From 6c0411af17f912e000d183abd020633f87a57e6d Mon Sep 17 00:00:00 2001 From: ad Date: Fri, 23 Aug 2024 21:10:45 -0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=BF=D0=B0=D1=80=D1=81?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=20=D1=82=D0=B5=D0=B3=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruts/morph_stats.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ruts/morph_stats.py b/ruts/morph_stats.py index 233ce50..f4cadff 100644 --- a/ruts/morph_stats.py +++ b/ruts/morph_stats.py @@ -84,7 +84,9 @@ def __init__(self, source: Union[str, Doc], words_extractor: WordsExtractor = No raise ValueError("В источнике данных отсутствуют слова") morph = pymorphy2.MorphAnalyzer() - self.tags = tuple(morph.parse(word)[0].tag for word in self.words) + word_counts = Counter(self.words) + parsed_tags = {word: morph.parse(word)[0].tag for word in word_counts} + self.tags = tuple(parsed_tags[word] for word in self.words) self.pos = tuple(tag.POS for tag in self.tags) self.animacy = tuple(tag.animacy for tag in self.tags) self.aspect = tuple(tag.aspect for tag in self.tags)