界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

legacy-extension

legacy-extension

【效率与协作】Guides LTP legacy perceptron and ltp_extension workflows for fast CWS/POS/NER, custom segmentation rules, and trainer APIs.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: legacy-extension description: "Guides LTP legacy perceptron and ltp_extension workflows for fast CWS/POS/NER, custom segmentation rules, and trainer APIs." disable-model-invocation: true metadata: disco-role: operating license: CC BY-NC 4.0

Legacy Extension

Use this sub-skill for the Rust-backed Python extension surface: fast legacy CWS/POS/NER, sentence splitting utilities, custom word hooks, CWS character-type rules, direct model files, and perceptron trainer APIs.

Choose this route when

  • The user asks for LTP("LTP/legacy"), ltp_extension, CWSModel, POSModel, NERModel, CharacterType, Algorithm, Trainer, CWSTrainer, POSTrainer, or NERTrainer.
  • Speed is more important than the full neural task set and only CWS/POS/NER are needed.
  • The task involves direct legacy model binary files, custom CWS rules for digits/roman/kanji, or legacy perceptron training data.
  • The user needs to understand benchmark/performance claims without running large benchmark scripts.

For neural SRL/DEP/SDP/SDPG, use ../python-pipeline/SKILL.md. For Rust-native crate use, use ../rust-bindings/SKILL.md.

Main workflow

  1. Verify imports without model downloads:

    python ../../scripts/check_ltp_install.py --json
    python scripts/legacy_rules_smoke.py --no-model
    
  2. For high-level legacy inference, use the factory when a complete legacy model directory or cache is available:

    from ltp import LTP
    ltp = LTP("LTP/legacy")
    output = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner"])
    
  3. For direct model files, use specialized extension classes:

    from ltp_extension.perceptron import CWSModel, POSModel, NERModel
    cws = CWSModel.load("cws_model.bin")
    pos = POSModel.load("pos_model.bin")
    ner = NERModel.load("ner_model.bin")
    words = cws.predict("他叫汤姆去拿外衣。")
    tags = pos.predict(words)
    entities = ner.predict(words, tags)
    
  4. Validate trainer inputs before training:

    python scripts/legacy_trainer_config_check.py --task cws --train-file train.txt --eval-file dev.txt --algorithm AP
    

Read these references

Bundled helpers

Boundaries

  • Legacy only covers CWS/POS/NER. Do not route SRL/DEP/SDP/SDPG here.
  • Direct model classes require local model binary files. The skill does not ship pretrained model weights.
  • Trainer APIs can run training, but the bundled script only validates configuration; running training is a user-approved expensive action.
我的收藏