0Pricing
NLP Academy · レッスン

カスタムエンティティルールを追加する

モデルが見逃すドメイン用語を捉える

「カスタムエンティティルールを追加する」はCoddyKit上の無料NLP Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはNLP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 NLP Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

When the Model Misses

Pre-trained NER never saw your product names or internal jargon. Custom rules let you catch the terms it always misses. 🎯

Meet the EntityRuler

spaCy's EntityRuler adds entities from patterns you define, no retraining required. It plugs straight into the pipeline.

Add It to the Pipe

Insert the ruler with add_pipe. Placing it before ner lets your rules take priority over the model's guesses.

ruler = nlp.add_pipe("entity_ruler", before="ner")

Patterns Are Dicts

Each rule is a dict with a label and a pattern. The label is the entity type you want assigned to a match.

{"label": "PRODUCT", "pattern": "CoddyKit"}

Add Your Patterns

Feed a list of pattern dicts to ruler.add_patterns. Now those exact phrases get tagged every time they appear.

ruler.add_patterns([{"label": "PRODUCT", "pattern": "CoddyKit"}])

Token-Based Patterns

Beyond plain strings, patterns can be token lists that match on attributes like lowercase text, giving flexible rules.

{"label": "ORG", "pattern": [{"LOWER": "acme"}]}

Match Multi-Word Terms

A token pattern with several entries catches phrases, so San Pedro Lab is tagged as one entity, not three words.

[{"LOWER": "san"}, {"LOWER": "pedro"}, {"LOWER": "lab"}]

Rules Run First

Because the ruler sits before ner, your custom labels win on conflicts, while the model still handles everything else.

Test Your Rules

Run a sentence through the updated pipeline and loop doc.ents to confirm your new terms now show the right label.

doc = nlp("We shipped CoddyKit today.")
# CoddyKit -> PRODUCT

Save the Patterns

Export rules to disk with to_disk so your whole team reuses the same custom entities instead of redefining them.

ruler.to_disk("patterns.jsonl")

Rules Plus Learning

Custom rules are a fast first step. Later you can train the model on labeled examples for tricky, fuzzy cases. 🚀

Quick Check

How do you make custom rules override the model?

Recap

The EntityRuler adds entities from string or token patterns, runs before ner, and saves to disk for reuse. ✅

よくある質問

「カスタムエンティティルールを追加する」レッスンは無料ですか?

はい。「カスタムエンティティルールを追加する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、NLP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 NLP Academyコースには全4レッスンが含まれています。

「カスタムエンティティルールを追加する」で何を学びますか?

モデルが見逃すドメイン用語を捉える ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

NLP Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのNLP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「カスタムエンティティルールを追加する」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このNLP Academyレッスンでコードを書いて実行できますか?

はい。すべてのNLP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. エンティティとみなされるもの
  2. spaCy でエンティティを抽出する
  3. displaCy でエンティティを可視化する
  4. カスタムエンティティルールを追加する
← NLP Academyに戻る