A little more about counting and stemming
Believe it or not, beyond just stemming there are multiple ways to count
words!
And what words do you count? Originals? Lowercased? Stemmed? Lemmatized?
There are so many options!
array([[0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0],
[1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0]], dtype=int64)
['and',
'blue',
'bought',
'bright',
'bugs',
'fish',
'fished',
'fishes',
'fishing',
'hate',
'orange',
'penny',
'the']
|
and |
blue |
bought |
bright |
bugs |
fish |
fished |
fishes |
fishing |
hate |
orange |
penny |
the |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
2 |
0 |
0 |
0 |
0 |
0 |
2 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
3 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
4 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
|
and |
blue |
bought |
bright |
bugs |
fish |
fished |
fishes |
fishing |
hate |
orange |
penny |
the |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
2 |
0 |
0 |
0 |
0 |
0 |
2 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
3 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
4 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
Stop words or stopwords
|
and |
blue |
bought |
bright |
bugs |
fish |
fished |
fishes |
fishing |
hate |
orange |
penny |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
2 |
0 |
0 |
0 |
0 |
0 |
2 |
1 |
0 |
0 |
0 |
0 |
0 |
3 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
4 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
|
ate |
blue |
bought |
bright |
bug |
bugs |
fish |
fished |
fishes |
fishing |
hate |
orange |
penny |
0 |
0 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
2 |
0 |
0 |
0 |
0 |
0 |
0 |
2 |
1 |
0 |
0 |
0 |
0 |
0 |
3 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
4 |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
5 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
Stemming
['i', 'went', 'fish', 'to', 'get', 'fish']
['i', 'went', 'fish', 'to', 'get', 'fish']
Using our tokenizer that also stems
|
'm |
ate |
blue |
bought |
bright |
bug |
fish |
hate |
orang |
penni |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
1 |
1 |
2 |
0 |
0 |
0 |
0 |
0 |
0 |
3 |
0 |
0 |
0 |
3 |
1 |
0 |
0 |
0 |
0 |
0 |
2 |
0 |
0 |
0 |
4 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
5 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
TF-IDF
|
'm |
ate |
blue |
bought |
bright |
bug |
fish |
hate |
orang |
penni |
0 |
0.000000 |
0.00 |
0.200000 |
0.200000 |
0.200000 |
0.000000 |
0.200000 |
0.000000 |
0.000000 |
0.200000 |
1 |
0.000000 |
0.00 |
0.166667 |
0.166667 |
0.166667 |
0.000000 |
0.166667 |
0.000000 |
0.166667 |
0.166667 |
2 |
0.000000 |
0.00 |
0.000000 |
0.000000 |
0.000000 |
0.000000 |
1.000000 |
0.000000 |
0.000000 |
0.000000 |
3 |
0.333333 |
0.00 |
0.000000 |
0.000000 |
0.000000 |
0.000000 |
0.666667 |
0.000000 |
0.000000 |
0.000000 |
4 |
0.000000 |
0.00 |
0.333333 |
0.000000 |
0.000000 |
0.333333 |
0.000000 |
0.333333 |
0.000000 |
0.000000 |
5 |
0.000000 |
0.25 |
0.250000 |
0.000000 |
0.000000 |
0.250000 |
0.250000 |
0.000000 |
0.000000 |
0.000000 |
6 |
0.000000 |
0.00 |
0.000000 |
0.000000 |
0.000000 |
0.000000 |
1.000000 |
0.000000 |
0.000000 |
0.000000 |
|
'm |
ate |
blue |
bought |
bright |
bug |
fish |
hate |
orang |
penni |
2 |
0.000000 |
0.00 |
0.000000 |
0.000000 |
0.000000 |
0.000000 |
1.000000 |
0.000000 |
0.000000 |
0.000000 |
6 |
0.000000 |
0.00 |
0.000000 |
0.000000 |
0.000000 |
0.000000 |
1.000000 |
0.000000 |
0.000000 |
0.000000 |
3 |
0.333333 |
0.00 |
0.000000 |
0.000000 |
0.000000 |
0.000000 |
0.666667 |
0.000000 |
0.000000 |
0.000000 |
5 |
0.000000 |
0.25 |
0.250000 |
0.000000 |
0.000000 |
0.250000 |
0.250000 |
0.000000 |
0.000000 |
0.000000 |
0 |
0.000000 |
0.00 |
0.200000 |
0.200000 |
0.200000 |
0.000000 |
0.200000 |
0.000000 |
0.000000 |
0.200000 |
1 |
0.000000 |
0.00 |
0.166667 |
0.166667 |
0.166667 |
0.000000 |
0.166667 |
0.000000 |
0.166667 |
0.166667 |
4 |
0.000000 |
0.00 |
0.333333 |
0.000000 |
0.000000 |
0.333333 |
0.000000 |
0.333333 |
0.000000 |
0.000000 |
Only counting certain words
|
fish |
bug |
0 |
1.0 |
0.0 |
1 |
1.0 |
0.0 |
2 |
1.0 |
0.0 |
3 |
1.0 |
0.0 |
4 |
0.0 |
1.0 |
5 |
0.5 |
0.5 |
6 |
1.0 |
0.0 |
|
fish |
bug |
0 |
1 |
0 |
1 |
1 |
0 |
2 |
3 |
0 |
3 |
2 |
0 |
4 |
0 |
1 |
5 |
1 |
1 |
6 |
1 |
0 |