SpaCy stores its labels like [DET], [NOUN], etc as numbers. So what we run to access the particular unique number vs what we run to access the actual label is different.
token.pos # 90 <-- which is a number of the particular POS tag
token.pos_ # 'DET' <-- this is the actual POS tagSpaCy uses numbers because there is less to store number than letters. SpaCy keeps a big 2 column table as shown below:
| word | number |
|---|---|
DET | 90 |
nsubj | 429 |
PERSON | 380 |
The title number, is also called a hash. A hash is just the number that represents the word/label.
Types of Labels
- note that we can also use
.explain('DET') - NER only gives us 4 of these labels, while POS tagging gives us all labels
| Label | Plain meaning | Example |
|---|---|---|
PERSON | a person | Simon Liu |
NORP | nationality, religious or political group | Chinese, Muslim, Republican |
FAC | a building or structure you can walk into | Changi Airport, the Eiffel Tower |
ORG | a company, school, agency, team | NTU, Google, ST Engineering |
GPE | a country, city, or state / a place with a government | Singapore, Japan, California |
LOC | a place with no government / natural or regional | Mount Fuji, the Pacific Ocean, Southeast Asia |
PRODUCT | an object, vehicle, or food that's branded | iPhone, Boeing 747 |
EVENT | a named happening | World War II, the Olympics |
WORK_OF_ART | a title of a book, song, film, or award | The Hobbit, the Nobel Prize |
LAW | a named law or legal document | the Constitution |
LANGUAGE | a named language | English, Malay |
DATE | a date or period | 1959, last Tuesday, three years |
TIME | a time shorter than a day | 8pm, two hours |
PERCENT | a percentage | 40%, ten percent |
MONEY | an amount of money | $50, three dollars |
QUANTITY | a measurement | 5 kilometres, 20 kg |
ORDINAL | position in an order | first, 3rd |
CARDINAL | a plain number that isn't any of the above |
Where each of these spaCy tasks sits in the wider flow is shown in Pipeline.