Skip to main content

A Python package for NLP tasks related to Chinese text.

Project description

qhChina Lab

Quantitative Humanities China Lab - A research lab and Python package for NLP tasks related to Chinese text analysis.

Repository Structure

This repository contains:

  1. Python Package: The qhchina package for Chinese text analysis in humanities research
  2. Lab Website: The qhChina Lab website located in the /docs folder with information about our research, projects, resources, and documentation

Python Package Features

  • Collocation Analysis: Find significant word co-occurrences in text
  • Corpus Comparison: Statistically compare different corpora
  • Word Embeddings: Work with Word2Vec and other embedding models
  • Text Classification: BERT-based classification and analysis
  • Topic Modeling: Fast LDA implementation with Cython acceleration

Installation

pip install qhchina

Usage Examples

Topic Modeling with LDA

from qhchina.analytics import LDAGibbsSampler

# Each document is a list of tokens
documents = [
    ["word1", "word2", "word3"],
    ["word2", "word4", "word5"],
    # ...
]

# Initialize and train the model
lda = LDAGibbsSampler(
    n_topics=10,
    iterations=500
)
lda.fit(documents)

# Get top words for each topic
for i, topic in enumerate(lda.get_topic_words(10)):
    print(f"Topic {i}: {[word for word, _ in topic]}")

For more examples, see the module documentation.

Website

The lab website is built with Jekyll and includes:

  • Information about the qhChina Lab and our research
  • Project descriptions and updates
  • Resources for Chinese humanities research
  • Comprehensive documentation for the qhchina package
  • Blog with updates and announcements

To run the website locally:

cd docs
bundle install
bundle exec jekyll serve

Documentation

For complete API documentation and tutorials, visit: https://mcjkurz.github.io/qhchina/

License

This project is licensed under the MIT License - see the LICENSE file for details.

For Developers

Building Wheels with Cython Extensions

The package includes Cython extensions for performance-critical components. When installed from PyPI, precompiled wheels should be available for common platforms.

To build wheels locally:

# Install build dependencies
pip install build wheel setuptools cython numpy

# Build the wheel
python -m build --wheel

The precompiled wheels are built using GitHub Actions and support:

  • Linux (for Google Colab and other Linux environments)
  • Windows 10/11

If you need to clean up before building:

# Clean while preserving .c files (for wheel building)
python clean_cython.py

# Clean everything including .c files
python clean_cython.py --all

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

qhchina-0.0.45-cp313-cp313-win_amd64.whl (14.7 MB view details)

Uploaded CPython 3.13Windows x86-64

qhchina-0.0.45-cp312-cp312-win_amd64.whl (14.7 MB view details)

Uploaded CPython 3.12Windows x86-64

qhchina-0.0.45-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

