pylfg

PyLFG is a Python library for working within the Lexical Functional Grammar (LFG) formalism. It provides a set of classes and methods for representing and manipulating LFG structures, including f-structures and c-structures.

https://github.com/ars-linguistica/pylfg

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.5%) to scientific vocabulary

Keywords

grammar grammar-parser lexical-functional-grammar python syntax-analysis
Last synced: 6 months ago · JSON representation ·

Repository

PyLFG is a Python library for working within the Lexical Functional Grammar (LFG) formalism. It provides a set of classes and methods for representing and manipulating LFG structures, including f-structures and c-structures.

Basic Info
  • Host: GitHub
  • Owner: Ars-Linguistica
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 668 KB
Statistics
  • Stars: 9
  • Watchers: 2
  • Forks: 3
  • Open Issues: 0
  • Releases: 1
Topics
grammar grammar-parser lexical-functional-grammar python syntax-analysis
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme Changelog Contributing Funding License Citation Authors

README.rst

PyLFG - A Python package for parsing sentences using Lexical Functional Grammar (LFG)
=====================================================================================

.. image:: https://zenodo.org/badge/586289901.svg
   :target: https://zenodo.org/badge/latestdoi/586289901

Introduction
------------

PyLFG (Python Library for Lexical Functional Grammar) is a new
open-source project that aims to provide a comprehensive set of tools
for working within the Lexical Functional Grammar (LFG) formalism, developed by ARS Linguistica.
LFG is a syntactic theory that represents the structure of natural language
using a combination of lexical and functional information. This project
provides a set of classes and methods for representing and manipulating
LFG structures, including lexical functional structures (f-structures)
and c-structures.

PyLFG’s primary goal is to make LFG research more accessible to a wider
community by providing a fully modular library that allows researchers
to easily try new ideas and improve existing ones. The library will not
only parse sentences but also generate sentences from f-structures, and
it will have transfer capabilities to do automated translation.

PyLFG is also designed to be user-friendly, providing both a TUI
(Terminal User Interface) and a WebUI for easy interaction. The library
being written in Python makes it perfectly suited for linguistics
students who are taught Python in university.

The lack of open-source LFG parsers is a significant problem in the
field of linguistics research. Many academically developed LFG parsers
have been abandoned by their authors, making them inaccessible to the
wider community. This is a major obstacle for researchers who are
interested in studying LFG, as they are often forced to rely on
proprietary software that is difficult to access and modify.

The open-source nature of PyLFG is crucial in addressing this problem.
By providing an open-source LFG parser, PyLFG aims to make LFG research
more accessible to a wider community, allowing researchers to easily try
new ideas and improve existing ones. The ability to view and modify the
source code of the library also allows for greater transparency and
reproducibility in research, which is essential for the advancement of
knowledge.

Moreover, PyLFG’s open-source nature allows for collaboration and
contributions from the wider community. This can lead to the development
of new features and improvements in the library, making it a valuable
tool for linguistics students and professors, language learning
applications, and documenting under-resourced languages.

Open science is the best way of spreading and furthering knowledge, and
PyLFG aims to contribute to this goal by providing a valuable tool that
can be used by researchers and practitioners alike. The open-source
nature of PyLFG will ensure that it is accessible to anyone who is
interested in studying LFG, making it an essential tool for advancing
knowledge in the field of linguistics.

Important note
~~~~~~~~~~~~~~

PyLFG is still in early development and has not yet reached a stable
release state.

Features
--------

PyLFG is designed to be a comprehensive tool for working within the
Lexical Functional Grammar (LFG) formalism, providing a range of
features that make it a valuable tool for researchers and practitioners
alike.

-  Modularity: PyLFG is fully modular, allowing researchers to easily
   replace all parts of the LFG parsing pipeline, from tokenizing
   sentences to the rich visualizations of the x-structures. This allows
   for flexibility in trying new ideas and improving existing ones,
   making it a valuable tool for advancing knowledge in the field of
   linguistics.
-  Parsing and generation: PyLFG is not only able to parse sentences but
   also generate sentences from f-structures, which is an essential
   capability for automated translation and language learning
   applications.
-  Transfer capabilities: PyLFG has transfer capabilities which allow it
   to do automated translation between languages, making it a useful
   tool for researchers and practitioners working on natural language
   processing.
-  User-friendly interface: PyLFG provides both a TUI (Terminal User
   Interface) and a WebUI for easy interaction, making it accessible to
   a wide range of users, including students and professors who are
   taught Python in university.
