Skip to content

Commit

Permalink
Adapted the code to deal with morph without attributed POS
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Nov 16, 2020
1 parent cc77354 commit a79cb21
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pyrrha_ci/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,23 @@ def from_file_io(cls, config_file: TextIO) -> "PyrrhaCI":
cross_check_lemma = False
if config.get("allowed_lemma"):
for _, data in parse_tsv(_relative_path(config_file.name, config["allowed_lemma"])):
allowed_lemma[data["lemma"]] = set()
if data["lemma"] not in allowed_lemma:
allowed_lemma[data["lemma"]] = set()
if "POS" in data and data["POS"]:
cross_check_lemma = True
allowed_lemma[data["lemma"]] = set(data["POS"].split(","))
allowed_lemma[data["lemma"]] |= set(data["POS"].split(","))

# Ouverture et lecture du fichier morph.tsv avec délimiteur tsv : \t et encapsulateur ''.
allowed_morph: Dict[str, List[str]] = {}
cross_check_morph = False
if config.get("allowed_morph"):
for row_num, row in parse_tsv(_relative_path(config_file.name, config.get("allowed_morph"))):
morph = row["morph"]
_morph_pos = row.get("POS", "").split(",") if row.get("POS") else []
if morph in allowed_morph:
allowed_morph[morph].extend(row.get("POS", "").split(","))
allowed_morph[morph].extend(_morph_pos)
else:
allowed_morph[morph] = row.get("POS", "").split(",")
allowed_morph[morph] = _morph_pos
if len(allowed_morph[morph]):
cross_check_morph = True

Expand Down

0 comments on commit a79cb21

Please sign in to comment.