Skip to main content

Tools for Old Chinese phonological analysis.

Project description

DIRECT

Digital Intertextual Resonances in Early Chinese Texts

CI Status Dependency Status PyPi Version Python Versions

installation

this software is tested on the latest versions of macOS, windows, and ubuntu. you will need a supported version of python (above), along with pip.

$ pip install dphon

if you're on windows and are seeing incorrectly formatted output in your terminal, have a look at this stackoverflow answer.

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.1.tar.gz (43.6 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.1-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: dphon-1.0.1.tar.gz
  • Upload date:
  • Size: 43.6 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.1.tar.gz
Algorithm Hash digest
SHA256 b8ff20456222455fd4c78a0b50f4e850b5a52241f78dac29ffc54bf7367c0475
MD5 097ceb96b64f6723ee93139b1e75c40c
BLAKE2b-256 5d494b135e1e0e8159f002bfb4d95f823de354c17b1199ec264f60c7d59a5281

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dphon-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3e0987f4be1db131926cbeb52b5084f281a1bf01da6e0cef0248d6408c0aafcb
MD5 ec5dd82def436edba69f7f18810bf8b6
BLAKE2b-256 2c6dfa372d846180bbcaf47bba054c2220f5cafb264931fe26b85dbffa88f98d

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