Metadata-Version: 2.4
Name: pyfoma
Version: 1.1.0
Summary: Python Finite-State Toolkit
Project-URL: Bug Tracker, https://github.com/mhulden/pyfoma/issues
Project-URL: Homepage, https://github.com/mhulden/pyfoma
Author-email: Mans Hulden <mans.hulden@colorado.edu>
License-File: LICENSE
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Requires-Dist: graphviz
Requires-Dist: ipython
Requires-Dist: tqdm
Description-Content-Type: text/markdown

<p align="center">
  <img src="docs/pyfoma-logo.png" width="200">
</p>

[![PyPI version](https://badge.fury.io/py/pyfoma.svg)](https://badge.fury.io/py/pyfoma)

## Quickstart

```bash
pip install pyfoma
```

```python
from pyfoma import FST
myfst = FST.re("(cl|n|s)?e(ve|a)r")
myfst.view()
```

<img src="./docs/examples/images/quickstart1.png" width="722">

### What's new
* Mar 2026: added [SKILL.md](./skills/pyfoma-morphology) for creating morphological analyzers
* Mar 2026: added support for [parsing](./src/pyfoma/cfg_parse.py) and [approximation](./src/pyfoma/cfg_approx.py) of CFGs
* Feb 2026: [pyfoma.js port](https://github.com/fomafst/fomafst.github.io/blob/master/pyfomajs/pyfoma.js) allows [PyFoma regex compilation, visualization, and testing in the browser](https://fomafst.github.io/pyfomajs/)
* Feb 2026: added support for [lexd](./src/pyfoma/lexd.py)

### Core documentation

* [Regular Expression Compiler](./docs/examples/RegularExpressionCompiler.ipynb)
* [Introduction to lexd](./docs/examples/lexd-intro.ipynb)
* [Morphological Analyzer Tutorial](./docs/examples/MorphologicalAnalyzerTutorial.ipynb)
* [CFG Parsing](./docs/examples/CFG%20Parsing.ipynb)
* [CFG Approximation](./docs/examples/CFG%20Approximation.ipynb)

## Contributing

<!-- TODO: Include details on how to open PRs -->
```bash
pip install -e .

# Build Cython modules
python setup.py build_ext --inplace
```

### Rebuilding the documentation

```bash
brew install sphinx-doc # if not installed

# Update automatically-scraped docs
sphinx-apidoc -o docs src/pyfoma/

# Rebuild docs
cd docs
make html
```

## Citation

```
@inproceedings{hulden-etal-2024-pyfoma,
    title = "{P}y{F}oma: a Python finite-state compiler module",
    author = "Hulden, Mans and Ginn, Michael and Silfverberg, Miikka and Hammond, Michael",
    editor = "Cao, Yixin and Feng, Yang and Xiong, Deyi",
    booktitle = "Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)",
    year = "2024",
    address = "Bangkok, Thailand",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2024.acl-demos.24",
    doi = "10.18653/v1/2024.acl-demos.24",
    pages = "258--265"
}
```
