Skip to content

Commit

Permalink
new version 0.3.27
Browse files Browse the repository at this point in the history
  • Loading branch information
falgore88 committed Jul 4, 2016
1 parent 78bac04 commit afe8a03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
@@ -1,7 +1,7 @@
from setuptools import setup


VERSION = "0.3.26"
VERSION = "0.3.27"

setup(
name='ta4',
Expand Down
6 changes: 2 additions & 4 deletions ta4/__init__.py
Expand Up @@ -32,7 +32,7 @@ def mark_with_words(words, text, analyzers={}):
False: SubformsAnalyzer(),
}
number = 1 # скозная нумерация маркеров
for word in words:
for word in set(words):
for sentence in text:
analyzer = analyzers[word.is_exact_task]
number = analyzer.mark(word, sentence, number)
Expand Down Expand Up @@ -88,10 +88,8 @@ def find_similar_phrases(phrases, text):
Находит похожие фразы. Если в предложении мы встретили какое нибудь слово из фраз,
то мы нарезаем это предложение на фразы. Максимальный промежуток между вхождениями
одно значимое слово
`
"""
words = [Sentence(word.word) for phrase in phrases for word in phrase]
words = set([Sentence(word.word) for phrase in phrases for word in phrase])
new_phrases = []
mark_with_words(words, text)
for sentence in text:
Expand Down
7 changes: 7 additions & 0 deletions ta4/sentence.py
@@ -1,5 +1,6 @@
#! coding: utf-8
import itertools
from hashlib import md5

class Sentence(object):
__slots__ = ['text', 'place_holders']
Expand All @@ -22,6 +23,12 @@ def __iter__(self):
for ph in self.place_holders:
yield ph

def __eq__(self, other):
return isinstance(other, Sentence) and self.__hash__() == other.__hash__()

def __hash__(self):
return int(md5(self.text).hexdigest(), 16)

def __getitem__(self, item):
return self.place_holders[item]

Expand Down

0 comments on commit afe8a03

Please sign in to comment.