Python | 12:26 | def ngram(index, id, string, span): u""" >>> index = {} >>> index = ngram(index, 1, u'わがはいは、ねこである', 2) >>> index == {u'わが': [{1: 1}], ... u'がは': [{1: 2}], ... u'はい': [{1: 3}], ... u'いは': [{1: 4}], ... u'は、': [{1: 5}], ... u'、ね': [{1: 6}], ... u'ねこ': [{1: 7}], ... u'こで': [{1: 8}], ... u'であ': [{1: 9}], ... u'ある': [{1: 10}], ... u'る' : [{1: 11}]} True >>> index = {} >>> index = ngra