[英]Compare two bigrams lists and return the matching bigram
請建議如何比較 2 個二元組列表並僅返回匹配的二元組。 從下面的示例列表中,如何返回匹配的二元組['two', 'three'] 。
bglist1 =
[['one', 'two'],
['two', 'three'],
['three', 'four']]
bglist2 =
[['one', 'six'],
['two', 'four'],
['two', 'three']]
您可以只測試二元組是否在另一個二元組列表中。
out = list()
for x in bglist1:
if x in bglist2:
out.append(x)
這將為您提供兩個 bglist 中的列表列表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.