word-and-lexical-tools
Use TextBlob Word and WordList for word-level morphology, spelling correction, lemmatization, WordNet lookup, and lexical frequency utilities.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- word-and-lexical-tools
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use TextBlob Word and WordList for word-level morphology, spelling correction, lemmatization, WordNet lookup, and lexical frequency utilities.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/lexical-reference.md6.3 KB
- 参考文档references/troubleshooting.md8.1 KB
- 脚本scripts/lexical_smoke.py8.0 KB
03 SKILL.md 正文
TextBlob word and lexical tools
Use this sub-skill when the task is word-level: inflecting words, stemming,
lemmatizing with optional POS tags, checking spelling suggestions, using
WordNet synsets/definitions, operating on WordList, or counting already
extracted words/noun phrases.
Route elsewhere when the user needs document-level NLP first:
- Tokenization, sentence splitting, POS tagging, noun-phrase extraction,
sentiment, parsing, n-grams, or full
TextBlobworkflows: sibling sub-skillcore-nlp-workflows. - Classifier training, classifier data formats, feature extractors, or
TextBlob(..., classifier=...): sibling sub-skillclassifiers-and-data-formats.
Bundled resources
- Lexical reference: API details, recipes, WordNet POS mapping, WordList behavior, and frequency patterns.
- Troubleshooting: missing corpora, wrong lemmas, spelling-correction caveats, inflection surprises, and list mutation gotchas.
- Lexical smoke script: deterministic installed
package smoke checks. Run
python scripts/lexical_smoke.py --help.
Operating workflow
- Confirm this is word-level. If raw text still needs tokenization, POS
tagging, noun phrases, or sentiment, route to
core-nlp-workflowsfirst and return here for lexical normalization or counts on the resulting words. - Create lexical objects. Import
WordandWordListfromtextblob:Word(string, pos_tag=None)for one token andWordList(collection)for a list-like token collection. - Choose the lexical operation.
- Inflection:
Word(...).singularize()and.pluralize(); batch withWordList(...).singularize()or.pluralize(). - Lemmatization:
Word(...).lemmatize(pos=None)or cached.lemmawhen aWordwas created withpos_tag; pass a WordNet or Penn POS for verbs, adjectives, and adverbs. - Stemming:
Word(...).stem()orWordList(...).stem(); Porter is the default stemmer. - Spelling:
Word(...).spellcheck()returns(candidate, confidence)tuples;.correct()returns the top candidate as aWord. - WordNet:
.synsets,.get_synsets(pos=...),.definitions, and.define(pos=...)require the NLTK WordNet corpus. - Counts: use
WordList.count(term, case_sensitive=False)for words or noun phrases that have already been extracted.
- Inflection:
- Check corpora before WordNet-dependent operations.
lemmatize,lemma, synsets, and definitions rely on NLTK WordNet data. Do not download corpora implicitly; use the smoke script with--skip-wordnetwhen corpus-backed checks should be bypassed. - Record uncertainty. Spelling correction is heuristic and approximate; keep the original token, the proposed correction, and confidence when normalizing noisy keywords.
- Troubleshoot near the workflow. If output is surprising, inspect
references/troubleshooting.mdbefore changing algorithms.
Quick patterns
from textblob import Word, WordList
from textblob.wordnet import VERB
Word("cats").singularize() # Word('cat')
Word("speling").correct() # Word('spelling')
Word("went").lemmatize(VERB) # 'go'
Word("went", "VBD").lemma # 'go'
WordList(["Dog", "dog"]).count("dog") # 2, case-insensitive by default
For noisy keyword normalization, combine spelling suggestions with an explicit POS-aware lemma and keep audit fields:
from textblob import Word
from textblob.wordnet import NOUN
def normalize_keyword(token, pos=NOUN, min_confidence=0.80):
suggestion, confidence = Word(token).spellcheck()[0]
chosen = suggestion if confidence >= min_confidence else token
return {
"original": token,
"suggestion": suggestion,
"confidence": confidence,
"normalized": Word(chosen).lemmatize(pos),
}
If Word("went").lemmatize() returns "went", it used the default noun POS;
recover with Word("went").lemmatize("v"), Word("went").lemmatize(VERB),
or Word("went", "VBD").lemma.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).