Skip to main content

Mathics3 Natural Language Toolkit module

Project description

Pypi Installs Latest Version Supported Python Versions

Mathics3 Natural Language Toolkit module.

Example Session

$ mathicsscript
In[1]:= LoadModule["pymathics.natlang"]
Out[1]= pymathics.natlang
In[2]= Pluralize["try"]
Out[2]= tries
In[3]= WordFrequency["Apple Tree and apple", "apple", IgnoreCase -> True]
Out[3]= 0.5
In[4] = TextCases["I was in London last year.", "Pronoun"]
Out[4]= {I}
In[5] = Synonyms["forget"]
Out[5]= {blank out, block, bury, draw a blank, leave}
In[6] = Antonyms["big"]
Out[6]= {little, small}
In[7] = LanguageIdentify["eins zwei drei"]
Out[7]= "German"

Other examples can be found in the test file.

Installing and Running

To build this Mathics3 module, you will need to install the Python module nltk and spacy, and then install some data from Language-specific words:

$ make develop  # or make install

The above make command defaults to the English. If you would like to install for another language, set the variable LANG. For example:

$ make develop LANG=fr

To use the Extended Open Multilingual Wordnet with NLTK and use even more languages, you need to install them manually. Go to http://compling.hss.ntu.edu.sg/omw/summx.html, download the data, and then create a new folder under $HOME/nltk_data/corpora/omw/your_language where you put the file from wiki/wn-wikt-your_language.tab, and rename it to wn-data-your_language.tab.

If you get the message:

OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

There is a problem with the spacy library for advanced Natural Language Processing in Python.

You might be able to fix this by running:

python -m spacy download en

Adjust “python” and “en” (the language you want) above as needed.

User customization

To use the Extended Open Multilingual Wordnet (OMW) with ‘NLTK’ and use even more languages, you need to install them manually.

Go to http://compling.hss.ntu.edu.sg/omw/summx.html, download the data, and then create a new folder under $HOME/nltk_data/corpora/omw/your_language where you put the file from wiki/wn-wikt-your_language.tab, and rename it to wn-data-your_language.tab.

Adding more languages to Open Multilingual Wordnet:

To use the Extended Open Multilingual Wordnet with NLTK and use even more languages, you need to install them manually. Go to http://compling.hss.ntu.edu.sg/omw/summx.html, download the data, and then create a new folder under $HOME/nltk_data/corpora/omw/your_language where you put the file from wiki/wn-wikt-your_language.tab, and rename it to wn-data-your_language.tab.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mathics3_module_nltk-10.0.0.tar.gz (42.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mathics3_module_nltk-10.0.0-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file mathics3_module_nltk-10.0.0.tar.gz.

File metadata

  • Download URL: mathics3_module_nltk-10.0.0.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for mathics3_module_nltk-10.0.0.tar.gz
Algorithm Hash digest
SHA256 0c9813e29ce7c388297017546b2fc9e729c256759484b1b539488b6300df4750
MD5 b4f12b6402f414b26570621fc06acf73
BLAKE2b-256 7241e349b27fec34e3e495480c2dfeb9dc11db108ceb1f6f52e4a36be01f5185

See more details on using hashes here.

File details

Details for the file mathics3_module_nltk-10.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mathics3_module_nltk-10.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e6430a31bfec217d99968bb6675a0cbbca44a0bcb44da0ae205c8faced56a4d
MD5 939d8ce0222240f391cabe559206aba2
BLAKE2b-256 145e9e1b9a44b5ff162cea785db04ffb087b70696d1e8d80812cad7189edae96

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page