Modernize NRCLex package layout, resource loading, and release tooling#22
Merged
DemetersSon83 merged 1 commit intomasterfrom Feb 27, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
from nrclex import NRCLexremains stable when installed.nrc_en.jsonis used reliably when no explicit path is provided.Description
nrclex/__init__.py(exportsNRCLex, sets__version__) andnrclex/core.py(implementation), and moved the lexicon tonrclex/data/nrc_en.jsonwhile keepingfrom nrclex import NRCLexcompatible.None→ load bundled resource viaimportlib.resources, explicit existing path → load that file, missing default/relative names → fallback to bundled resource, and missing absolute custom paths raiseFileNotFoundErrorwith a helpful message.functools.lru_cacheand refactored helpers into private methods (_build_word_affect,_compute_top_emotions), introducedEMOTION_ORDER, usedCounteranditertools.chainfor performance, and added type hints/docstrings.setup.pywithpyproject.toml(PEP 517/621), removed stdlib modules fromdependencies, setrequires-python = ">=3.9", and configured package data sonrclex/data/nrc_en.jsonis included in sdist/wheel.tests/(temporary small lexicons) and an optional integration test forload_raw_textthat is skipped when TextBlob/corpora are not available, created a GitHub Actions CI workflow (.github/workflows/ci.yml), and addedRELEASING.mdandCOMPATIBILITY.md.Testing
PYTHONPATH=. pytest -q -m "not integration"and they passed (all unit tests succeeded).PYTHONPATH=. pytest -qand it passed; the integration test is guarded withpytest.importorskip/skip logic and will be skipped automatically iftextblob/corpora are not present in the environment.raw_emotion_scores,affect_frequencies, andtop_emotionsfor the sample tokens.pip install -e .,python -m build,twine check dist/*) could not be completed in this environment because build tools/network access were unavailable orsetuptools/build/twinewere not installable due to network/proxy restrictions; these steps are included in CI andRELEASING.mdfor use in a network-enabled environment.Codex Task