Skip to content

Commit

Permalink
Use PatternLite instead of defunkt pattern...
Browse files Browse the repository at this point in the history
It looks like we get a loss in qualiity too
  • Loading branch information
rocky committed Jan 14, 2025
1 parent 7ff91b7 commit 1adabf6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ all: develop

#: Word-list data. Customize with lang and eventually WORDLIST_SIZE variables
wordlist:
$(PYTHON) -m nltk.downloader wordnet2022 omw-1.4
$(PYTHON) -m nltk.downloader wordnet2022 omw-1.4 popular
$(PYTHON) -m spacy download $(SPACY_DOWNLOAD)

#: build everything needed to install
Expand Down
5 changes: 2 additions & 3 deletions pymathics/natlang/nltk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from itertools import chain

import nltk
from pattern.en import lexeme, pluralize

from mathics.builtin.codetables import iso639_3
from mathics.core.atoms import String
from mathics.core.builtin import Builtin, MessageException
Expand Down Expand Up @@ -304,12 +306,9 @@ def inflected_forms(self, syn, desc):
try:
word, pos, _ = desc
if pos == "Verb":
from pattern.en import lexeme

return [w for w in reversed(lexeme(word)) if w != word]
elif pos == "Noun":
from pattern.en import pluralize

return [pluralize(word)]
elif pos == "Adjective":
from pattern.en import comparative, superlative
Expand Down
2 changes: 1 addition & 1 deletion pymathics/natlang/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TextCases(_SpacyBuiltin):
## >> TextCases[Import["ExampleData/EinsteinSzilLetter.txt"], "Person", 3][[2;;3]]
## = {L. Szilard, Joliot}
>> TextCases["Anne, Peter and Mr Johnes say hello.", "Person", 3][[2;;3]]
>> TextCases["Saul, Peter and Mr Johnes say hello.", "Person", 3][[2;;3]]
= {Peter, Johnes}
"""
Expand Down
6 changes: 3 additions & 3 deletions pymathics/natlang/textual_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ class WordSimilarity(_SpacyBuiltin):
</dl>
>> NumberForm[WordSimilarity["car", "train"], 3]
= 0.439
= 0.169
>> NumberForm[WordSimilarity["car", "hedgehog"], 3]
= 0.195
= 0.0173
>> NumberForm[WordSimilarity[{"An ocean full of water.", {2, 2}}, { "A desert full of sand.", {2, 5}}], 3]
= {0.505, 0.481}
= {0.127, 0.256}
"""

messages = merge_dictionaries(
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ def read(*rnames):
"langid", # replace with a supported newer package, e.g. via spacy
"llvmlite>=0.36",
"nltk>=3.8.0",
"pattern",
"PatternLite",
"pyenchant>=3.2.0",
"pycountry>=3.2.0",
"spacy>=3.4",
"textblob",
"wasabi<1.1.0,>=0.8.2",
],
zip_safe=False,
Expand All @@ -76,11 +77,11 @@ def read(*rnames):
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
Expand Down
3 changes: 3 additions & 0 deletions test/consistency-and-style/test_summary_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import pytest

from types import ModuleType
from typing import Dict

from mathics.core.load_builtin import name_is_builtin_symbol
from mathics.core.builtin import Builtin
from mathics.doc.gather import skip_doc
Expand Down
3 changes: 2 additions & 1 deletion test/helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import time
from typing import Optional

from mathics.session import MathicsSession, import_and_load_builtins
from mathics.core.load_builtin import import_and_load_builtins
from mathics.session import MathicsSession

import_and_load_builtins()

Expand Down

0 comments on commit 1adabf6

Please sign in to comment.