如何用Python从文献字符串中提取完整作者列表?
解决文献作者提取问题
针对你提供的文献字符串,直接用split(';')无法完整提取最后一位作者——因为最后一位作者后没有分号,而是以. 衔接标题。可以通过以下两种方法解决:
方法一:先拆分作者与标题部分
利用作者部分和标题部分的分界符. (点加空格),先分离出完整的作者字符串,再拆分单个作者:
ref = 'ARCADI, G.; DORSCH, G. C.; NETO, J. P.; QUEIROZ, F. S.; OVIEDO-TORRES, Y. M. Probing a dark sector with collider physics, direct detection, and gravitational waves. Physics Letters, Section B: Nuclear, Elementary Particle and High-Energy Physics, v. 848, Jan. 2024.' # 按第一个'. '分割,取前半部分为作者串 author_segment = ref.split('. ', 1)[0] # 用'; '拆分每个作者,补全末尾的点确保格式一致 authors = [author.strip() + '.' for author in author_segment.split(';')] print(authors) # 输出:['ARCADI, G.', 'DORSCH, G. C.', 'NETO, J. P.', 'QUEIROZ, F. S.', 'OVIEDO-TORRES, Y. M.']
方法二:基于标题起始词拆分
如果已知标题固定以某个大写单词开头(比如示例中的Probing),可以直接以此为分割点:
ref = 'ARCADI, G.; DORSCH, G. C.; NETO, J. P.; QUEIROZ, F. S.; OVIEDO-TORRES, Y. M. Probing a dark sector with collider physics, direct detection, and gravitational waves. Physics Letters, Section B: Nuclear, Elementary Particle and High-Energy Physics, v. 848, Jan. 2024.' # 分割出作者部分 author_segment = ref.split(' Probing')[0].strip() # 拆分作者列表 authors = author_segment.split('; ') print(authors) # 输出:['ARCADI, G.', 'DORSCH, G. C.', 'NETO, J. P.', 'QUEIROZ, F. S.', 'OVIEDO-TORRES, Y. M.']
说明
两种方法的核心都是先将作者区域与文献的标题、期刊等内容分离,再对作者区域进行拆分,避免了split(';')无法处理最后一位作者的问题。
内容的提问来源于stack exchange,提问作者Ingrid Ibagon
相关产品推荐
相关产品推荐

