Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/consistency-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
python-version: ['3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -27,6 +27,7 @@ jobs:
python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
(cd src/mathics3 && bash ./admin-tools/make-JSON-tables.sh)
# python -m pip install Mathics3[full]
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
- name: Install Pymathics.natlang
run: |
make develop
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/osx.yml-needs-enchant-fixup
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ on:
jobs:
build:
env:
LDFLAGS: "-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -lunwind"
CPPFLAGS; "-I/opt/homebrew/opt/llvm/include"
LDFLAGS: "-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/llvm/lib/unwind -lunwind"
CPPFLAGS: "-I/opt/homebrew/opt/llvm/include"
runs-on: macos-latest
strategy:
matrix:
os: [macOS]
python-version: ['3.9']
python-version: ['3.13']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install OS dependencies
- name: Install dependencies
run: |
brew install llvm tesseract enchant mysql
brew update
brew install llvm lld tesseract enchant mysql
python -m pip install --upgrade pip
pip install pytest pyenchant
PYENCHANT_VERBOSE_FIND=1 python -c 'import enchant'

# Can comment out when next Mathics core and Mathics-scanner are released
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
# Can remove after next Mathics-core release
python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
(cd src/mathics3 && bash ./admin-tools/make-op-tables.sh)
# python -m pip install Mathics3[full]
- name: Install pymathics.natlang
# Go over and comment out stuff when next Mathics core and Mathics-scanner are released
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
git clone https://github.com/Mathics3/mathics-core
(cd mathics-core && pip3 install -e .[full])
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
python -m pip install -e .
- name: Install Mathics3 natlang Module
run: |
make develop
- name: Test natlang
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pymathics.natlang (ubuntu)
name: pymathics.natlang (Ubuntu)

on:
push:
Expand All @@ -11,8 +11,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# python-version: ['3.9', '3.10'] # Figure out what's wrong here.
python-version: ['3.9', '3.10', '3.11']
# 3.9 works but it takes a long time to gather dependencies
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -21,18 +21,18 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
# python -m pip install --upgrade pip
python -m pip install --upgrade pip
python -m pip install pytest
# Can comment out when next Mathics3 core and Mathics-scanner are released
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
# python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
# git clone https://github.com/Mathics3/mathics-core
# (cd mathics-core && pip3 install -e .[full])
# (cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
python -m pip install Mathics3[full]
- name: install pymathics natlang
# Go over and comment out stuff when next Mathics core and Mathics-scanner are released
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
git clone https://github.com/Mathics3/mathics-core
(cd mathics-core && pip3 install -e .[full])
(cd mathics-core && bash ./admin-tools/make-JSON-tables.sh)
python -m pip install -e git+https://github.com/Mathics3/Mathics3-Module-Base#egg=Mathics3-Module-Base
python -m pip install -e .
- name: Install Mathics3 natlang Module
run: |
make develop
- name: Test natlang
- name: Test natlang Mathics3 Module
run: |
make -j3 check
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/ChangeLog-spell-corrected
/ChangeLog.orig
/ChangeLog.rej
/ChangeLog.spell-corrected
/Mathics3_natlang.egg-info
/build
/dist
/pymathics_natlang.egg-info
Expand Down
2 changes: 1 addition & 1 deletion pymathics/natlang/nltk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from itertools import chain

import nltk
from pattern.en import lexeme, pluralize
from pattern.text.en import lexeme, pluralize

from mathics.builtin.codetables import iso639_3
from mathics.core.atoms import String
Expand Down
74 changes: 74 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[build-system]
requires = [
"setuptools",
"sympy>=1.11,<1.13",
"PatternLite",
"langid", # replace with a supported newer package, e.g. via spacy
"matplotlib",
"mpmath>=1.2.0",
"numpy",
"pycountry>=3.2.0",
"pyenchant>=3.2.0",
"scipy>=1.10.0",
"spacy>=3.4",
"wasabi<1.1.0,>=0.8.2",
]
build-backend = "setuptools.build_meta"

[project]
name = "Mathics3-natlang"
description = "Mathics3 Natural Language Toolkit module"
dependencies = [
"Mathics3>=8.0.1",
"Mathics3-Module-Base",
"click>=8.0",
"joblib>=1.0.1",
"langid", # replace with a supported newer package, e.g. via spacy
"llvmlite>=0.36",
"nltk>=3.8.0",
"PatternLite",
"pyenchant>=3.2.0",
"pycountry>=3.2.0",
"spacy>=3.4",
"wasabi<1.1.0,>=0.8.2",
]
requires-python = ">=3.10"
readme = "README.rst"
license = {text = "GPL"}
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
maintainers = [
{name = "Mathics Group", email = "mathics-devel@googlegroups.com"},
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Software Development :: Interpreters",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Mathics3/pymathics-natlang"
Downloads = "https://github.com/Mathics3/pymathics-natlang/releases"

[project.optional-dependencies]
dev = [
"pytest",
]

[tool.setuptools]
packages = [
"pymathics.natlang",
]

[tool.setuptools.dynamic]
version = {attr = "pymathics.natlang.__version__"}
93 changes: 15 additions & 78 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import os.path as osp
import platform
import sys

from setuptools import find_namespace_packages, setup

# Ensure user has the correct Python version
if sys.version_info < (3, 8):
print("Mathics support Python 3.8 and above; you have %d.%d" % sys.version_info[:2])
sys.exit(-1)


def get_srcdir():
filename = osp.normcase(osp.dirname(osp.abspath(__file__)))
return osp.realpath(filename)


def read(*rnames):
return open(osp.join(get_srcdir(), *rnames)).read()


# Get/set VERSION and long_description from files
long_description = read("README.rst") + "\n"

__version__ = "0.0.0" # overwritten by exec below

# stores __version__ in the current namespace
exec(compile(open("pymathics/natlang/version.py").read(), "version.py", "exec"))

is_PyPy = platform.python_implementation() == "PyPy"

# Install a wordlist.
# Environment variables "lang", "WORDLIST_SIZE", and "SPACY_DOWNLOAD" override defaults.
from setuptools import setup
from setuptools.command.egg_info import egg_info

# Full package name with two-letter language code, e.g. fr, zh
lang = os.environ.get("lang", "en_core_web_md")
Expand All @@ -43,56 +13,23 @@ def read(*rnames):
# sm=small, lg=large, md=medium.
WORDLIST_SIZE = os.environ.get("WORDLIST_SIZE", "md")

SPACY_DOWNLOAD = os.environ.get("SPACY_DOWNLOAD", "%s" % (lang,))
SPACY_DOWNLOAD = os.environ.get("SPACY_DOWNLOAD", lang)


class CustomCommands(egg_info):
"""This runs as part of building an sdist"""

def finalize_options(self):
"""Run program to create JSON tables"""
os.system(f"{sys.executable} -m spacy download {lang}")
os.system(f"{sys.executable} -m nltk.downloader 'wordnet2022 omw")
super().finalize_options()


# FIXME:
# consider using langid3 and pyenchant

setup(
name="pymathics-natlang",
version=__version__,
packages=find_namespace_packages(include=["pymathics.*"]),
install_requires=[
"Mathics3>=8.0.0",
"click>=8.0",
"joblib>=1.0.1",
"langid", # replace with a supported newer package, e.g. via spacy
"llvmlite>=0.36",
"nltk>=3.8.0",
"PatternLite",
"pyenchant>=3.2.0",
"pycountry>=3.2.0",
"spacy>=3.4",
"wasabi<1.1.0,>=0.8.2",
],
cmdclass={"egg_info": CustomCommands},
zip_safe=False,
maintainer="Mathics3 Group",
maintainer_email="rb@dustyfeet.com",
long_description=long_description,
long_description_content_type="text/x-rst",
# metadata for upload to PyPI
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"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",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Interpreters",
"Topic :: Scientific/Engineering :: Human Machine Interfaces",
"Topic :: Text Processing",
"Topic :: Text Processing :: Linguistic",
],
# TODO: could also include long_description, download_url,
)

os.system("%s -m spacy download %s" % (sys.executable, lang))
os.system("%s -m nltk.downloader 'wordnet2022 omw" % sys.executable)