Skip to main content

Distributed Morphology calculator

Project description

Latest PyPI Version License Supported Python Versions Wheel format

Build Codecov

DM-engine is a Python implementation of Distributed Morphology (DM).

Distributed Morphology is a framework from theoretical linguistics that is used to describe the morphology (word structure) of natural languages. This package provides an engine that calculates the word forms that are generated by a given DM analysis.

Analyses are entered as plain-text files in the human-friendly YAML format. Minimally, they consist of a title, an inventory of feature values, a list of insertable vocabulary items (VIs), and a list of inputs to be processed (see the example below). The dmengine command-line tool calculates the results and generates a detailed transcript of all calculations for later inspection. The resulting YAML file can be converted into a LaTeX-based report that can directly be compiled into a PDF file.

Installation

This package runs under Python 3.6+, use pip to install:

$ pip install dmengine

This will also install the PyYAML and oset packages from PyPI as required dependencies.

Converting the results to a PDF report also requires a LaTeX distribution (TeX Live and MikTeX should work). Make sure its executables are on your systems’ path.

Usage

Create a plain text file that defines your analysis:

# example.yaml - simple demonstration of the analysis definition syntax
title: English verbal agreement
features:
- value: V
  category: pos
- value: Nom
  category: case
- value: +1
  category: person
- value: +2
  category: person
- value: +3
  category: person
- value: -pl
  category: number
- value: +pl
  category: number
vis:
- exponent: sleep
  features: [ V ]
- exponent: -s
  features: [ Nom, +3, -pl ]
- exponent: 
  features: [ Nom ]
paradigms:
- name: Intransitive paradigm
  headers: [ [1, 2, 3], [sg, pl] ]
  inputs:
  - [ [V], [Nom, +1, -pl] ]
  - [ [V], [Nom, +1, +pl] ]
  - [ [V], [Nom, +2, -pl] ]
  - [ [V], [Nom, +2, +pl] ]
  - [ [V], [Nom, +3, -pl] ]
  - [ [V], [Nom, +3, +pl] ]

Save your analysis definition to a file ending with .yaml (e.g. example.yaml).

Open a shell (command line window) and navigate to the directory of your definition file.

Calculate the results of the analyis with the dmengine command creating a PDF report:

$ dmengine example.yaml --pdf

This will create three files:

  • example-results.yaml – plain-text file with the results in YAML format

  • example-results.tex – LaTeX source for the result report

  • example-results.pdf – PDF output of the report compiled with pdflatex

Results

Go to the outputs section of the report. It provides a paradigm table of the calculated results:

https://raw.github.com/xflr6/dmengine/master/docs/example-outputs.png

The log section of the report contains detailed information about each individual input and the derivation of the output.

https://raw.github.com/xflr6/dmengine/master/docs/example-log.png

Invocation options

Check the usage of the dmengine command:

$ dmengine --help

usage: dmengine [-h] [--version] [--report] [--pdf] [--view]
                filename [directory]

Calculates a given Distributed Morphology (DM) analysis

positional arguments:
  filename    dm analysis .yaml definition file
  directory   analysis results output directory

optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit
  --report    create a LaTeX report from the results
  --pdf       render the report to PDF (implies --report)
  --view      open the report in viewer app (implies --pdf)

Rules

Analyses can use the following types of rules that manipulate the input before insertion:

  • impoverishment – feature deletion

  • obliteration – head removal

  • fission – head feature extraction

  • fusion – head merging

  • copy – head duplication

  • add – features addition

  • metathesis – head position swapping

The following types of readjustment rules are supported (manipulating the output after insertion):

  • delete – exponent removal

  • copy – exponent duplication

  • metathesis – exponent position swapping

  • transform – regular expression search & replace

Contexts

The insertion of vocabulary items and the application of pre-insertion rules can be restricted to the following context types:

  • this_head – the processed head must have the features

  • left_head – the left-adjacent head must have the features

  • right_head – the right-adjacent head must have the features

  • any_head – any input head must have the features

  • anywhere – features must be matched somewhere in the input

TODO

  • check expected spell-out for each input

  • delete_matching: yes/no

  • delete_other: all, given, none

  • set_delete: global, slot, vi

See also

Raphael Finkel provides web-based engines for calculating Paradigm Function Morphology and Network Morphology analyses.

License

dmengine is distributed under the MIT license.

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

dmengine-0.3.zip (78.1 kB view details)

Uploaded Source

Built Distribution

dmengine-0.3-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file dmengine-0.3.zip.

File metadata

  • Download URL: dmengine-0.3.zip
  • Upload date:
  • Size: 78.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for dmengine-0.3.zip
Algorithm Hash digest
SHA256 e44c24cb1fa6811dbcab5d64ec12374a64a239c6635bb811bb80873f9027c5bd
MD5 5bce24f35e571678720056adcb8898cf
BLAKE2b-256 60874110c0d6da32b1e61aaf3a502e21a53789d2dbba126c6372f5377b48a1a3

See more details on using hashes here.

Provenance

File details

Details for the file dmengine-0.3-py3-none-any.whl.

File metadata

  • Download URL: dmengine-0.3-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for dmengine-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 103975ce7d70fee17d2569f7d6b168777e482af1fef9dbe3f1ce720bacf345dc
MD5 8f8239d4baa7a9e1b2e0c0779423d3a7
BLAKE2b-256 970bff6bb9252a9af0297bd3d7781c76b31df1a87e7ed73e20cb6cc0514f3489

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page