Skip to main content

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.

Release files for Mathics3-Module-nltk 10.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Mathics3-Module-nltk 10.0.0
File Size Uploaded
mathics3_module_nltk-10.0.0.tar.gz 42.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Mathics3-Module-nltk 10.0.0
File Interpreter ABI Platform
mathics3_module_nltk-10.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 77.0 kB

Release files / mathics3_module_nltk-10.0.0.tar.gz

Download URL mathics3_module_nltk-10.0.0.tar.gz
Size 42.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c9813e29ce7c388297017546b2fc9e729c256759484b1b539488b6300df4750
BLAKE2b-256 checksum
How to use checksums
7241e349b27fec34e3e495480c2dfeb9dc11db108ceb1f6f52e4a36be01f5185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / mathics3_module_nltk-10.0.0-py3-none-any.whl

Download URL mathics3_module_nltk-10.0.0-py3-none-any.whl
Size 34.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e6430a31bfec217d99968bb6675a0cbbca44a0bcb44da0ae205c8faced56a4d
BLAKE2b-256 checksum
How to use checksums
145e9e1b9a44b5ff162cea785db04ffb087b70696d1e8d80812cad7189edae96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

10.0.0 This release

2 release files

9.0.2

2 release files

9.0.1

2 release files

9.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page