From cbbb1df11f1e388665e24af92f0fec1a40ff956e Mon Sep 17 00:00:00 2001 From: thorunna Date: Fri, 18 Jun 2021 13:31:00 +0000 Subject: [PATCH 1/9] minor fix for dir_loc corrections --- src/reynir_correct/pattern.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/reynir_correct/pattern.py b/src/reynir_correct/pattern.py index a83f6a70..e3d40d27 100644 --- a/src/reynir_correct/pattern.py +++ b/src/reynir_correct/pattern.py @@ -1685,14 +1685,23 @@ def dir4loc(verbs: Set[str], tree: SimpleTree) -> bool: cls.ctx_dir_loc, ) ) - cls.add_pattern( - ( - "inn", # Trigger lemma for this pattern - "VP > { VP > { %verb } ADVP > { 'inn' } }", - lambda self, match: self.dir_loc(match), - cls.ctx_dir_loc, - ) - ) +# cls.add_pattern( +# ( +# "inn", # Trigger lemma for this pattern +# "IP > { IP-INF > { VP > { VP > { %verb } ADVP > { 'inn' } } } PP > { P > { ('á'|'í') } NP } }", +# #"VP > { VP > { %verb } ADVP > { 'inn' } }", +# lambda self, match: self.dir_loc(match), +# cls.ctx_dir_loc, +# ) +# ) +# cls.add_pattern( +# ( +# "inn", # Trigger lemma for this pattern +# "VP > { VP > { %verb } ADVP > { 'inn' } }", +# lambda self, match: self.dir_loc(match), +# cls.ctx_dir_loc, +# ) +# ) cls.add_pattern( ( From 36a40dbca38862f7c8fe77ea34d17d75a9f34363 Mon Sep 17 00:00:00 2001 From: thorunna Date: Mon, 21 Jun 2021 10:53:01 +0000 Subject: [PATCH 2/9] added Icelandic places and their respective preposition --- src/reynir_correct/resources/iceloc_prep.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/reynir_correct/resources/iceloc_prep.json b/src/reynir_correct/resources/iceloc_prep.json index f24d45c1..4b0ea269 100644 --- a/src/reynir_correct/resources/iceloc_prep.json +++ b/src/reynir_correct/resources/iceloc_prep.json @@ -29,6 +29,7 @@ "Auðnir": "á", "Auðshaugur": "á", "Auðsholt": "í", + "Austurstræti": "í", "Bakkagerði": "í", "Bakki": "á", "Bár": "í", @@ -108,6 +109,7 @@ "Ferjubakki": "á", "Finnmörk": "á", "Fitjar": "á", + "Fjarðarbyggð": "í", "Fjarðarhorn": "í", "Fjósatunga": "í", "Flaga": "í", @@ -137,6 +139,7 @@ "Gilsbakki": "á", "Gjögur": "á", "Glóra": "í", + "Grafarvogur": "í", "Grænavatn": "á", "Grenivík": "í", "Grenjaðarstaður": "á", @@ -237,6 +240,7 @@ "Hveragerði": "í", "Hveravellir": "á", "Hvoll": "á", + "Hvolsvöllur": "á", "Ingjaldshóll": "á", "Ingunnarstaðir": "á", "Jaðar": "á", @@ -252,6 +256,7 @@ "Kirkjubær": "í", "Kirkjuból": "á", "Kjálki": "á", + "Kjarardalur": "í", "Kjarnholt": "í", "Klængshóll": "á", "Klaustur": "á", @@ -274,6 +279,7 @@ "Kvennabrekka": "á", "Kvígindisdalur": "í", "Kvísker": "á", + "Lækjarbakki": "á", "Lækur": "á", "Lambafell": "á", "Lambavatn": "á", @@ -432,6 +438,7 @@ "Vatnshorn": "í", "Vellir": "á", "Vestmannaeyjar": "í", + "Vesturlönd": "á", "Viðey": "í", "Vík": "í", "Víkingavatn": "á", From 7957ad43c2246ff378f33a060f4ee2063e49411d Mon Sep 17 00:00:00 2001 From: thorunna Date: Wed, 23 Jun 2021 09:06:35 +0000 Subject: [PATCH 3/9] added place names --- src/reynir_correct/resources/iceloc_prep.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reynir_correct/resources/iceloc_prep.json b/src/reynir_correct/resources/iceloc_prep.json index 4b0ea269..66ce2431 100644 --- a/src/reynir_correct/resources/iceloc_prep.json +++ b/src/reynir_correct/resources/iceloc_prep.json @@ -109,7 +109,7 @@ "Ferjubakki": "á", "Finnmörk": "á", "Fitjar": "á", - "Fjarðarbyggð": "í", + "Fjarðabyggð": "í", "Fjarðarhorn": "í", "Fjósatunga": "í", "Flaga": "í", From 3a9128d364c09ab6ee9dd2101822b363d6dc051a Mon Sep 17 00:00:00 2001 From: thorunna Date: Wed, 23 Jun 2021 09:07:31 +0000 Subject: [PATCH 4/9] added comment --- src/reynir_correct/pattern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reynir_correct/pattern.py b/src/reynir_correct/pattern.py index e3d40d27..07a84328 100644 --- a/src/reynir_correct/pattern.py +++ b/src/reynir_correct/pattern.py @@ -73,7 +73,7 @@ class IcelandicPlaces: # "fjörður": "á", # Skip this since 'í *firði' is also common "eyri": "á", "vogur": "í", - "brekka": "í", + "brekka": "í", #Ath. algeng ending á bæjarheitum sem taka með sér 'á' "staðir": "á", # "höfn": "á", # Skip this since 'í *höfn' is also common "eyjar": "í", From 25d6c80b0be63a518d6a4f2ecc3f0eaa06d66cc2 Mon Sep 17 00:00:00 2001 From: thorunna Date: Tue, 29 Jun 2021 10:37:36 +0000 Subject: [PATCH 5/9] added handling for preps with countries --- src/reynir_correct/pattern.py | 69 ++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/reynir_correct/pattern.py b/src/reynir_correct/pattern.py index 07a84328..de45e5fa 100644 --- a/src/reynir_correct/pattern.py +++ b/src/reynir_correct/pattern.py @@ -46,6 +46,8 @@ import os import json +from islenska import Bin + from reynir import Sentence, NounPhrase from reynir.simpletree import SimpleTree from reynir.verbframe import VerbErrors @@ -53,6 +55,11 @@ from .annotation import Annotation +BIN = Bin() + +# Variants not needed for lookup +SKIPVARS = ["OP", "SUBJ"] + # The types involved in pattern processing AnnotationFunction = Callable[["PatternMatcher", SimpleTree], None] @@ -121,6 +128,40 @@ def includes(cls, place: str) -> bool: assert cls.ICELOC_PREP is not None return place in cls.ICELOC_PREP +class Countries: + + """ Wraps a dictionary of country names with their + associated prepositions """ + + COUNTRIES_PREP: Optional[Dict[str, str]] = None + COUNTRIES_PREP_JSONPATH = os.path.join( + os.path.dirname(__file__), "resources", "countries_prep.json" + ) + + @classmethod + def _load_json(cls) -> None: + """ Load the place name dictionary from a JSON file into memory """ + with open(cls.COUNTRIES_PREP_JSONPATH, encoding="utf-8") as f: + cls.COUNTRIES_PREP = json.load(f) + + @classmethod + def lookup_preposition(cls, place: str) -> Optional[str]: + """ Look up the correct preposition to use with a placename, + or None if the placename is not known """ + if cls.COUNTRIES_PREP is None: + cls._load_json() + assert cls.COUNTRIES_PREP is not None + prep = cls.COUNTRIES_PREP.get(place) + return prep + + @classmethod + def includes(cls, place: str) -> bool: + """ Return True if the given place is found in the dictionary """ + if cls.COUNTRIES_PREP is None: + cls._load_json() + assert cls.COUNTRIES_PREP is not None + return place in cls.COUNTRIES_PREP + class PatternMatcher: @@ -166,6 +207,28 @@ def __init__(self, ann: List[Annotation], sent: Sentence) -> None: # First instance: create the class-wide pattern list self.create_patterns() + def get_wordform(self, lemma, cat, variants): + """ Get correct wordform from BinPackage, + given a set of variants """ + + # Get rid of argument variants in verbs: + variants = list( [ x for x in variants if not x.isdigit()]) + realvars = [] + for x in variants: + if x.isdigit: + continue + if x in SKIPVARS: + continue + else: + realvars.append(x) + + wordforms = BIN.lookup_variants(lemma, cat, realvars) + if not wordforms: + return "" + else: + # Can be many possible word forms, want the first one in most cases + return wordforms[0].bmynd + def wrong_preposition_af(self, match: SimpleTree) -> None: """ Handle a match of a suspect preposition pattern """ # Find the offending verb phrase @@ -798,8 +861,10 @@ def check_pp_with_place(self, match: SimpleTree) -> None: place = match.NP.lemma correct_preposition = IcelandicPlaces.lookup_preposition(place) if correct_preposition is None: - # This is not a known or likely place name - return + correct_preposition = Countries.lookup_preposition(place) + if correct_preposition is None: + # This is not a known or likely place name + return preposition = match.P.lemma if correct_preposition == preposition: # Correct: return From 10be95fbe675b635507b2ae435b3e5df3518d5c8 Mon Sep 17 00:00:00 2001 From: thorunna Date: Tue, 29 Jun 2021 10:38:15 +0000 Subject: [PATCH 6/9] added handling for preps with countries --- .../resources/countries_prep.json | 314 ++++++++++++++++++ 1 file changed, 314 insertions(+) create mode 100644 src/reynir_correct/resources/countries_prep.json diff --git a/src/reynir_correct/resources/countries_prep.json b/src/reynir_correct/resources/countries_prep.json new file mode 100644 index 00000000..cc5af5fb --- /dev/null +++ b/src/reynir_correct/resources/countries_prep.json @@ -0,0 +1,314 @@ +{ +"Afganistan":"í", +"Albanía":"í", +"Alsír":"í", +"Andorra":"í", +"Angvilla":"í", +"Angóla":"í", +"Antigva":"á", +"Antigúa":"á", +"Antígva":"á", +"Antígva og Barbúda":"á", +"Argentína":"í", +"Armenía":"í", +"Arúba":"í", +"Aserbaídsjan":"í", +"Aserbaísjan":"í", +"Aserbædjan":"í", +"Austur-Kongó":"í", +"Austur-Tímor":"í", +"Austurríki":"í", +"Azerbaijan":"í", +"Bahamaeyjar":"á", +"Bahrain":"í", +"Bandaríkin":"í", +"Bandaríki Norður-Ameríku":"í", +"Bandaríska Samóa":"í", +"Bandarísku Jómfrúaeyjar":"á", +"Bangladess":"í", +"Barbados":"á", +"Barbadoseyjar":"á", +"Barein":"í", +"Belgía":"í", +"Belís":"í", +"Benín":"í", +"Bermúdaeyjar":"á", +"Bosnía":"í", +"Bosnía og Hersegóvína":"í", +"Botsvana":"í", +"Bouveteyja":"í", +"Brasilía":"í", +"Bresku Indlandshafseyjar":"á", +"Bresku Jómfrúaeyjar":"á", +"Bretland":"í", +"Brúnei":"í", +"Burma":"í", +"Bólivía":"í", +"Búlgaría":"í", +"Búrkína Fasó":"í", +"Búrma":"í", +"Búrúndí":"í", +"Bútan":"í", +"Caicoseyjar":"á", +"Caymaneyjar":"á", +"Chile":"í", +"Cooks-eyjar":"á", +"Cookseyjar":"á", +"Curacao":"í", +"Danmörk":"í", +"Djíbútí":"í", +"Dóminíka":"á", +"Dóminíska lýðveldið":"í", +"Egiftaland":"í", +"Egiptaland":"í", +"Egyptaland":"í", +"Eistland":"í", +"Ekvador":"í", +"El Salvador":"í", +"England":"í", +"Erítrea":"í", +"Eþíópía":"í", +"Falklandseyjar":"á", +"Filippseyjar":"á", +"Finnland":"í", +"Frakkland":"í", +"Franska Gvæjana":"í", +"Franska Pólýnesía":"í", +"Frönsku suðlægu landsvæðin":"á", +"Færeyjar":"í", +"Fídjieyjar":"á", +"Fídjíeyjar":"á", +"Fílabeinsströndin":"í", +"Gabon":"í", +"Gambía":"í", +"Gana":"í", +"Georgía":"í", +"Ghana":"í", +"Grenada":"á", +"Grenadíneyjar":"á", +"Grikkland":"í", +"Grænhöfðaeyjar":"á", +"Grænland":"á", +"Guatemala":"í", +"Guernsey":"á", +"Gvadelúpeyjar":"á", +"Gvam":"í", +"Gvatemala":"í", +"Gvæjana":"í", +"Gíbraltar":"í", +"Gínea":"í", +"Gínea-Bissá":"í", +"Haítí":"á", +"Heard og McDonaldseyjar":"í", +"Hersegóvína":"í", +"Holland":"í", +"Hondúras":"í", +"Hong Kong":"í", +"Hvíta-Rússland":"í", +"Indland":"í", +"Indónesía":"í", +"Jamaíka":"á", +"Japan":"í", +"Jemen":"í", +"Jersey":"á", +"Jólaey":"á", +"Jómfrúaeyjar":"í", +"Jórdanía":"í", +"Kambódía":"í", +"Kamerún":"í", +"Kanada":"í", +"Kanaríeyjar":"á", +"Karíbahafshluti Hollands":"í", +"Kasakstan":"í", +"Katar":"í", +"Kenía":"í", +"Kenýa":"í", +"Kirgisistan":"í", +"Kirgistan":"í", +"Kongó":"í", +"Kongó-Brazzaville":"í", +"Kongó-Kinshasa":"í", +"Kosovo":"í", +"Kostaríka":"í", +"Króatía":"í", +"Kína":"í", +"Kípur":"á", +"Kíribatí":"í", +"Kíríbatí":"í", +"Kókoseyjar":"á", +"Kólumbía":"í", +"Kómoreyjar":"á", +"Kórea":"í", +"Kúba":"á", +"Kúveit":"í", +"Kýpur":"á", +"Laos":"í", +"Lesótó":"í", +"Lettland":"í", +"Liechtenstein":"í", +"Litháen":"í", +"Líbanon":"í", +"Líbería":"í", +"Líbía":"í", +"Líbýa":"í", +"Lúxemborg":"í", +"Lýbía":"í", +"Madagaskar":"á", +"Makaó":"í", +"Malasía":"í", +"Malaví":"í", +"Malawi":"í", +"Maldíveyjar":"á", +"Malta":"á", +"Malí":"í", +"Marokkó":"í", +"Marshalleyjar":"á", +"Martiník":"á", +"Mayotte":"í", +"Mexíkó":"í", +"Mikrónesía":"í", +"Mið-Afríkulýðveldið":"í", +"Miðbaugs-Gínea":"í", +"Mjanmar":"í", +"Moldavía":"í", +"Moldóva":"í", +"Mongólía":"í", +"Montserrat":"í", +"Myanmar":"í", +"Máritanía":"í", +"Máritíus":"í", +"Míkrónesía":"í", +"Mónakó":"í", +"Mósambík":"í", +"Mön":"á", +"Namibía":"í", +"Nepal":"í", +"Nevis":"í", +"Nikaragva":"í", +"Nikaragúa":"í", +"Niue":"í", +"Noregur":"í", +"Norfolkeyja":"á", +"Norður-Kórea":"í", +"Norður-Makedónía":"í", +"Norður-Maríanaeyjar":"á", +"Norður-Írland":"í", +"Nárú":"á", +"Níger":"í", +"Nígería":"í", +"Níkaragva":"í", +"Nýja-Kaledónía":"í", +"Nýja-Sjáland":"á", +"Pakistan":"í", +"Palestína":"í", +"Palá":"í", +"Panama":"í", +"Papúa":"í", +"Papúa Nýja-Gínea":"í", +"Paragvæ":"í", +"Perú":"í", +"Pitcairn-eyjar":"á", +"Portúgal":"í", +"Páfagarður":"í", +"Páfaríki":"í", +"Páfastóll":"í", +"Pólland":"í", +"Púertó Ríkó":"í", +"Réunion":"í", +"Rúanda":"í", +"Rúmenía":"í", +"Rússland":"í", +"Saint-Martin":"á", +"Salvador":"í", +"Salómonseyjar":"á", +"Sambía":"í", +"Sameinuðu arabísku furstadæmin":"í", +"Samóa":"í", +"San Marínó":"í", +"Sankti Bartólómeusareyjar":"á", +"Sankti Helena":"á", +"Sankti Kitts og Nevis":"í", +"Sankti Lúsía":"á", +"Sankti Martin":"á", +"Sankti Pierre og Miquelon":"á", +"Sankti Vinsent og Grenadíneyjar":"á", +"Saó Tóme og Prinsípe":"í", +"Senegal":"í", +"Serbía":"í", +"Seychelles-eyjar":"á", +"Seychelleseyjar":"á", +"Simbabve":"í", +"Singapúr":"í", +"Skotland":"í", +"Slóvakía":"í", +"Slóvenía":"í", +"Smáeyjar Bandaríkjanna":"í", +"Spánn":"á", +"Sri Lanka":"á", +"Srí Lanka":"á", +"Stóra-Bretland":"í", +"Suður-Afríka":"í", +"Suður-Georgía og Suður-Sandvíkureyjar":"á", +"Suður-Kórea":"í", +"Suður-Súdan":"í", +"Suðurskautslandið":"á", +"Svalbarði og Jan Mayen":"á", +"Svartfjallaland":"í", +"Svasíland":"í", +"Sviss":"í", +"Svíþjóð":"í", +"Sádi-Arabía":"í", +"Síerra Leóne":"í", +"Síle":"í", +"Sómalía":"í", +"Súdan":"í", +"Súrínam":"í", +"Sýrland":"í", +"Tadsjikistan":"í", +"Tansanía":"í", +"Taíland":"í", +"Taívan":"í", +"Tonga":"í", +"Trínidad":"í", +"Trínidad og Tóbagó":"í", +"Tsjad":"í", +"Turks- og Caicoseyjar":"á", +"Tyrkland":"í", +"Tæland":"í", +"Tékkland":"í", +"Tímor-Leste":"í", +"Tóbagó":"í", +"Tógó":"í", +"Tókelá":"í", +"Túnis":"í", +"Túrkmenistan":"í", +"Túvalú":"í", +"Ungverjaland":"í", +"Vanúatú":"á", +"Vatikan":"í", +"Vatikanið":"í", +"Vatikanríki":"í", +"Vatíkan":"í", +"Vatíkanið":"í", +"Vatíkanríki":"í", +"Venesúela":"í", +"Vestur-Kongó":"í", +"Vestur-Sahara":"í", +"Víetnam":"í", +"Wales":"í", +"Wallis- og Fútúnaeyjar":"á", +"Álandseyjar":"á", +"Ástralía":"í", +"Írak":"í", +"Íran":"í", +"Írland":"á", +"Ísland":"á", +"Ísrael":"í", +"Ítalía":"á", +"Óman":"í", +"Úganda":"í", +"Úkraína":"í", +"Úrúgvæ":"í", +"Úsbekistan":"í", +"Þýskaland":"í" +} \ No newline at end of file From 2bd924c9a75f0c52cae7557228e19cd23492ee2a Mon Sep 17 00:00:00 2001 From: thorunna Date: Tue, 29 Jun 2021 10:53:50 +0000 Subject: [PATCH 7/9] fixed get_wordform() --- src/reynir_correct/pattern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reynir_correct/pattern.py b/src/reynir_correct/pattern.py index de45e5fa..0ef62616 100644 --- a/src/reynir_correct/pattern.py +++ b/src/reynir_correct/pattern.py @@ -215,7 +215,7 @@ def get_wordform(self, lemma, cat, variants): variants = list( [ x for x in variants if not x.isdigit()]) realvars = [] for x in variants: - if x.isdigit: + if x.isdigit(): continue if x in SKIPVARS: continue From de9626b8bc773ad03b8abdc0f997b25d021f2f8c Mon Sep 17 00:00:00 2001 From: thorunna Date: Fri, 13 Oct 2023 09:21:06 +0000 Subject: [PATCH 8/9] resolved conflict --- src/reynir_correct/pattern.py | 45 ++++++++++------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/src/reynir_correct/pattern.py b/src/reynir_correct/pattern.py index 0838e82b..7dfe23b8 100644 --- a/src/reynir_correct/pattern.py +++ b/src/reynir_correct/pattern.py @@ -78,7 +78,7 @@ class IcelandicPlaces: # "fjörður": "á", # Skip this since 'í *firði' is also common "eyri": "á", "vogur": "í", - "brekka": "í", #Ath. algeng ending á bæjarheitum sem taka með sér 'á' + "brekka": "í", # Ath. algeng ending á bæjarheitum sem taka með sér 'á' "staðir": "á", # "höfn": "á", # Skip this since 'í *höfn' is also common "eyjar": "í", @@ -124,26 +124,25 @@ def includes(cls, place: str) -> bool: assert cls.ICELOC_PREP is not None return place in cls.ICELOC_PREP + class Countries: - """ Wraps a dictionary of country names with their - associated prepositions """ + """Wraps a dictionary of country names with their + associated prepositions""" COUNTRIES_PREP: Optional[Dict[str, str]] = None - COUNTRIES_PREP_JSONPATH = os.path.join( - os.path.dirname(__file__), "resources", "countries_prep.json" - ) + COUNTRIES_PREP_JSONPATH = os.path.join(os.path.dirname(__file__), "resources", "countries_prep.json") @classmethod def _load_json(cls) -> None: - """ Load the place name dictionary from a JSON file into memory """ + """Load the place name dictionary from a JSON file into memory""" with open(cls.COUNTRIES_PREP_JSONPATH, encoding="utf-8") as f: cls.COUNTRIES_PREP = json.load(f) @classmethod def lookup_preposition(cls, place: str) -> Optional[str]: - """ Look up the correct preposition to use with a placename, - or None if the placename is not known """ + """Look up the correct preposition to use with a placename, + or None if the placename is not known""" if cls.COUNTRIES_PREP is None: cls._load_json() assert cls.COUNTRIES_PREP is not None @@ -152,7 +151,7 @@ def lookup_preposition(cls, place: str) -> Optional[str]: @classmethod def includes(cls, place: str) -> bool: - """ Return True if the given place is found in the dictionary """ + """Return True if the given place is found in the dictionary""" if cls.COUNTRIES_PREP is None: cls._load_json() assert cls.COUNTRIES_PREP is not None @@ -223,11 +222,11 @@ def get_wordform(word: str, lemma: str, cat: str, variants: Iterable[str]) -> st return wordforms[0].bmynd def get_wordform(self, lemma, cat, variants): - """ Get correct wordform from BinPackage, - given a set of variants """ + """Get correct wordform from BinPackage, + given a set of variants""" # Get rid of argument variants in verbs: - variants = list( [ x for x in variants if not x.isdigit()]) + variants = list([x for x in variants if not x.isdigit()]) realvars = [] for x in variants: if x.isdigit(): @@ -2619,25 +2618,6 @@ def dir4loc(verbs: FrozenSet[str], tree: SimpleTree) -> bool: self.ctx_dir_loc, ) ) -<<<<<<< HEAD -# cls.add_pattern( -# ( -# "inn", # Trigger lemma for this pattern -# "IP > { IP-INF > { VP > { VP > { %verb } ADVP > { 'inn' } } } PP > { P > { ('á'|'í') } NP } }", -# #"VP > { VP > { %verb } ADVP > { 'inn' } }", -# lambda self, match: self.dir_loc(match), -# cls.ctx_dir_loc, -# ) -# ) -# cls.add_pattern( -# ( -# "inn", # Trigger lemma for this pattern -# "VP > { VP > { %verb } ADVP > { 'inn' } }", -# lambda self, match: self.dir_loc(match), -# cls.ctx_dir_loc, -# ) -# ) -======= self.add_pattern( ( "inn", # Trigger lemma for this pattern @@ -2646,7 +2626,6 @@ def dir4loc(verbs: FrozenSet[str], tree: SimpleTree) -> bool: self.ctx_dir_loc, ) ) ->>>>>>> e7d0ac4a2829215916c424e2fc254b8ac5615edc self.add_pattern( ( From 6f13832fd09c06e38b336d4d66df3531e839cfbc Mon Sep 17 00:00:00 2001 From: thorunna Date: Wed, 25 Oct 2023 09:45:58 +0000 Subject: [PATCH 9/9] responded to comment --- src/reynir_correct/pattern.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/reynir_correct/pattern.py b/src/reynir_correct/pattern.py index 7dfe23b8..7842fc49 100644 --- a/src/reynir_correct/pattern.py +++ b/src/reynir_correct/pattern.py @@ -226,15 +226,7 @@ def get_wordform(self, lemma, cat, variants): given a set of variants""" # Get rid of argument variants in verbs: - variants = list([x for x in variants if not x.isdigit()]) - realvars = [] - for x in variants: - if x.isdigit(): - continue - if x in SKIPVARS: - continue - else: - realvars.append(x) + realvars = [x for x in variants if not x.isdigit() and x not in SKIPVARS] wordforms = BIN.lookup_variants(lemma, cat, realvars) if not wordforms: