[英]How do i extract only abbreviation following acronyms inside the brackets by mapping each Capital letter
a = "The process maps are similar to Manual Excellence Process Framework (MEPF)"
input = "The process maps are similar to Manual Excellence Process Framework (MEPF)" input = "流程图类似于手动卓越流程框架 (MEPF)"
output = Manual Excellence Process Framework (MEPF) output = 手动卓越流程框架 (MEPF)
I want to write a python scripts where I have that piece of text, from that I want to extract full for of given acronyms inside the brackets (MEPF)
and full form is Manual Excellence Process Framework
I want to append only full from by match each uppercase letter from inside the brackets.我想编写一个 python 脚本,其中我有那段文本,我想从中提取完整的括号内的给定首字母缩略词
(MEPF)
,完整形式是Manual Excellence Process Framework
我想要 append 仅从匹配每个括号内的大写字母。
my idea was when ever acronyms appears inside the bracket that will map each capital letter for example (MEPF) starting from last Letter F that will match last word befoure the bracket here it is Framwork, then P (Pocess) then E(Excellence ) finaly M (manual) so final output will be full form(Manual Excellence Process Framework) can you try once this way that will be realy helpfull for me我的想法是,当括号内出现首字母缩略词时,将 map 每个大写字母(例如,MEPF)从最后一个字母 F 开始,匹配括号前的最后一个单词,这里是框架,然后是 P(Pocess),然后是 E(Excellence) M (manual) so final output will be full form(Manual Excellence Process Framework) 你能试试这种方式对我很有帮助吗
i make your question as a challenge i am a beginner so i hope to be this answer useful for you and thank you for you question:我把你的问题作为一个挑战我是一个初学者,所以我希望这个答案对你有用,谢谢你的问题:
a = "process maps are similar to Manual Excellence Process
Framework (MEPF)"
full = ''
ind = a.index('(')
ind2 = a.index(')')
acr = a[ind+1:ind2]
for i in a.split():
for j in range (len(acr)):
if acr[j] == i[0] and len(i) > 1:
word = i
full = full + word + ' '
print(full)
Using a simple regex and a bit of post-processing:使用一个简单的正则表达式和一些后处理:
a = "I like International Business Machines (IBM). The Manual Excellence Process Framework (MEPF)"
import re
m = re.findall(r'([^)]+) \(([A-Z]+)\)', a)
out = {b: ' '.join(a.split()[-len(b):]) for a,b in m}
out
output: output:
{'IBM': 'International Business Machines',
'MEPF': 'Manual Excellence Process Framework'}
If you want to check the the acronym actually matches the words:如果要检查首字母缩写词是否与单词匹配:
out = {b: ' '.join(a.split()[-len(b):]) for a,b in m
if all(x[0]==y for x,y in zip(a.split()[-len(b):], b))
}
example例子
a = "No match (ABC). I like International Business Machines (IBM). The Manual Excellence Process Framework (MEPF)."
m = re.findall(r'([^)]+) \(([A-Z]+)\)', a)
{b: ' '.join(a.split()[-len(b):]) for a,b in m
if all(x[0]==y for x,y in zip(a.split()[-len(b):], b))
}
# {'IBM': 'International Business Machines',
# 'MEPF': 'Manual Excellence Process Framework'}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.