-  Open-source: PyLFG is an open-source project, meaning that the source
   code is freely available for anyone to view and modify. This allows
   for greater transparency and reproducibility in research, and also
   enables collaboration and contributions from the wider community.
-  Suitable for linguistics students and professors: PyLFG is written in
   Python, which is a widely used programming language in the field of
   linguistics research. This makes it perfectly suited for linguistics
   students and professors, as well as python programmers in general.
-  Valuable tool for documenting under-resourced languages: PyLFG
   provides a valuable tool for documenting under-resourced languages,
   which is essential for preserving and studying these languages.

In summary, PyLFG is a comprehensive and user-friendly open-source tool
that provides a range of features that make it valuable for linguistics
students and professors, language learning applications, and documenting
under-resourced languages.

Use Cases
---------

PyLFG can be used in a variety of applications, making it a valuable
tool for researchers and practitioners working in a range of fields.
Some of the key use cases include:

-  Linguistics research: PyLFG is a valuable tool for linguistics
   students and professors who study syntactic theories. It can be used
   to parse sentences and generate f-structures, which can be used to
   test hypotheses and advance knowledge in the field.
-  Language learning applications: PyLFG’s ability to generate sentences
   from f-structures makes it a useful tool for language learning
   applications. It can be used to generate grammatically correct
   sentences for language learners to practice, and its transfer
   capabilities can also be used to translate between languages.
-  Documenting under-resourced languages: PyLFG’s ability to parse and
   generate sentences makes it a valuable tool for documenting
   under-resourced languages. It can be used to create grammatically
   correct sentences for use in language dictionaries and phrasebooks,
   and its transfer capabilities can also be used to translate between
   languages.
-  Natural language processing: PyLFG’s transfer capabilities and
   ability to generate sentences from f-structures make it a valuable
   tool for researchers and practitioners working on natural language
   processing. It can be used to automate the translation of sentences
   between languages, which has a wide range of applications, such as
   machine translation and language-based search engines.
-  Language-based search engines: PyLFG can be used to generate
   f-structures, which can be used to create grammatically correct
   sentences for use in language-based search engines. This makes it a
   valuable tool for researchers and practitioners working in this
   field.

In summary, PyLFG is a versatile tool that can be used in a wide range
of applications, making it a valuable tool for researchers and
practitioners working in linguistics, language learning, natural
language processing, and language-based search engines.

Technical Details
-----------------

PyLFG’s architecture is divided into five main components:

-  Tokenization: PyLFG uses the NLTK library to tokenize sentences. This
   allows users to tokenize sentences in multiple languages, including
   English, Spanish, French, and German.
-  Morphological Analysis: PyLFG uses a morphological analyzer to
   identify the base forms of words and their grammatical properties.
   This is an important step in the LFG parsing process, as it provides
   the necessary information for generating f-structures.
-  Parsing: PyLFG uses a modified version of the C-Structure Earley
   parser to parse sentences and generate f-structures. This parser is
   based on the Earley algorithm, which is a top-down parsing algorithm
   that is well-suited for parsing context-free grammars.
-  C-Structure and F-Structure Construction: PyLFG uses the information
   obtained from tokenization and morphological analysis to construct
   both C-structures and F-structures. These structures represent the
   syntactic and functional properties of sentences, respectively.
-  Visualization: PyLFG uses the Graphviz library to visualize
   f-structures. This allows users to create rich visualizations of
   f-structures, making it easy to understand and analyze the structures
   generated by the parser.

In addition, PyLFG also provides a TUI (Terminal User Interface) and a
WebUI (Web User Interface) which makes it easy for users to interact
with the library, parse sentences and visualize the f-structures

PyLFG is written in Python, which means users of the library can
leverage the wide range of libraries and frameworks available in Python,
such as NLTK and Spacy, which makes it a powerful and flexible tool for
working with LFG structures.

Contributing
------------

PyLFG is an open-source project and we welcome contributions from the
community. There are several ways to contribute, including:

-  Reporting bugs: If you find a bug in PyLFG, please report it on the
   GitHub issue tracker. Be sure to include as much information as
   possible, such as the version of PyLFG you are using, the steps to
   reproduce the bug, and any error messages you received.
-  Suggesting features: If you have an idea for a new feature in PyLFG,
   please suggest it on the GitHub issue tracker. Be sure to include as
   much detail as possible about the feature, including any relevant use
   cases or examples.
-  Writing code: If you would like to contribute code to PyLFG, please
   fork the repository on GitHub and submit a pull request. Be sure to
   follow the existing code style, and include tests and documentation
   for your changes.
