Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
p-goulart committed Nov 30, 2023
1 parent 0e26218 commit 09afc18
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 20 deletions.
1 change: 0 additions & 1 deletion pt_dict/dicts/dictionary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from typing import List


class Dictionary:
Expand Down
2 changes: 1 addition & 1 deletion pt_dict/scripts/build_spelling_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tempfile import NamedTemporaryFile
from os import path

from pt_dict.constants import DICT_DIR, HUNSPELL_DIR, LT_JAR_PATH, LOGGER, LT_DIR, LT_VER, LATIN_1_ENCODING
from pt_dict.constants import DICT_DIR, LT_JAR_PATH, LOGGER, LT_DIR, LT_VER, LATIN_1_ENCODING
from pt_dict.utils import run_command, compile_lt_dev, run_command_with_input, install_dictionaries
from pt_dict.variants.variant import Variant, DIC_VARIANTS

Expand Down
2 changes: 0 additions & 2 deletions pt_dict/scripts/clean_pt_pt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re

from pt_dict.constants import LATIN_1_ENCODING
from pt_dict.variants.variant import PT_PT_90, PT_PT_45

Expand Down
5 changes: 1 addition & 4 deletions pt_dict/scripts/clean_replacements_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
from os import path

from pt_dict.constants import RULES_DIR, ALTERNATIONS_DIR
Expand All @@ -15,9 +14,7 @@ def main():
pair = line.split('=')
alternations.update(pair)

variants = [PT_BR]
# variants = [PT_BR, PT_PT_90]
vowel_pattern = re.compile('[êéôó]')
variants = [PT_BR, PT_PT_90]
for var in variants:
replacements_filepath = path.join(RULES_DIR, var.hyphenated, "replace.txt")
with open(replacements_filepath, 'r') as replacements_file:
Expand Down
1 change: 0 additions & 1 deletion pt_dict/scripts/compounds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import random
import re

from pt_dict.constants import COMPOUNDS_FILEPATH, LATIN_1_ENCODING
Expand Down
11 changes: 7 additions & 4 deletions pt_dict/scripts/dedupe_dictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ def main():
print(var)
total_all_lines = len(all_lines)
total_unique_lines = len(unique_lines)
print(f"total - unique = duplicated lines || {total_all_lines} - {total_unique_lines} = {total_all_lines - total_unique_lines}")
print(f"total - unique = duplicated lines ||"
f"{total_all_lines} - {total_unique_lines} = {total_all_lines - total_unique_lines}")

lemmata_with_multiple_lines = set(filter(lambda l: len(lemma_to_line_mapping[l]) > 1, lemma_to_line_mapping.keys()))
lemmata_with_multiple_lines = set(filter(lambda lemma: len(lemma_to_line_mapping[lemma]) > 1,
lemma_to_line_mapping.keys()))
print(f"duplicated lemmata: {len(lemmata_with_multiple_lines)}")

lemmata_with_multiple_unique_lines = set(filter(lambda l: len(set(lemma_to_line_mapping[l])) > 1, lemma_to_line_mapping.keys()))
lemmata_with_multiple_unique_lines = set(filter(lambda lemma: len(set(lemma_to_line_mapping[lemma])) > 1,
lemma_to_line_mapping.keys()))
print(f"duplicated lemmata with multiple unique lines: {len(lemmata_with_multiple_unique_lines)}")
print(sorted(lemmata_with_multiple_unique_lines))

Expand All @@ -48,7 +51,7 @@ def main():
for line in lines:
try:
write_lines.remove(line)
except:
except: # noqa: E722
pass
tag_match = tag_pattern.search(line)
if tag_match:
Expand Down
3 changes: 1 addition & 2 deletions pt_dict/scripts/migrate_to_tagger_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import re

from pt_dict.constants import LATIN_1_ENCODING
from pt_dict.dicts.hunspell import HunspellDict
from pt_dict.dicts.tagger import TaggerDict
from pt_dict.utils import print_sample
from pt_dict.variants.variant import Variant, PT_BR, PT_PT_90
Expand Down Expand Up @@ -34,7 +33,7 @@ def collect_tagged_lemmata(variant: Variant):


def main():
for var in [PT_BR]:
for var in [PT_BR, PT_PT_90]:
collect_tagged_lemmata(var)


Expand Down
1 change: 0 additions & 1 deletion pt_dict/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from os import chdir, path
from typing import List

import chardet as chardet
import random

from pt_dict.constants import LOGGER, LT_DIR, REPO_DIR, RESULTS_DIR
Expand Down
2 changes: 1 addition & 1 deletion pt_dict/variants/alternation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""In this module we define the logic for alternations between variants."""
from typing import Literal, Optional, List

from pt_dict.variants.syllabifier import Syllabifier, Syllables
from pt_dict.variants.syllabifier import Syllables
import pt_dict.variants.phonology as phon


Expand Down
2 changes: 1 addition & 1 deletion pt_dict/variants/syllabifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from re import Pattern

import spacy
from spacy_syllables import SpacySyllables
from spacy_syllables import SpacySyllables # noqa:F401
from typing import List, Union, Optional

import pt_dict.variants.phonology as ph
Expand Down
1 change: 0 additions & 1 deletion test/test_alternation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ def test_alternation(self):
alternation.transform(self.syllabifier.syllabify('armênio')) # context applies
assert len(alternation.transformations) == 1
assert alternation.transformations[0].target == 'arménio'

1 change: 0 additions & 1 deletion test/test_syllabifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,3 @@ def test_syllabifier(self):
]
for word, syllables in syllabifications:
assert [syl.value for syl in syllabifier.syllabify(word).values] == syllables

0 comments on commit 09afc18

Please sign in to comment.