I used python-ngram
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ngram
text = u'AIUEO'
index = ngram.NGram(N=2)
for term in index.ngrams(index.pad(text)):
print term
result
$ python sample.py
$Ah
Ai
Say
up
Eo
O$
There are many other functions, so you should read the tutorials linked above. It seems that you can also search
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ngram
G = ngram.NGram(['joe','joseph','jon','john','sally'])
print G.search("joseph")
$ python sample.py
[('joseph', 1.0), ('joe', 0.18181818181818182), ('jon', 0.18181818181818182), ('john', 0.16666666666666666)]
Recommended Posts