-  Documentation: If you find any errors or inconsistencies in the
   documentation, or would like to suggest improvements, please let us
   know on the GitHub issue tracker.
-  Examples: If you have examples of using PyLFG in your research or
   projects, we would love to hear about them and feature them in the
   documentation.

We are looking forward to hearing from you and working together to
improve PyLFG. Thank you for considering to contribute to this project!

Please also note that by contributing to this project, you agree to
abide by our code of conduct.

Conclusion
----------

PyLFG is a powerful open-source Python library for working within the
Lexical Functional Grammar (LFG) formalism. It provides a comprehensive
set of classes and methods for representing and manipulating LFG
structures, including lexical functional structures (f-structures) and
c-structures. With its modular design, PyLFG allows researchers to
easily experiment with new ideas and customize their LFG parsing
pipeline.

By making PyLFG open-source, we aim to contribute to the goal of open
science and the spread and advancement of knowledge in the field of
linguistics.

We invite the community to contribute to the development of PyLFG by
reporting bugs, suggesting new features, writing code, improving
documentation and sharing examples of using PyLFG. We are looking
forward to working together to improve PyLFG and make it an even more
powerful tool for researchers in the field of linguistics.

Usage
-----

The package provides helper functions for loading grammar rules and
lexicon from files, and a ``LFGParseTree`` and ``LFGParseTreeNode``
class for representing and visualizing parse trees. Here is an example
of how to use the package:

.. code:: python

   from pylfg import build_parse_trees


   sentence = "the cat sits on the mat"

   # load grammar and lexicon
   grammar = load_grammar("path/to/grammar.txt")
   lexicon = load_lexicon("path/to/lexicon.txt")

   # parse sentence
   trees = build_parse_trees(sentence, grammar, lexicon)

   # print the first parse tree
   print(trees[0])

You can also use the LFGParseTree.to_f_structure method to export the
f-structure of the sentence in latex format, as shown in this example

.. code:: python

   f_structure = trees[0].to_f_structure()

   # write f-structure to a latex file
   with open("f_structure.tex", "w") as f:
       f.write(f_structure)

Owner

  • Name: ARS Linguistica
  • Login: Ars-Linguistica
  • Kind: organization
  • Location: France

Welcome to ARS Linguistica - Where Linguistics Meets Open Science

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Diao"
  given-names: "Sekou"
  orcid: "https://orcid.org/0000-0002-7874-8073"
title: "PyLFG A Python Lexical Functional Grammar parser"
version: 0.1.1a
doi: 10.5281/zenodo.7581653
date-released: 2023-01-29
url: "https://github.com/Ars-Linguistica/PyLFG"

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 398
  • Total Committers: 1
  • Avg Commits per committer: 398.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Sekou Diao d****p@g****m 398

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 0
  • Total pull requests: 22
  • Average time to close issues: N/A
  • Average time to close pull requests: 7 minutes
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 20
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • SekouDiaoNlp (22)
Top Labels
Issue Labels
Pull Request Labels
documentation (12) enhancement (1)

Dependencies

.github/workflows/OSSF.yml actions
  • actions/checkout 93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 composite
  • actions/upload-artifact 3cea5372237819ed00197afe530f5a7ea3e805c8 composite
  • github/codeql-action/upload-sarif 807578363a7869ca324a79039e6db9c843e0e100 composite
  • ossf/scorecard-action 99c53751e09b9529366343771cc321ec74e9bd3d composite
.github/workflows/poetry.yml actions
  • actions/cache 58c146cc91c5b9e778e71775dfe9bf1442ad9a12 composite
  • actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
  • actions/setup-python d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 composite
  • snok/install-poetry d45b6d76012debf457ab49dffc7fb7b2efe8071d composite
  • step-security/harden-runner 18bf8ad2ca49c14cbb28b91346d626ccfb00c518 composite
.github/workflows/sign_and_deploy.yml actions
  • actions/cache 58c146cc91c5b9e778e71775dfe9bf1442ad9a12 composite
  • actions/checkout ac593985615ec2ede58e132d2e21d2b1cbd6127c composite
  • actions/setup-python d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 composite
  • sigstore/gh-action-sigstore-python 6b203deb6739fa707744be136400b8fccb1a72bd composite
  • snok/install-poetry d45b6d76012debf457ab49dffc7fb7b2efe8071d composite
  • step-security/harden-runner 18bf8ad2ca49c14cbb28b91346d626ccfb00c518 composite
