Skip to main content

Builds a multi-source English lexicon

Project description

🗽 CityLex: a free English lexical database

PyPI version Supported Python versions CircleCI

CityLex is an English lexical database intended to replace or enhance databases like CELEX. It combines data from up to seven unique sources, including frequency norms, morphological analyses, and pronunciations. Since these have varying license conditions (some are proprietary, others restrict redistribution), we do not provide the database as is. Rather the user must generate a personal copy by executing a Python script, enabling whatever sources they wish to use.

Building your own CityLex

To install CityLex execute

pip install citylex

To see the available data sources and options, execute citylex --help.

To generate the lexicon, execute citylex with at least one source enabled using command-line flags. As most of the data is downloaded from outline sources, an internet connection is normally required. The process takes roughly four minutes with all sources enabled; much of the time is spent downloading large files.

To generate a lexicon with all the sources that don't require manual downloads, execute

citylex --all-free

File formats

Two files are produced. The first, by default citylex.tsv, is a standard wide-format "tab separated values" (TSV) file, of the sort that can be read into Excel or R. Some fields (particularly pronunciations and morphological analyses) can have multiple entries per wordform. In this case, they are separated using the ^ character.

Advanced users may wish to make use of the second file, by default citylex.textproto, a text-format protocol buffer which provides a better representation of the repeated fields. To parse this file in Python, use the following snippet:

import citylex

lexicon = citylex.read_textproto("citylex.textproto")

This will parse the text-format data and populate lexicon. One can then iterate over lexicon.entry like a Python dictionary.

Non-redistributable data sources

Not all CityLex data can be obtained automatically from online sources. If you wish to enable CELEX features, follow the instructions below.

This proprietary resource must be obtained from the Linguistic Data Consortium as LDC96L14.tgz. The file should be decompressed using

tar -xzf LDC96L14.tgz

This will produce a directory named celex2. To enable CELEX2 features, use --celex and pass the local path of this directory as an argument to --celex_path.

For more information

For contributors

To regenerate citylex_pb2.py you will need to install the Protocol Buffers C++ runtime for your platform, making sure the version number (e.g., the one returned by protoc --version matches that of protobuf in requirements.txt. Then, run protoc --python_out=. citylex.proto.

License

The CityLex codebase are distributed under the Apache 2.0 license. Please see License.txt for details.

All other data sources bear their original licenses chosen by their creators; see citylex --help for more information.

Author

CityLex was created by Kyle Gorman.

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

citylex-0.1.14.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

citylex-0.1.14-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file citylex-0.1.14.tar.gz.

File metadata

  • Download URL: citylex-0.1.14.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for citylex-0.1.14.tar.gz
Algorithm Hash digest
SHA256 064c9e1d136bcb8ec4dd74aaee27f31f14692bfc3b7b7c1de6a323e09459fd15
MD5 cceb9f058ef3e3679f461444cf1af7ce
BLAKE2b-256 bffeb5aa63a8c4af9129cce94a9f5309029a7c2e8840e9b6b180a6d15f300643

See more details on using hashes here.

File details

Details for the file citylex-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: citylex-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for citylex-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d94e8e5732076a6f013dfd4374dc65099e6938c2389de3bb5c7ac9055b6f0a94
MD5 8e2e3bfe2899de6236b7fd6276f026cb
BLAKE2b-256 64185e78454be130a9de94295c43c587310690a7421cbdfd04a0467b1dfcf782

See more details on using hashes here.

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