From ad3fffd7bc8201d102c78c177a7668b61b45916f Mon Sep 17 00:00:00 2001 From: Andrey Golovizin Date: Mon, 25 Aug 2014 13:41:03 +0200 Subject: [PATCH] Disable score-based dicritic detection, use the first matching body. --- pixelocr/page.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pixelocr/page.py b/pixelocr/page.py index e7b7fa1..1ec8537 100644 --- a/pixelocr/page.py +++ b/pixelocr/page.py @@ -146,8 +146,9 @@ class Line(PageObject): if glyph.is_body(): continue neighbours = neighbourhood(glyphs, i, 5) - body = max(neighbours, key=lambda neighbour: neighbour.detect_diacritic(glyph)) - if body.detect_diacritic(glyph): + possible_bodies = [body for body in neighbours if body.detect_diacritic(glyph)] + if possible_bodies: + body = possible_bodies[0] diacritics[body].append(glyph) bodies[glyph].append(body) return bodies, diacritics