docs/requirements_docs.txt pypi
  • alabaster ==0.7.13
  • anyio ==3.6.2
  • attrs ==22.2.0
  • babel ==2.11.0
  • beautifulsoup4 ==4.11.1
  • bump2version ==1.0.1
  • certifi ==2022.12.7
  • charset-normalizer ==3.0.1
  • click ==8.1.3
  • colorama ==0.4.6
  • contourpy ==1.0.7
  • coverage ==7.1.0
  • cycler ==0.11.0
  • docutils ==0.19
  • fastapi ==0.89.1
  • fonttools ==4.38.0
  • furo ==2022.12.7
  • idna ==3.4
  • imagesize ==1.4.1
  • importlib-metadata ==4.13.0
  • iniconfig ==2.0.0
  • jinja2 ==3.1.2
  • kiwisolver ==1.4.4
  • markdown-it-py ==2.1.0
  • markupsafe ==2.1.2
  • matplotlib ==3.6.3
  • mdurl ==0.1.2
  • mypy ==0.991
  • mypy-extensions ==0.4.3
  • nanoid ==2.0.0
  • networkx ==3.0
  • numpy ==1.24.1
  • packaging ==23.0
  • pillow ==9.4.0
  • pluggy ==1.0.0
  • ply ==3.11
  • plyplus ==0.7.5
  • pydantic ==1.10.4
  • pygments ==2.14.0
  • pyparsing ==3.0.9
  • pytest ==7.2.1
  • pytest-cov ==4.0.0
  • pytest-runner ==6.0.0
  • python-dateutil ==2.8.2
  • pytz ==2022.7.1
  • pyupgrade ==3.3.1
  • requests ==2.28.2
  • rich ==13.3.1
  • six ==1.16.0
  • sniffio ==1.3.0
  • snowballstemmer ==2.2.0
  • soupsieve ==2.3.2.post1
  • sphinx ==6.1.3
  • sphinx-basic-ng ==1.0.0b1
  • sphinxcontrib-applehelp ==1.0.4
  • sphinxcontrib-devhelp ==1.0.2
  • sphinxcontrib-htmlhelp ==2.0.0
  • sphinxcontrib-jsmath ==1.0.1
  • sphinxcontrib-qthelp ==1.0.3
  • sphinxcontrib-serializinghtml ==1.1.5
  • starlette ==0.22.0
  • textual ==0.10.1
  • textual-imageview ==0.1.1
  • tokenize-rt ==5.0.0
  • typing-extensions ==4.4.0
  • urllib3 ==1.26.14
  • zipp ==3.12.0
poetry.lock pypi
  • alabaster 0.7.13 develop
  • attrs 22.2.0 develop
  • babel 2.11.0 develop
  • bandit 1.7.4 develop
  • beautifulsoup4 4.11.1 develop
  • bump2version 1.0.1 develop
  • certifi 2022.12.7 develop
  • charset-normalizer 3.0.1 develop
  • coverage 7.1.0 develop
  • docutils 0.19 develop
  • furo 2022.12.7 develop
  • gitdb 4.0.10 develop
  • gitpython 3.1.30 develop
  • imagesize 1.4.1 develop
  • iniconfig 2.0.0 develop
  • jinja2 3.1.2 develop
  • markupsafe 2.1.2 develop
  • mypy 0.991 develop
  • mypy-extensions 0.4.3 develop
  • pbr 5.11.1 develop
  • pluggy 1.0.0 develop
  • pytest 7.2.1 develop
  • pytest-cov 4.0.0 develop
  • pytest-runner 6.0.0 develop
  • pytz 2022.7.1 develop
  • pyupgrade 3.3.1 develop
  • pyyaml 6.0 develop
  • requests 2.28.2 develop
  • smmap 5.0.0 develop
  • snowballstemmer 2.2.0 develop
  • soupsieve 2.3.2.post1 develop
  • sphinx 6.1.3 develop
  • sphinx-basic-ng 1.0.0b1 develop
  • sphinxcontrib-applehelp 1.0.4 develop
  • sphinxcontrib-devhelp 1.0.2 develop
  • sphinxcontrib-htmlhelp 2.0.0 develop
  • sphinxcontrib-jsmath 1.0.1 develop
  • sphinxcontrib-qthelp 1.0.3 develop
  • sphinxcontrib-serializinghtml 1.1.5 develop
  • stevedore 4.1.1 develop
  • tokenize-rt 5.0.0 develop
  • urllib3 1.26.14 develop
  • anyio 3.6.2
  • click 8.1.3
  • colorama 0.4.6
  • contourpy 1.0.7
  • cycler 0.11.0
  • fastapi 0.89.1
  • fonttools 4.38.0
  • idna 3.4
  • importlib-metadata 4.13.0
  • kiwisolver 1.4.4
  • markdown-it-py 2.1.0
  • matplotlib 3.6.3
  • mdurl 0.1.2
  • nanoid 2.0.0
  • networkx 3.0
  • numpy 1.24.1
  • packaging 23.0
  • pillow 9.4.0
  • ply 3.11
  • plyplus 0.7.5
  • pydantic 1.10.4
  • pygments 2.14.0
  • pyparsing 3.0.9
  • python-dateutil 2.8.2
  • rich 13.3.1
  • six 1.16.0
  • sniffio 1.3.0
  • starlette 0.22.0
  • textual 0.10.1
  • textual-imageview 0.1.1
  • typing-extensions 4.4.0
  • zipp 3.12.0
