if type(prevtag_pair) == list:
word_tag=[]
for row in prevtag_pair:
c =0
x =[]
for col in row:
y=[]
for pair in col:
if len(pair[1])> 0:
y.append(pair[0]+ '_'+pair[1])
else:
y.append(pair[0]+ '_' )
x.append(y)
word_tag.append(x)
我想把它转换成一个班轮。但我收到错误。任何帮助,将不胜感激。
if type(prevtag_pair) == list:
word_tag = [[y.append(pair[0]+ '_'+pair[1]) if len(pair[1])> 0 else y.append(pair[0]+ '_' ) ] for row in prevtag_pair for col in row for pair in col]
如果可能,请更正它。谢谢你。
输入/输出数据:
[[[['挑战','D'],['机会','D'],['克服','P'],['挑战','D'],['机会','D' '], ['higher', 'D'], ['levelthan', 'A']], [['country', 'D'], ['face', 'P'],
['levels', 'N'], ['挑战', 'A'], ['民主', 'A'],
['基础', 'P'], ['进步', 'A']], [['挑战', 'A'], ['民主', 'P'], ['faces', 'N'], ['world', 'D'], ['level', 'A']], [[ '挑战', 'D'], ['机会', 'D'], ['进步', 'A'], ['陈述', 'D'], ['揭示', 'N'], ['idea', 'D'],
['挑战', 'D'], ['难度', ' D'], ['困难', 'A'],
['机会', 'D'], ['进步', 'A'], ['挑战', 'D'],
['克服', ' A'], ['挑战', 'D'], ['成功', 'P'],], ['克服', 'A'], ['挑战', 'D'], ['成功', 'P'],], ['克服', 'A'], ['挑战', 'D'], ['成功', 'P'],
['克服', 'A'], ['上升', 'A'], ['更高', 'D'],
['水平', 'A'], ['进步', 'A']] , [['challenges', ['o']],
['enlight', 'N'], ['deal', 'P'], ['ways', 'D'], ['like', ' A'], ['障碍', 'A'], ['enlights', 'P'], ['afford', 'P'], ['best', 'P'], ['result', ' D'],['挑战','P'],['喜欢','A'],['机会','D'],['进步','P'],['想要',' P'], ['deal', 'P'], ['smartly', 'P'], ['victorious', 'V'],
['宽松', 'C'], ['生活', 'P']], [['挑战', 'D'],
['问题', 'D'], ['机会', 'D' ], ['progress', 'A'],
['meansa', 'N'], ['challenge', 'P'], ['problem', 'D'],
['help', 'D'], ['development', 'D'], ['ex', 'P'], ['farmer', 'D'], ['challenging', 'A'], ['grow', 'P'], ['plants', 'A'],
['set', 'P'], ['target', 'P'], ['help', 'V'], ['发展', 'A']]]]
O/P: 错误出现 [none],[none],.....