我如何通过映射每个大写字母仅提取括号内首字母缩略词后的缩写

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 = "流程图类似于手动卓越流程框架 (MEPF)"

输出 = 手动卓越流程框架 (MEPF)

我想写一个 python 脚本,其中我有那段文字,我想从中提取括号内给定首字母缩略词的完整形式 (MEPF) 并且完整形式是 Manual Excellence Process Framework 我只想通过匹配括号内的每个大写字母来附加完整的。

我的想法是,当首字母缩略词出现在括号内时,它将映射每个大写字母,例如 (MEPF),从最后一个字母 F 开始,匹配括号前的最后一个单词,这里是 Framwork,然后是 P (Pocess),然后E(卓越)最终 M(手册)所以最终输出将是完整形式(手册卓越流程框架)你能以这种方式尝试一次吗,这对我真的很有帮助

我把你的问题作为一个挑战,我是一个初学者,所以我希望这个答案对你有用,谢谢你的问题:

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)

使用简单的正则表达式和一些 post 处理:

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

输出:

{'IBM': 'International Business Machines',
 'MEPF': 'Manual Excellence Process Framework'}

如果您想检查首字母缩略词是否与单词匹配:

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))
       }

例子

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'}