raptorkwok commited on
Commit
78c8954
·
1 Parent(s): 21a1897

suppress WordNet warnings

Browse files
.gitignore CHANGED
@@ -1 +1,2 @@
 
1
  *.bak
 
1
+ .ipynb_checkpoints/
2
  *.bak
.ipynb_checkpoints/chinesemeteor-checkpoint.py CHANGED
@@ -28,6 +28,12 @@ import re
28
  # suppress WordNet warnings
29
  import warnings
30
  warnings.filterwarnings("ignore")
 
 
 
 
 
 
31
 
32
  # Download once
33
  nltk.download("wordnet", quiet=True)
@@ -192,7 +198,7 @@ class ChineseMETEOR(evaluate.Metric):
192
  if syn_lemmas_set:
193
  synsets_list.append(_CwnSynset(list(syn_lemmas_set), synset_id))
194
  #print(f"DEBUG: Found {len(synsets_list)} synsets for '{word}': {synsets_list[0]._lemmas if synsets_list else []}")
195
- return synsets_list
196
 
197
  # Use class for proper method binding
198
  class ChineseWordNet:
 
28
  # suppress WordNet warnings
29
  import warnings
30
  warnings.filterwarnings("ignore")
31
+ warnings.filterwarnings(
32
+ "ignore",
33
+ message="more than one synset, returning the first",
34
+ category=UserWarning,
35
+ module="nltk.translate.meteor_score"
36
+ )
37
 
38
  # Download once
39
  nltk.download("wordnet", quiet=True)
 
198
  if syn_lemmas_set:
199
  synsets_list.append(_CwnSynset(list(syn_lemmas_set), synset_id))
200
  #print(f"DEBUG: Found {len(synsets_list)} synsets for '{word}': {synsets_list[0]._lemmas if synsets_list else []}")
201
+ return synsets_list[:1]
202
 
203
  # Use class for proper method binding
204
  class ChineseWordNet:
chinesemeteor.py CHANGED
@@ -28,6 +28,12 @@ import re
28
  # suppress WordNet warnings
29
  import warnings
30
  warnings.filterwarnings("ignore")
 
 
 
 
 
 
31
 
32
  # Download once
33
  nltk.download("wordnet", quiet=True)
@@ -192,7 +198,7 @@ class ChineseMETEOR(evaluate.Metric):
192
  if syn_lemmas_set:
193
  synsets_list.append(_CwnSynset(list(syn_lemmas_set), synset_id))
194
  #print(f"DEBUG: Found {len(synsets_list)} synsets for '{word}': {synsets_list[0]._lemmas if synsets_list else []}")
195
- return synsets_list
196
 
197
  # Use class for proper method binding
198
  class ChineseWordNet:
 
28
  # suppress WordNet warnings
29
  import warnings
30
  warnings.filterwarnings("ignore")
31
+ warnings.filterwarnings(
32
+ "ignore",
33
+ message="more than one synset, returning the first",
34
+ category=UserWarning,
35
+ module="nltk.translate.meteor_score"
36
+ )
37
 
38
  # Download once
39
  nltk.download("wordnet", quiet=True)
 
198
  if syn_lemmas_set:
199
  synsets_list.append(_CwnSynset(list(syn_lemmas_set), synset_id))
200
  #print(f"DEBUG: Found {len(synsets_list)} synsets for '{word}': {synsets_list[0]._lemmas if synsets_list else []}")
201
+ return synsets_list[:1]
202
 
203
  # Use class for proper method binding
204
  class ChineseWordNet: