Skip to main content

A Python port of Fluid Construction Grammar

Project description

PyFCG

A Python interface to FCG and Babel, built on FCG Go.

Installation

The Python integration of FCG (aka PyFCG) is distributed as a pip-installable package. To install this package from PyPI, run the following command.

$ pip install pyfcg

Use

Once pip-installed, PyFCG can readily be imported as a module into Python programs. It is customary to define fcg as an alias for the PyFCG module, so that all functionality is available within the fcg namespace (functions and variables are thereby prefixed with fcg.)

You initialise PyFCG as follows:

>>> import pyfcg as fcg
>>> fcg.init()

Many FCG functions depend on the fcg-go precompiled binary, which you loaded (or download if necessary) by calling the init() function. On macOS, you will need to accept opening the application bundle by clicking "open" in the popup window.

Example: Creating an FCG Agent

The Agent class will usually be your main entry point. The idea is that an agent has a grammar (of type Grammar), which in turn holds constructions (of type Construction). In PyFCG, a grammar will always be tied to an agent. Upon creation, an agent is automatically initialised with an empty grammar, i.e. a grammar that holds zero constructions.

>>> demo_agent = fcg.Agent()

>>> demo_agent
<Agent: agent (id: agent-42) ~ 0 constructions>

>>> demo_agent.grammar.size()
0

Walkthrough Tutorials

A more in-depth showcase of PyFCG's functionalities can be found in the following interactive notebooks. Each of them walks you through the process of integrating PyFCG in a typical use case of FCG.

Documentation

The tecnical documentation of PyFCG is available at Read the Docs.

How to Cite

Temporarily anonymised for reviewing purposes (but ArXiv's your friend).

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

pyfcg-3.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

pyfcg-3.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfcg-3.1.tar.gz.

File metadata

  • Download URL: pyfcg-3.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyfcg-3.1.tar.gz
Algorithm Hash digest
SHA256 a3150f81ac2abc7bf0b0a199701c8b1f0c64e8b6aefe569f666a341f45f61e85
MD5 96b9da3e93aa20d5f83d40c073dc8ac6
BLAKE2b-256 dd925ad33517109036f209d8cd39372dd6c8cea9ae6a9d7ec82879d22a5f972a

See more details on using hashes here.

File details

Details for the file pyfcg-3.1-py3-none-any.whl.

File metadata

  • Download URL: pyfcg-3.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyfcg-3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02ce5b9196ee77d96a4626255b161b91f19ff9771039758e4106a0c1a25ca99c
MD5 b5f228366102062f57582f43a8e035a9
BLAKE2b-256 97a9ce468c4b881c6fd987d529ffc6e796b4204a04fd5953566367034ec0118d

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