Skip to main content

Tools for Old Chinese phonological analysis.

Project description

DIRECT

Digital Intertextual Resonances in Early Chinese Texts

Build Status PyPi Version Python Versions License

installation

install with pip:

$ pip install dphon

usage

the basic function of DIRECT is to phonologically compare two early chinese texts. you will need to have the files saved locally in utf-8 encoded plain text (.txt) format. to compare two texts:

$ dphon text_a.txt text_b.txt # search text b against text a

the output will be a list of character sequences in text_a that have rhyming counterparts in text_b, including the texts and line numbers from which the sequences are drawn:

滋章盜賊多有 (a: 16)    # this sequence of characters from a line 16 matches
滋彰,盜賊多有 (b: 57)  # this sequence of characters from b line 57
...
不可得 (a: 15)         # this sequence from a on line 15 matches two separate 
不可識 (b: 15)         # locations in b, and both of them are on line 15 in b
不可識 (b: 15)
...
解其忿 (a: 15)         # in this sequence, we see three separate graphic
解其紛 (b: 4)          # variations for the third character - one on a line 15
解其分 (b: 56)         # and two from b on lines 4 and 56

note that the sequences ignore non-word characters, including punctuation and numbers. this means that rhymes could span across lines, which will be reflected in the output.

you can view the full list of command options with:

$ dphon --help

methodology

matching sequences are determined by a dictionary file that represents a particular reconstruction of old chinese phonology (you can see some examples in the data/ folder). these data structures map an input character to an arbitrary sound token ("dummy") that can be matched against other such tokens.

the core process of DIRECT is to accept plaintext input, tokenize it according to a particular phonological reconstruction, and search for matches amongst the tokenized text. these matches thus represent resonance: sequences that could have rhymed when they were originally read aloud, despite dissimilarity in their written forms.

development setup

python >=3.6 is required.

first, clone the repository:

$ git clone https://github.com/direct-phonology/direct.git
$ cd direct

then, to create and activate a virtual environment (recommended):

$ python -m venv venv
$ source venv/bin/activate

install dependencies:

$ pip install -r requirements.txt
$ pip install -r dev-requirements.txt

finally, install the package itself in development mode:

$ pip install -e .

now your changes will be automatically picked up when you run dphon.

pull requests should be made against the develop branch.

tests

unit tests are written with pytest. you can run them with:

$ pytest

releases

make sure the version number in dphon/__init__.py is correct!

if there are any built files in dist/ from older releases, remove them before you start this process:

$ rm dist/*

to build a source archive and distribution for a release:

$ python setup.py sdist bdist_wheel

to publish the release on test PyPI (useful for making sure everything worked):

$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*

if everything is OK, publish the package to PyPI:

$ twine upload dist/*

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

dphon-1.0.0.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

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

dphon-1.0.0-py2.py3-none-any.whl (8.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file dphon-1.0.0.tar.gz.

File metadata

  • Download URL: dphon-1.0.0.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for dphon-1.0.0.tar.gz
Algorithm Hash digest
SHA256 36f5d09e000795a58ad16afb7b1503910bdd703526bcfb63dbd25ed630a5a898
MD5 ebaace4fe9af7f9bd9d44eab43615b4f
BLAKE2b-256 589372e9911700c771466e15fda6f5282ccf86748987370cf56e44ad57550572

See more details on using hashes here.

File details

Details for the file dphon-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: dphon-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for dphon-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6df72f0e3896c0e0a40304f4e70e0a5ff8c7a40a11df7cf2f7ae3e6bc2b23e6d
MD5 c9ab7478b7261132e7d6b3e772e97cb8
BLAKE2b-256 b356d0c5e0fc0041a6358a2c9aee3e3bf02bdaf047b086fd04ae5f1eb02ba89b

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