Skip to content

Commit

Permalink
fix progress count
Browse files Browse the repository at this point in the history
  • Loading branch information
ontanj committed Mar 11, 2020
1 parent 1b936f6 commit b1272d5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions propositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get(self, link):
return html

def fit(self, lemma):
match = self.regex_pattern.search(lemma) # TODO: matcha grundform
match = self.class_pattern.search(lemma) # TODO: matcha grundform
if match == None:
return None
else:
Expand Down Expand Up @@ -110,9 +110,10 @@ def _saol_lemmas(self, lemmas):
return defs[-1][0]

def compile_regex(self, pattern):
pattern = pattern.replace('@',f'(?:[{self.vocals}])').replace('£',f'(?:[{self.letters}])').replace('$',f'(?:[{self.consonants}])')
pattern = 'class="bform"[^<>]*>(' + pattern + ')</span>'
self.regex_pattern = re.compile(pattern)
pattern = pattern.replace('@',f'([{self.vocals}])').replace('£',f'([{self.letters}])').replace('$',f'([{self.consonants}])')
class_pattern = 'class="bform"[^<>]*>(' + pattern + ')</span>'
self.word_pattern = re.compile(pattern)
self.class_pattern = re.compile(class_pattern)

def from_pattern(self, pattern):
return pattern.replace('@','?').replace('£','?').replace('$','?')
Expand Down Expand Up @@ -159,8 +160,8 @@ def get_wild_numbers(self):
def calculate_progress(self, current):
if not self.verbose:
return
matches = self.regex_pattern.findall(current)
matches = matches[0]
matches = self.word_pattern.fullmatch(current)
matches = matches.groups()
progress = 0
for index in range(len(matches)):
if self.wild_sequence[index] == "@":
Expand All @@ -174,7 +175,7 @@ def calculate_progress(self, current):
def add_words(self, words):
for word in words:
if word not in self.words:
#self.calculate_progress(word[0])
self.calculate_progress(word[0])
self.words.append(word)

def prop(word):
Expand Down

0 comments on commit b1272d5

Please sign in to comment.