L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Productivité · 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.

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

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.
Skills enregistrées