grammar-parse-semantics
Use NLTK grammars, parsers, chunkers, trees, dependency graphs, semantic logic, and inference APIs without reopening the source repo.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- grammar-parse-semantics
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use NLTK grammars, parsers, chunkers, trees, dependency graphs, semantic logic, and inference APIs without reopening the source repo.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md19.8 KB
- 参考文档references/troubleshooting.md12.9 KB
- 参考文档references/workflows.md10.2 KB
- 脚本scripts/grammar_parse_smoke.py7.7 KB
03 SKILL.md 正文
Grammar Parse Semantics
Use this sub-skill when the task is about NLTK grammar authoring, parse-tree generation or inspection, regular-expression chunking, dependency graph handling, semantic interpretation, logic expressions, or theorem-proving/model-building wrappers.
Route away from this sub-skill when the task is mainly about:
- Installing or locating NLTK data packages, sample grammars, corpora, or model resources: use
../data-and-downloader/SKILL.mdfirst. - Tokenization, POS tagging, stemming, lemmatization, or VADER preprocessing before parsing/chunking: use
../tokenize-tag-stem/SKILL.mdwhen available. - Classifiers, language models, probability distributions, metrics, or translation/alignment: use
../ml-metrics-and-translation/SKILL.md.
Fast Paths
- For small grammar workflows, prefer in-memory
CFG.fromstring(...),PCFG.fromstring(...), orFeatureGrammar.fromstring(...); then parse already-tokenized input withChartParser,RecursiveDescentParser,ShiftReduceParser,ViterbiParser, or feature chart parsers. - When a parser returns no trees, first check exact terminal/token alignment with
grammar.check_coverage(tokens), casing, punctuation, and the grammar start symbol before changing parser strategy. - For ambiguity, use
ChartParseror chart strategy subclasses and count/inspect all returned trees. UseShiftReduceParseronly when a single heuristic parse is acceptable; it can miss parses in ambiguous grammars. - For chunking, feed
RegexpParserPOS-tagged tuples such as[('the', 'DT'), ('dog', 'NN')]; chunk grammars operate over tags, not raw words. - For tree manipulation, use
Tree.fromstring,label(),leaves(),treepositions(),subtrees(),productions(),pformat(),chomsky_normal_form(), andcollapse_unary()rather than manually traversing nested lists. - For dependency input, start with a tiny Malt/CoNLL string and
DependencyGraph; useDependencyEvaluatoronly after verifying equal token sequences. - For semantics, parse expressions with
Expression.fromstring, evaluate withValuation,Assignment, andModel, and useFeatureGrammarSEMfeatures when connecting parse trees to semantic representations. - Treat CoreNLP, Stanford, Malt, BLLIP, Prover9, Mace4, Graphviz rendering, and trained transition-parser models as optional external-wrapper workflows. They require external services, Java/JARs, binaries, models, or trusted model files and are not part of the base no-download path.
Reference Map
- Public grammar, parser, chunker, tree, dependency, semantics, inference, and optional wrapper API contracts:
references/api-reference.md. - Task recipes for CFG/PCFG/feature grammars, parser comparisons, chunking, tree transforms, dependency graphs, semantic models, DRT, and wrapper caveats:
references/workflows.md. - Failure diagnosis for empty parses, malformed grammars, chunk regexes, tree parsing, dependency files, semantic logic, resource bounds, and optional wrappers:
references/troubleshooting.md. - Tiny in-memory no-download runtime check covering CFG/chart/RD/shift-reduce parsing, PCFG/Viterbi, feature grammar semantics, chunking, trees, dependency graphs, logic/model evaluation, and DRT:
scripts/grammar_parse_smoke.py.
Minimum Validation Pattern
- Print
nltk.__version__, Python version, and the parser or grammar class being used. - Keep tokenization/tagging explicit; for CFG/PCFG parsers, assert
grammar.check_coverage(tokens)succeeds before interpreting an empty parse list. - For ambiguity-sensitive tasks, report parse count and the parser strategy; do not silently take the first tree unless the task says one-best is acceptable.
- For
RegexpParser, assert input is POS-tagged, runtree2conlltags()or inspectTreesubtrees, and document whether nested chunks are expected. - For semantic workflows, assert the parsed expression, valuation domain, assignment, and
Model.evaluate(...)result; handle'Undefined'separately fromFalse. - For external parser/prover wrappers, verify the exact external binary/JAR/service/model path and timeout/resource settings before invoking them.
- Run the bundled no-download smoke from any current working directory in an environment with NLTK installed:
python /path/to/skills/disco/nltk/sub-skills/grammar-parse-semantics/scripts/grammar_parse_smoke.py --help
python /path/to/skills/disco/nltk/sub-skills/grammar-parse-semantics/scripts/grammar_parse_smoke.py --json
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).