Skip to content

Commit

Permalink
remove unknown token from known vocab (#440)
Browse files Browse the repository at this point in the history
in FilterCorpusRemoveUnknownWordSegmentsJob
  • Loading branch information
michelwi authored Aug 25, 2023
1 parent 8c25c89 commit 6b06f97
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions corpus/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ def maybe_to_lower(s):
with open_func(lex_path, "rt") as f:
lex_root = ET.parse(f)
vocabulary = set([maybe_to_lower(o.text.strip() if o.text else "") for o in lex_root.findall(".//orth")])
vocabulary -= {
maybe_to_lower(o.text.strip() if o.text else "")
for l in lex_root.findall(".//lemma")
if l.attrib.get("special") == "unknown"
for o in l.findall(".//orth")
}

c = corpus.Corpus()
c.load(self.corpus.get_path())
Expand Down

0 comments on commit 6b06f97

Please sign in to comment.