@@ -450,8 +450,13 @@ class WordFrequency(_SpacyBuiltin):
450450
451451 $word$ may also specify multiple words using $a$ | $b$ | ...
452452
453- >> WordFrequency[Import["ExampleData/EinsteinSzilLetter.txt"], "a" | "the"]
454- = 0.0665635
453+ ## Problem with import for certain characters in the text.
454+ ## >> text = Import["ExampleData/EinsteinSzilLetter.txt"];
455+ >> text = "I have a dairy cow, it's not just any cow. \
456+ She gives me milkshake, oh what a salty cow. She is the best\
457+ cow in the county.";
458+ >> WordFrequency[text, "a" | "the"]
459+ = 0.114286
455460
456461 >> WordFrequency["Apple Tree", "apple", IgnoreCase -> True]
457462 = 0.5
@@ -473,6 +478,7 @@ def eval(self, text: String, word, evaluation: Evaluation, options: dict):
473478 words = set (a .value for a in word .elements )
474479 else :
475480 return # error
481+
476482 ignore_case = self .get_option (options , "IgnoreCase" , evaluation ) is SymbolTrue
477483 if ignore_case :
478484 words = [w .lower () for w in words ]
@@ -565,8 +571,12 @@ class TextCases(_SpacyBuiltin):
565571 >> TextCases["I was in London last year.", "City"]
566572 = {London}
567573
568- >> TextCases[Import["ExampleData/EinsteinSzilLetter.txt"], "Person", 3][[2;;3]]
569- = {L. Szilard, Joliot}
574+ ## >> TextCases[Import["ExampleData/EinsteinSzilLetter.txt"], "Person", 3][[2;;3]]
575+ ## = {L. Szilard, Joliot}
576+
577+ >> TextCases["Anne, Peter and Mr Johnes say hello.", "Person", 3][[2;;3]]
578+ = {Peter, Johnes}
579+
570580 """
571581
572582 def eval_string_form (
@@ -833,10 +843,10 @@ def _language_name(self, evaluation: Evaluation, options: dict):
833843
834844 def _init_wordnet (self , evaluation : Evaluation , language_name , language_code ):
835845 try :
836- wordnet_resource = nltk .data .find ("corpora/wordnet " )
846+ wordnet_resource = nltk .data .find ("corpora/wordnet2022 " )
837847 _init_nltk_maps ()
838848 except LookupError :
839- evaluation .message (self .get_name (), "package" , "wordnet " )
849+ evaluation .message (self .get_name (), "package" , "wordnet2022 " )
840850 return None
841851
842852 try :
0 commit comments