나는 제품 설명의 거대한 데이터를 가지고 있으며, POS 태그로 텍스트를 태그 한 후에 NNP 태그를 구분하는 것을 발견 한 설명에서 제품 이름과 의도를 분리해야하는데, 이는 더 많은 클렌징에 도움이됩니다.목록에서 특정 POS 태그를 필터링하여 목록을 구분하는 방법은 무엇입니까?
NNP 태그 만 필터링하고 해당 목록에서 필터링하려고하지만 다음과 같이 비슷한 데이터가 있습니다.
이['User',
'Coala',
'VWR',
'Arfter',
'COALA',
'Category',
'S9901',
'Dummy',
'POETcatalog',
'Vendor',
'VWR',
'COALA',
'COALA',
'User',
'Universitaet',
'Regensburg',
'Scout',
'P17',
'YESRMCDMUSER01',
'Merck',
'KGaA',
'Please']
내가 좀하고 싶습니다 출력은 다음과 같습니다 :
[['User',
'Coala',
'VWR']
['Arfter',
'COALA',
'Category',
'S9901',
'Dummy']
[],
[],
['POETcatalog'],
['Vendor',
'VWR',
'COALA'],
[],
['COALA'],
['User',
'Universitaet',
'Regensburg',
'Scout',
'P17',
'YESRMCDMUSER01',
'Merck',
'KGaA'],
['Please']]
다음과 같은 출력을주고있다
def prodname(a):
p = []
for i in a:
for j in range(len(i)):
if i[j][1]=='NNP':
p.append(i[j][0])
return p
:
data = [[('User', 'NNP'),
('is', 'VBZ'),
('not', 'RB'),
('able', 'JJ'),
('to', 'TO'),
('order', 'NN'),
('products', 'NNS'),
('from', 'IN'),
('iShopCatalog', 'NN'),
('Coala', 'NNP'),
('excluding', 'VBG'),
('articles', 'NNS'),
('from', 'IN'),
('VWR', 'NNP')],
[('Arfter', 'NNP'),
('transferring', 'VBG'),
('the', 'DT'),
('articles', 'NNS'),
('from', 'IN'),
('COALA', 'NNP'),
('to', 'TO'),
('SRM', 'VB'),
('the', 'DT'),
('Category', 'NNP'),
('S9901', 'NNP'),
('Dummy', 'NNP'),
('is', 'VBZ'),
('maintained', 'VBN')],
[('Due', 'JJ'),
('to', 'TO'),
('this', 'DT'),
('the', 'DT'),
('user', 'NN'),
('is', 'VBZ'),
('not', 'RB'),
('able', 'JJ'),
('to', 'TO'),
('order', 'NN'),
('the', 'DT'),
('product', 'NN')],
[('All', 'DT'),
('other', 'JJ'),
('users', 'NNS'),
('can', 'MD'),
('order', 'NN'),
('these', 'DT'),
('articles', 'NNS')],
[('She', 'PRP'),
('can', 'MD'),
('order', 'NN'),
('other', 'JJ'),
('products', 'NNS'),
('from', 'IN'),
('a', 'DT'),
('POETcatalog', 'NNP'),
('without', 'IN'),
('any', 'DT'),
('problems', 'NNS')],
[('Furtheremore', 'IN'),
('she', 'PRP'),
('is', 'VBZ'),
('able', 'JJ'),
('to', 'TO'),
('order', 'NN'),
('products', 'NNS'),
('from', 'IN'),
('the', 'DT'),
('Vendor', 'NNP'),
('VWR', 'NNP'),
('through', 'IN'),
('COALA', 'NNP')],
[('But', 'CC'),
('articles', 'NNS'),
('from', 'IN'),
('all', 'DT'),
('other', 'JJ'),
('suppliers', 'NNS'),
('are', 'VBP'),
('not', 'RB'),
('orderable', 'JJ')],
[('I', 'PRP'),
('already', 'RB'),
('spoke', 'VBD'),
('to', 'TO'),
('anic', 'VB'),
('who', 'WP'),
('maintain', 'VBP'),
('the', 'DT'),
('catalog', 'NN'),
('COALA', 'NNP'),
('and', 'CC'),
('they', 'PRP'),
('said', 'VBD'),
('that', 'IN'),
('the', 'DT'),
('reason', 'NN'),
('should', 'MD'),
('be', 'VB'),
('the', 'DT'),
('assignment', 'NN'),
('of', 'IN'),
('the', 'DT'),
('plant', 'NN')],
[('User', 'NNP'),
('is', 'VBZ'),
('a', 'DT'),
('assinged', 'JJ'),
('to', 'TO'),
('Universitaet', 'NNP'),
('Regensburg', 'NNP'),
('in', 'IN'),
('Scout', 'NNP'),
('but', 'CC'),
('in', 'IN'),
('P17', 'NNP'),
('table', 'NN'),
('YESRMCDMUSER01', 'NNP'),
('she', 'PRP'),
('is', 'VBZ'),
('assigned', 'VBN'),
('to', 'TO'),
('company', 'NN'),
('001500', 'CD'),
('Merck', 'NNP'),
('KGaA', 'NNP')],
[('Please', 'NNP'),
('find', 'VB'),
('attached', 'JJ'),
('some', 'DT'),
('screenshots', 'NNS')]]
나는 다음과 같은 코드를 작성도 사용하려고했습니다.은 해당 목록에 추가 할 수는 있지만 그렇게 할 수는 없습니다.
덕분에 많은
여기에 솔루션을 읽기 쉬운을합니다. 그거야. – sharathchandramandadi