loodos / zemberek-python

Python implementation of Zemberek
Other
112 stars 14 forks source link

normalizer.normalize("musunuz") Attribute error #3

Closed orhanabar closed 2 years ago

orhanabar commented 3 years ago

Merhabe, Normalizasyon fonksiyonunu calistirdigimda eger girilen cumlede "musunuz" kelimesi geciyorsa asagidaki hatayi aliyorum.


AttributeError Traceback (most recent call last)

in ----> 1 normalized = normalizer.normalize("olur musunuz") ~/anaconda3/lib/python3.7/site-packages/zemberek/normalization/turkish_sentence_normalizer.py in normalize(self, sentence) 113 114 def normalize(self, sentence: str) -> str: --> 115 processed = self.pre_process(sentence) 116 117 tokens: Tuple[Token] = tuple(TurkishTokenizer.DEFAULT.tokenize(processed)) ~/anaconda3/lib/python3.7/site-packages/zemberek/normalization/turkish_sentence_normalizer.py in pre_process(self, sentence) 229 s = self.combine_necessary_words(tokens) 230 tokens: Tuple[Token] = TurkishTokenizer.DEFAULT.tokenize(s) --> 231 s = self.split_necessary_words(tokens, use_look_up=False) 232 if self.always_apply_deasciifier or self.probably_requires_deasciifier(s): 233 deasciifier = Deasciifier(s) ~/anaconda3/lib/python3.7/site-packages/zemberek/normalization/turkish_sentence_normalizer.py in split_necessary_words(self, tokens, use_look_up) 243 text = token.content 244 if self.is_word(token): --> 245 result.append(self.separate_common(text, use_look_up)) 246 else: 247 result.append(text) ~/anaconda3/lib/python3.7/site-packages/zemberek/normalization/turkish_sentence_normalizer.py in separate_common(self, inp, use_look_up) 264 return inp 265 --> 266 if self.has_regular_analysis(head): 267 return f"{head} {tail}" 268 else: ~/anaconda3/lib/python3.7/site-packages/zemberek/normalization/turkish_sentence_normalizer.py in has_regular_analysis(self, s) 320 321 def has_regular_analysis(self, s: str) -> bool: --> 322 a: WordAnalysis = self.morphology.analyze(s) 323 for s in a: 324 if (not s.is_unknown()) and (not s.is_runtime()) and s.item.secondary_pos != SecondaryPos.ProperNoun \ ~/anaconda3/lib/python3.7/site-packages/zemberek/morphology/turkish_morphology.py in analyze(self, word) 51 @lru_cache(maxsize=200) 52 def analyze(self, word: str) -> WordAnalysis: ---> 53 return self.analyze_without_cache(word=word) 54 55 @staticmethod ~/anaconda3/lib/python3.7/site-packages/zemberek/morphology/turkish_morphology.py in analyze_without_cache(self, word, token) 69 self.analyze_without_cache(token=tokens[0]) 70 else: # token is not None ---> 71 word = token.content # equal to token.getText() 72 s = self.normalize_for_analysis(word) 73 if len(s) == 0: AttributeError: 'NoneType' object has no attribute 'content'
harun-loodos commented 2 years ago

Bu issue'ya cevap vermeyi unutmuşum sanırım, kusura bakmayın. Bu problem sanırsam şu an devam etmiyor. Epey önce düzeltmiştim bunu. Normalizasyon modülünde v0.2.1'de pek çok iyileştirme yaptım. Onu deneyebilirsiniz. Şimdilik bu başlığı kapatıyorum. Aynı problemi yaşarsanız tekrar açabilirsiniz.