擅长:python、mysql、java
<p>像这样的:</p>
<pre><code>>>> from nltk import bigrams
>>> text = """thai iced tea
... spicy fried chicken
... sweet chili pork
... thai chicken curry"""
>>> lines = map(str.split, text.split('\n'))
>>> for line in lines:
... ", ".join([" ".join(bi) for bi in bigrams(line)])
...
'thai iced, iced tea'
'spicy fried, fried chicken'
'sweet chili, chili pork'
'thai chicken, chicken curry'
</code></pre>
<hr/>
<p>或者使用<code>colibricore</code><a href="https://proycon.github.io/colibri-core/doc/#installation" rel="nofollow">https://proycon.github.io/colibri-core/doc/#installation</a>;p</p>