将名字和姓氏标记为一个标记

编程入门 行业动态 更新时间:2024-10-27 17:11:51
本文介绍了将名字和姓氏标记为一个标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以对标记中的文本进行标记,以便将名字和姓氏组合在一个标记中?例如,如果我的文字是:

Is is possible to tokenize a text in tokens such that first and last name are combined in one token? For example if my text is:

text = "Barack Obama is the President"

那么:

text.split()

结果:

['Barack', 'Obama', 'is', 'the, 'President']

我如何识别名字和姓氏?所以我只得到 ['Barack Obama', 'is', 'the', 'President'] 作为标记.

how can I recognize the first and last name? So I get only ['Barack Obama', 'is', 'the', 'President'] as tokens.

有没有办法在 Python 中实现它?

Is there a way to achieve it in Python?

推荐答案

您正在寻找的是命名实体识别系统.我建议您不要将此视为标记化的一部分.

What you are looking for is a named entity recognition system. I suggest you do not consider this as part of tokenization.

对于python,您可以使用pypi.python/pypi/ner/

For python you can use pypi.python/pypi/ner/

来自网站的示例

>>>tagger.json_entities("爱丽丝去了自然历史博物馆.")'{组织":[自然历史博物馆"],人物":[爱丽丝"]}'

>>> tagger.json_entities("Alice went to the Museum of Natural History.") '{"ORGANIZATION": ["Museum of Natural History"], "PERSON": ["Alice"]}'

更多推荐

将名字和姓氏标记为一个标记

本文发布于:2023-10-23 19:35:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521814.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标记   姓氏   名字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!