Please suggest how to compare 2 bigrams lists and return the matching bigram only. From the below example lists, how to return the matching bigrams ['two', 'three'] .
bglist1 =
[['one', 'two'],
['two', 'three'],
['three', 'four']]
bglist2 =
[['one', 'six'],
['two', 'four'],
['two', 'three']]
You could just test for if the bigram is in the other list of bigrams.
out = list()
for x in bglist1:
if x in bglist2:
out.append(x)
This would give you a list of lists that are in both bglists.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.