0Pricing
NLP Academy · レッスン

モデルを読み込み Doc を処理する

1 回の呼び出しで nlp() にテキストを渡す

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

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

Install First

Before you load anything, you download a model once. The en_core_web_sm model is small, fast, and perfect for getting started.

python -m spacy download en_core_web_sm

Load the Model

You bring spaCy to life with spacy.load. It reads the model from disk and hands you an nlp object ready to process text.

import spacy
nlp = spacy.load("en_core_web_sm")

What nlp Is

That nlp object is your whole pipeline wrapped up. Calling it on text runs every stage: tokenizer, tagger, parser, and entity recognizer.

Process Some Text

To analyze a sentence, just call nlp() on a string. The result is a Doc, a rich container holding all the analysis.

doc = nlp("Apple is hiring in Berlin.")

One Call Does It All

That single call already ran tokenizing, tagging, and parsing. The Doc now carries every result, so you never repeat the work.

Loop Over Tokens

A Doc behaves like a sequence, so you can loop through it. Each item you get back is a Token with its own attributes.

for token in doc:
    print(token.text)

Read Token Text

The raw word lives in token.text. It is exactly the surface string spaCy found while splitting your sentence.

Load Once, Reuse

Loading a model is slow, so do it once at startup. Then reuse the same nlp object for every document you process.

Process Many Docs

For lots of texts, use nlp.pipe. It batches them efficiently and is far faster than calling nlp() in a plain loop.

for doc in nlp.pipe(texts):
    print(len(doc))

Disable for Speed

Need only tokens? You can disable unused components when loading to skip work and run even faster.

nlp = spacy.load("en_core_web_sm", disable=["parser"])

Blank Pipelines

You can also start from spacy.blank for a tokenizer-only pipeline. It is handy when you want to build everything yourself.

nlp = spacy.blank("en")

Quick Check

What do you get back from calling nlp() on a string?

Recap

You install a model, load it once with spacy.load, then call nlp() to get a Doc. One call runs the whole pipeline and you reuse it everywhere. 🎯

よくある質問

「モデルを読み込み Doc を処理する」レッスンは無料ですか?

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

「モデルを読み込み Doc を処理する」で何を学びますか?

1 回の呼び出しで nlp() にテキストを渡す ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

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

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

「モデルを読み込み Doc を処理する」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. 実プロジェクトで spaCy を使う理由
  2. モデルを読み込み Doc を処理する
  3. トークン、Span、Doc オブジェクト
  4. パイプラインをカスタマイズする
← NLP Academyに戻る