Skip to content

Commit

Permalink
Use spaCy v2.3.0 or later to use HocrVisualParser (fix #527)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiromu Hota committed Oct 23, 2020
1 parent 3abbe5c commit c1a6600
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/fonduer/parser/visual_parser/hocr_visual_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ def __init__(
):
"""Initialize a visual parser.
:raises ImportError: an error is raised when spaCy is not 2.2.2 or later.
:raises ImportError: an error is raised when spaCy is not 2.3.0 or later.
"""
if version.parse(spacy.__version__) < version.parse("2.2.2"):
if version.parse(spacy.__version__) < version.parse("2.3.0"):
raise ImportError(
f"You are using spaCy {spacy.__version__},"
f"but it should be 2.2.2 or later."
f"You are using spaCy {spacy.__version__}, "
f"but it should be 2.3.0 or later to use {__class__.__name__}."
)
spacy.gold.USE_NEW_ALIGN = True
self.replacements: List[Tuple[Pattern, str]] = []
for (pattern, replace) in replacements:
self.replacements.append((re.compile(pattern, flags=re.UNICODE), replace))
Expand Down

0 comments on commit c1a6600

Please sign in to comment.