pyproject.toml pypi
  • PlyPlus ^0.7.5
  • click ^8.1.3
  • fastapi ^0.89.1
  • matplotlib ^3.6.3
  • networkx ^3.0
  • python ^3.11
  • rich ^13.3.1
  • textual ^0.10.1
  • textual-imageview ^0.1.1
requirements_doc.txt pypi
  • alabaster ==0.7.13
  • antlr4-python3-runtime ==4.9.3
  • asq ==1.3
  • attrs ==22.2.0
  • babel ==2.11.0
  • bandit ==1.7.4
  • beautifulsoup4 ==4.11.1
  • bleach ==6.0.0
  • bump2version ==1.0.1
  • cachetools ==5.3.0
  • certifi ==2022.12.7
  • cffi ==1.15.1
  • chardet ==5.1.0
  • charset-normalizer ==3.0.1
  • click ==8.1.3
  • codecov ==2.1.12
  • colorama ==0.4.6
  • coverage ==7.0.5
  • cryptography ==39.0.0
  • cython ==0.29.33
  • defusedxml ==0.7.1
  • distlib ==0.3.6
  • docutils ==0.19
  • exceptiongroup ==1.1.0
  • filelock ==3.9.0
  • furo ==2022.12.7
  • gitdb ==4.0.10
  • gitpython ==3.1.30
  • hydra-core ==1.3.1
  • idna ==3.4
  • imagesize ==1.4.1
  • importlib-metadata ==6.0.0
  • importlib-resources ==5.10.2
  • iniconfig ==2.0.0
  • jaraco-classes ==3.2.3
  • jeepney ==0.8.0
  • jinja2 ==3.1.2
  • joblib ==1.2.0
  • keyring ==23.13.1
  • markdown-it-py ==2.1.0
  • markupsafe ==2.1.2
  • mdurl ==0.1.2
  • more-itertools ==9.0.0
  • mypy ==0.991
  • mypy-extensions ==0.4.3
  • numpy ==1.24.1
  • omegaconf ==2.3.0
  • packaging ==23.0
  • pathlib2 ==2.3.7.post1
  • pbr ==5.11.1
  • pkginfo ==1.9.6
  • platformdirs ==2.6.2
  • pluggy ==1.0.0
  • pycparser ==2.21
  • pygments ==2.14.0
  • pyproject-api ==1.5.0
  • pytest ==7.2.1
  • pytest-cov ==3.0.0
  • pytest-runner ==6.0.0
  • pytz ==2022.7.1
  • pywin32-ctypes ==0.2.0
  • pyyaml ==6.0
  • readme-renderer ==37.3
  • requests ==2.28.2
  • requests-toolbelt ==0.10.1
  • rfc3986 ==2.0.0
  • rich ==13.2.0
  • scikit-learn ==1.2.0
  • scipy ==1.10.0
  • secretstorage ==3.3.3
  • six ==1.16.0
  • smmap ==5.0.0
  • snowballstemmer ==2.2.0
  • soupsieve ==2.3.2.post1
  • sphinx ==6.1.3
  • sphinx-basic-ng ==1.0.0b1
  • sphinxcontrib-applehelp ==1.0.4
  • sphinxcontrib-devhelp ==1.0.2
  • sphinxcontrib-htmlhelp ==2.0.0
  • sphinxcontrib-jsmath ==1.0.1
  • sphinxcontrib-qthelp ==1.0.3
  • sphinxcontrib-serializinghtml ==1.1.5
  • stevedore ==4.1.1
  • threadpoolctl ==3.1.0
  • tomli ==2.0.1
  • tox ==4.3.5
  • twine ==4.0.2
  • typing-extensions ==4.4.0
  • urllib3 ==1.26.14
  • virtualenv ==20.17.1
  • webencodings ==0.5.1
  • zipp ==3.11.0