2017-10-24 13:50:41 +00:00
|
|
|
//- 💫 DOCS > API > ANNOTATION > TRAINING
|
|
|
|
|
|
|
|
p
|
|
|
|
| spaCy takes training data in JSON format. The built-in
|
|
|
|
| #[+api("cli#convert") #[code convert]] command helps you convert the
|
|
|
|
| #[code .conllu] format used by the
|
|
|
|
| #[+a("https://github.com/UniversalDependencies") Universal Dependencies corpora]
|
|
|
|
| to spaCy's training format.
|
|
|
|
|
|
|
|
+aside("Annotating entities")
|
|
|
|
| Named entities are provided in the #[+a("/api/annotation#biluo") BILUO]
|
|
|
|
| notation. Tokens outside an entity are set to #[code "O"] and tokens
|
|
|
|
| that are part of an entity are set to the entity label, prefixed by the
|
|
|
|
| BILUO marker. For example #[code "B-ORG"] describes the first token of
|
|
|
|
| a multi-token #[code ORG] entity and #[code "U-PERSON"] a single
|
2017-10-26 12:44:32 +00:00
|
|
|
| token representing a #[code PERSON] entity. The
|
|
|
|
| #[+api("goldparse#biluo_tags_from_offsets") #[code biluo_tags_from_offsets]]
|
|
|
|
| function can help you convert entity offsets to the right format.
|
2017-10-24 13:50:41 +00:00
|
|
|
|
|
|
|
+code("Example structure").
|
|
|
|
[{
|
|
|
|
"id": int, # ID of the document within the corpus
|
|
|
|
"paragraphs": [{ # list of paragraphs in the corpus
|
|
|
|
"raw": string, # raw text of the paragraph
|
|
|
|
"sentences": [{ # list of sentences in the paragraph
|
|
|
|
"tokens": [{ # list of tokens in the sentence
|
|
|
|
"id": int, # index of the token in the document
|
|
|
|
"dep": string, # dependency label
|
|
|
|
"head": int, # offset of token head relative to token index
|
|
|
|
"tag": string, # part-of-speech tag
|
|
|
|
"orth": string, # verbatim text of the token
|
|
|
|
"ner": string # BILUO label, e.g. "O" or "B-ORG"
|
|
|
|
}],
|
|
|
|
"brackets": [{ # phrase structure (NOT USED by current models)
|
|
|
|
"first": int, # index of first token
|
|
|
|
"last": int, # index of last token
|
|
|
|
"label": string # phrase label
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
|
|
|
|
p
|
|
|
|
| Here's an example of dependencies, part-of-speech tags and names
|
|
|
|
| entities, taken from the English Wall Street Journal portion of the Penn
|
|
|
|
| Treebank:
|
|
|
|
|
|
|
|
+github("spacy", "examples/training/training-data.json", false, false, "json")
|