解析LaTex作者标签以提取作者姓名

时间:2018-10-11 16:15:10

标签: python latex nltk author ner

1。作者标签:

\author{{\small Tanya Araujo$^{a,b}$ and Elsa Fontainha$^{a}$} \and {\small $^{a}$ISEG
(Lisbon School of Economics \& Management) Universidade de Lisboa, } \and
{\small Rua do Quelhas, 6 1200-781 Lisboa Portugal} \and {\small $^{b}$Research
Unit on Complexity and Economics (UECE)} \and {\small Rua Miguel Lupi, 20
1249-078 Lisboa Portugal}}

\author{{\bf R. Vilela Mendes} \and {\small Grupo de Fisica Matematica, Av.
Gama Pinto 2,} \and {\small \ 1699 Lisboa Codex, Portugal
(vilela@cii.fc.ul.pt)} \and {\bf Tanya Araujo and Francisco Lou\cc\a%
} \and {\small Departamento de Economia, ISEG,} \and {\small R. Miguel Lupi
20, 1200 Lisboa, Portugal} \and {\small (tanya@iseg.utl.pt,
flouc@iseg.utl.pt)}}

2。删除了特殊字符,其他标签,电子邮件和数字:

Tanya Araujo和Elsa Fontainha ISEG 里斯本经济与管理学院-里斯本葡萄牙大学-里斯本研究 UECE Rua Miguel Lupi复杂性和经济学单位, -葡萄牙里斯本

R。 Vilela Mendes Grupo de Fisica Matematica,大道 葡萄牙里斯本法典Gama Pinto    Tanya Araujo和Francisco Lou    ISEG经济研究所,R。Miguel Lupi ,葡萄牙里斯本,

3。所需的输出: 仅提取名称并删除大学名称或任何位置名称。尝试使用NLTK的NER,但将Universidade和Lisboa识别为PERSON等。

(PERSON Tanya/NNP)
  (PERSON Araujo/NNP)
  and/CC
  (PERSON Elsa/NNP Fontainha/NNP)
  ISEG/NNP
  (/(
  (ORGANIZATION Lisbon/NNP School/NNP)
  of/IN
  (ORGANIZATION Economics/NNP)
  &/CC
  Management/NNP
  )/)
  (PERSON Universidade/NNP)
  de/FW
  (PERSON Lisboa/NNP)
  ,/,
  (PERSON Rua/NNP)
  do/VBP
  (PERSON Quelhas/NNP)
  ,/,
  -/:
  (PERSON Lisboa/NNP Portugal/NNP Research/NNP Unit/NNP)
  on/IN
  (ORGANIZATION Complexity/NNP)
  and/CC
  (GPE Economics/NNP)
  (/(
  (ORGANIZATION UECE/NNP)
  )/)
  (PERSON Rua/NNP Miguel/NNP Lupi/NNP)
  ,/,
  -/:
  (PERSON Lisboa/NNP Portugal/NNP Alessandro/NNP Spelta/NNP)
  corresponding/VBG
  author/NN
  :/:
  and/CC
  (PERSON Tanya/NNP Araujo/NNP))

是否可以使用NLTK的NER解决此问题,还是我们应该尝试使用spaCy之类的其他任何库?

1 个答案:

答案 0 :(得分:2)

您也许可以使用https://github.com/alvinwan/TexSoup,它会像这样提取作者元素。

>>> from TexSoup import TexSoup
>>> soup = TexSoup(open('tri7.txt').read())
>>> for i in soup.find_all('author'):
...     i
...     
\author{{\small Tanya Araujo$^{a,b}$ and Elsa Fontainha$^{a}$} \and {\small $^{a}$ISEG
(Lisbon School of Economics \& Management) Universidade de Lisboa, } \and
{\small Rua do Quelhas, 6 1200-781 Lisboa Portugal} \and {\small $^{b}$Research
Unit on Complexity and Economics (UECE)} \and {\small Rua Miguel Lupi, 20
1249-078 Lisboa Portugal}}

然后您可以提取

代表的字符串
{{\small Tanya Araujo$^{a,b}$ and Elsa Fontainha$^{a}$}

在这种情况下,可以通过多种方式中的任何一种。 最后,如果您无法让TexSoup替您完成此操作,则可以使用正则表达式删除\small$(a,b)$之类的项目。