qhchina-0.0.45-cp312-cp312-macosx_11_0_arm64.whl (14.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

qhchina-0.0.45-cp312-cp312-macosx_10_9_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

qhchina-0.0.45-cp311-cp311-win_amd64.whl (14.7 MB view details)

Uploaded CPython 3.11Windows x86-64

qhchina-0.0.45-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

qhchina-0.0.45-cp311-cp311-macosx_11_0_arm64.whl (14.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

qhchina-0.0.45-cp311-cp311-macosx_10_9_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

qhchina-0.0.45-cp310-cp310-win_amd64.whl (14.7 MB view details)

Uploaded CPython 3.10Windows x86-64

qhchina-0.0.45-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

qhchina-0.0.45-cp310-cp310-macosx_11_0_arm64.whl (14.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

qhchina-0.0.45-cp310-cp310-macosx_10_9_x86_64.whl (14.7 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file qhchina-0.0.45-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: qhchina-0.0.45-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 14.7 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for qhchina-0.0.45-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c35a55d2b9571e4deae57a5556fc3a13d015fa1d316dd641917dffe8417174ce
MD5 00c7c78d8712c7622e548796b9586277
BLAKE2b-256 78518e01e14076db6959db66809125a50a577c6559f180691ba44d7c41cda606

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: qhchina-0.0.45-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 14.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for qhchina-0.0.45-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 83d3c91368314fdcb3cecb63308c4a44b9367b82dfb004f171a7038055ee1ca2
MD5 711bb578991d29f4c5ad8ed6f0665803
BLAKE2b-256 c12efaa3de32268f81f648bd5b0d4753e1abe6f89c2c4f02624564664d22cc2b

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 39c49aec7a1a264548ccafc60f371e3777ca100f6b6cd8a8f4b69f6b9d401b17
MD5 006a62dae7fdf07c26860cc737da058f
BLAKE2b-256 b3dc9c4cca565d4c8675a1a039b937633599d5422ff1be68012f6badabf4537f

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 249be01680eebc903c43c69dacfd8b8df5446d77daf8f7e2f368f093d8652b02
MD5 a6099ff5c234f49ba89114e178e3237b
BLAKE2b-256 7b109d8e97b89a35462f7bbe4f719033ed101e5d0960ad35354ffcf5dc09f50b

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 58ca89aea1ba95932b2a06360692a753ed9112f408cd6d82158e0d338244e237
MD5 77fa16f840f48915d43c5c1b91e5e889
BLAKE2b-256 3e29ca7af2c87b7030632c422ca37630eaac4bd5e04b666f3055228078eaaebc

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: qhchina-0.0.45-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 14.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for qhchina-0.0.45-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 768e7660892910eff413c9786ab0b0965df3d336bab1c45687fdb54454460dd0
MD5 bfe86cc3a0b00cb23d6bed28ee000ccb
BLAKE2b-256 c28817a99780625c7e89be2b28afc7a1a199cd78e31628085bf28d2dabe39b80

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f0b84c0d243eebf1865905b24f5948746d766a3b48353a443f7fd5b77c79194
MD5 947144fcc2c8b39cdaac8ace8e81979e
BLAKE2b-256 4713899a2be5ae41f736d180ba435e047b2553bc19ca5e01e53f03616a6db1a3

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 053e5cc2df471421ec8ec6205e6419cb0da5e793194715cf5d1c75733fa767f1
MD5 f66fd9112d795e45eb63b1a919fcdce7
BLAKE2b-256 e1b9860269b34d01b9899cea17e3b8a0a05553528b7b41e95d4b80f6930084e6

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 48560228633a29cee39b17fcd4a31f8b389298eb0e7af3c2abeff043b158cd09
MD5 28811385563b5fd9b8b907fbed7f12a7
BLAKE2b-256 a89a272cd0f9c6182e425377627258c00e179c11c6dd324d850440484466bf5d

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: qhchina-0.0.45-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 14.7 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for qhchina-0.0.45-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f97ecbe1f4d0dc64983160aeccda13aa65746f523db9c958daa8fb6c43dd3947
MD5 869520f43e0708ada998d58dcf2c61c6
BLAKE2b-256 c702bd91870e05754e27a29d371969b8d3e86d07ea815bbb18cfbb9893d7d1e6

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 91a1507e0c90b7651d5e2fbbf86352d9fd1e1f733ba2838234f788a35ee9f886
MD5 e18de6b51a1d910ce58c8cfeda345e55
BLAKE2b-256 914ef8d891fb33cd41dc2152bfb63e16f185a6b6ebd82913378460bbdf57d830

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69250ef6e82e06ad157d13dfdeebacf58e018799af685e4cf99799fdf4c1ca17
MD5 9fddd8c8f09e15b0114054c9a66424d9
BLAKE2b-256 40ab5fe5acb903c6a46f4e4fab61e94fae20dd03967b68da97d453330a8c5eea

See more details on using hashes here.

File details

Details for the file qhchina-0.0.45-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.45-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c5ccc1c35f1df1d43b5e0d8e0bf31b4a3bd0d4c94967348c83bf112236fda379
MD5 0124c4fcb1dee03980856a575021782f
BLAKE2b-256 20392e000030022a048dee20ab9f9dfbd40bf033bdee4384e12e5b5f9ddba104

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