微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我没有足够的值来解压预期为 3,得到 1复杂的列表理解

如何解决为什么我没有足够的值来解压预期为 3,得到 1复杂的列表理解

我正在努力理解列表,但我不知道如何处理。我想我明白这个问题,但我想保留我的一个班轮。
extract_entities(content) 返回 3 个元素的元组列表

[result_file_ner.write(convert_format(f'{name}\t{tag}\t{ner}\n',pos_table)) 
 for name,tag,ner in zip(*[iter(extract_entities(content))])]

如何更改此列表理解以保持单行? 事实上,我必须这样做才能工作,但我不确定这是否是一个方法

list(map(lambda x: print(x),zip(*[iter(extract_entities(content))]))) 

给予

([('Consuela','NNP','B-PERSON'),('Washington','B-ORGANIZATION'),(',','O'),('a','DT',('longtime','JJ',('House',('staffer','NN',('and','CC',('an',('expert',('in','IN',('securities','NNS',('laws',('is','VBZ',('leading','VBG',('candidate',('to','TO',('be','VB',('chairwoman',('of',('the',('Securities','NNPS',('Exchange',('Commission','I-ORGANIZATION'),('Clinton',('administration',('.','.','O')],)
([('Ms.','B-GPE'),('44','CD',('years',('old',('would','MD',('first',('woman',('black',('head',('five-member',('commission',('that','WDT',('oversees',('markets',("'s",'POS',('candidacy',('being',('championed','VBN',('by',('several',('powerful',('lawmakers',('including',('her','PRP$',('boss',('Chairman',('John',('Dingell','I-PERSON'),('(','(',('D.',('Mich.',(')',')',('Energy',('Commerce',('Committee',)
([('She','PRP',('currently','RB',('counsel',('committee',('Mr.',('have','VBP',('been',('considered',('allies',('exchanges',('while',('banks',('futures',('often',('fought',('with',('them',)
([('A',('graduate',('Harvard',('Law',('School',('Ms.',('worked','VBD',('as',('laywer',('for',('corporate',('finance',('division',('SEC',('late',('1970s',('has',('congressional',('since',('1979',)
([('Separately',('transition',('officials',('said',('Frank',('Newman',('50',('vice',('chairman',('chief',('financial',('officer',('BankAmerica',('Corp.',('expected',('nominated',('assistant',('Treasury',('secretary',('domestic',)
([('Mr.',('who','WP',('giving',('up','RP',('job',('pays',('$','$',('1',('million',('year',('oversee',('auctions',('government',('well',('banking',('issues',)
([('He',('report',('directly',('Secretary-designate',('Lloyd',('Bentsen',('headed',('Senate',('Finance',('past',('six',('also',('nominate',('Samuel',('Sessions',('tax',('one',('top',('jobs',('at',)
([('As',('early',('today',('camp',('name',('five',('undersecretaries',('state',('secretaries',)
([('Peter',('Tarnoff',('former',('Carter',('official',('president',('Council',('on',('Foreign',('Relations',('named',('undersecretary',('political',('affairs',)
([('Former',('Sen.',('Tim',('Wirth',('get',('newly',('created',('post',('global',('which',('include',('refugees',('drugs',('environmental',)
([('Earlier','RBR',('Colorado',('Democrat',('had',('contender',('Environmental',('Protection',('Agency',)
([('In',('addition',('Joan',('Spero',('executive',('American',('Express',('Co.',('economic',)
([('And',('Time',('magazine',('columnist',('Strobe',('Talbott',('ambassador-at-large',('coordinate',('U.S.',('policy',('toward',('Soviet',('Union','I-GPE'),)
([('Several',('appointees',('President',('Bush',('are',('likely',('stay',('office',('least','JJS',('temporarily',('until',('permanent',('successors',('can',)
([('One',('Bernadine',('Healy',('director',('National',('Institutes',('Health',)
([('Another',('holdover',('David',('Kessler',('Food',('Drug',('Administration',('offfice',('Trade',('Representative-designate',('Mickey',('Kantor',('selections',('three',('deputy',('Trade',('representative',('slots',('general',('still',('decided',)
([('But',('Robert',('Kyle',('or',('elsewhere',)
([('For',('many',('subcabinet',('list',('candidates',('narrowed',('considerably',)
([('Clinton',('deciding',('between',('recently',('retired',('Rep.',('Matthew',('McHugh',('N.Y.',('activist',('Gus',('Speth',('International',('Development',)
([('Among',('others',('hired',('Kitty',('Higgins',('aide',('Michigan',('Sander',('Levin',('staff',('Labor',('Department',('Jerry',('Palast',('Service',('Employees',('department',('legislative',('incoming',('serIoUsly',('considering',('moving',('briefing',('room',('press',('decades',('situated',('West','B-LOCATION'),('Wing','I-LOCATION'),('White','B-FACILITY'),'I-FACILITY'),('out',('into',('Old',('Executive',('Office',('Building',('next',('door',)
([('The',('current',('Could',('used',('offices',)
[[result_file_ner.write(convert_format(f'{name}\t{tag}\t{ner}\n',pos_table)) 
  for name,ner in line]
 for line in extract_entities(content)]

如何访问?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?