QubitPi commited on
Commit
ca1fb62
·
unverified ·
1 Parent(s): 52aaa95

Remove parenthesis from definition during link inference (#112)

Browse files
huggingface/vocabulary_parser.py CHANGED
@@ -202,7 +202,7 @@ def get_definition_tokens(word: dict) -> set[str]:
202
  tokens = set()
203
 
204
  for token in set(sum([definition.split(" ") for definition in set().union(set(definitions))], [])):
205
- cleansed = token.lower().strip()
206
  if cleansed not in EXCLUDED_DEFINITION_TOKENS:
207
  tokens.add(cleansed)
208
 
 
202
  tokens = set()
203
 
204
  for token in set(sum([definition.split(" ") for definition in set().union(set(definitions))], [])):
205
+ cleansed = token.lower().strip().replace('(', '').replace(')', '') # trim and remove parenthesis
206
  if cleansed not in EXCLUDED_DEFINITION_TOKENS:
207
  tokens.add(cleansed)
208
 
tests/test_vocabulary_parser.py CHANGED
@@ -173,6 +173,17 @@ class TestVocabularyParser(unittest.TestCase):
173
  get_definition_tokens(vocabulary[0])
174
  )
175
 
 
 
 
 
 
 
 
 
 
 
 
176
  def test_get_term_tokens(self):
177
  vocabulary = yaml.safe_load("""
178
  vocabulary:
 
173
  get_definition_tokens(vocabulary[0])
174
  )
175
 
176
+ vocabulary = yaml.safe_load("""
177
+ vocabulary:
178
+ - term: exekutieren
179
+ definition: to execute (kill)
180
+ audio: https://upload.wikimedia.org/wikipedia/commons/f/f1/De-exekutieren.ogg
181
+ """)["vocabulary"]
182
+ self.assertEqual(
183
+ {"execute", "kill"},
184
+ get_definition_tokens(vocabulary[0])
185
+ )
186
+
187
  def test_get_term_tokens(self):
188
  vocabulary = yaml.safe_load("""
189
  vocabulary: