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.43-cp313-cp313-macosx_14_0_arm64.whl (14.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

qhchina-0.0.43-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.43-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.43-cp310-cp310-win_amd64.whl (14.7 MB view details)

Uploaded CPython 3.10Windows x86-64

qhchina-0.0.43-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

File details

Details for the file qhchina-0.0.43-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for qhchina-0.0.43-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6fb3284712f67137d816ce069b852ee23a48098ba64f0009f10fe325eeba6e0d
MD5 30d4c9168dca0043e642e489fb85579e
BLAKE2b-256 fa56a2343f214559073008287614619437228a1ea3c7d7b014d31bd242762872

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qhchina-0.0.43-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 446a910a6f13e6bdd51e136fe3ebda5468b0b8c16a44a736fbf5537b055d5460
MD5 9a5592b5736c25092a848cae1572ccb7
BLAKE2b-256 575fd31a3fb5d5e559fb0c2965fcc2789e2f0bf45cde09e6b6a282a9543839a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qhchina-0.0.43-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f2bec06a5700350bd7ece8e0b39d7945214dceccb066f35ff59b097d79c0ad1
MD5 552127027ed29a050fa818cbf14ed896
BLAKE2b-256 967dfe68eb577e2d30bcdad2415e9531500bfa41d8ce7217f0f208d7fa658ad6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qhchina-0.0.43-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.2

File hashes

Hashes for qhchina-0.0.43-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a811680d74ce352c82986580616e4cb64e41685e61be7de46d63bc49e3af9587
MD5 32bb60e8d5a90cad1fe54267f28cffc9
BLAKE2b-256 a8bb0ae0f373df040be96c28152485347a2eac04e004cb4eb5454590530eb6e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qhchina-0.0.43-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f4da700d6091c63e4adbf0dfd67afd3728cf9796ac8e655488a0417860ac001
MD5 34e9e0c4bb663723ea76204644eb7b75
BLAKE2b-256 7ef392466e959cb757d8ee94dbe848452cae052a8601315aa564696154515f26

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