Skip to main content

🗽 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.

Release files for citylex 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for citylex 0.1.15
File Size Uploaded
citylex-0.1.15.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for citylex 0.1.15
File Interpreter ABI Platform
citylex-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 26.6 kB

Release files / citylex-0.1.15.tar.gz

Download URL citylex-0.1.15.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a24dfe367968eb433e997975c64dde36bb15da7be227c214de0609645001883b
BLAKE2b-256 checksum
How to use checksums
2fb94f6cb165637696003c9ec390c9dcb52c620adced56fa970ec31bbe7fcd68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.13

Release files / citylex-0.1.15-py3-none-any.whl

Download URL citylex-0.1.15-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a042a739dce2842acf61d4cf3640efd6fa4a73404c7f4a80a1d2bf4feba6b174
BLAKE2b-256 checksum
How to use checksums
46c116cc464e6cb619f347c80ada1e3820cdf8fabeacd1c47150f232893efd67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.13

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page