对英文单词的词性标注
来源:互联网 发布:java 反射 用途 编辑:程序博客网 时间:2024/04/26 05:37
QQ:66781877
1.前言
最近的一个项目有个需求是这样的,需要从一篇英文文章或者一段英文文字中提取出其中的形容词(adjective),即对单词进行词性标注,我看到这个需求,第一反应是这肯定是个自然语言处理的问题。首先需要对句子进行分词,英文的分词是很容易的,但是分词之后,对于词性的判断,我最初的想法是,找一个英文字典,然后将单词输入,在字典中进行词性的查找。
先不说这种方法词性判断的准确率,从效率上来说,这样去对单词按词性分类,速度是很慢的。于是我继续查找资料,发现,对中文的词性判断,是有开源的解决方案的,如一些中文分词器:jcseg等等。但是对英文单词的词性标注,这些中文分词器是没有做到的,至少我目前没有找到。
既然中文分词器能对中文进行词性标注,那么英文分词器是否能对英文进行词性标注呢?很遗憾,我在lucene中,并没有找到相关的API,于是乎,我只能寻求其它解决办法。
进过一番努力,我从Stanford University的自然语言处理小组网站上找到了一个开源的英文词性标注工具,大喜过望,看了相关的介绍文档之后,运行了例子程序,发现分词的准确率是很高的,而且速度很快。
2.程序及说明
这个开源词性标注工具中有三种分类器,english-bidirectional-distsim.tagger english-left3words-distsim.tagger wsj-0-18-bidirectional-nodistsim.tagger,根据他的说明文档,标注的准确率大概在97.01%,另外,该工具还可以对中文、德文等语言进行词性标注。
下面来看看标注程序及标注结果:
2.1.标注程序
public class Tagger { public static void main(String[] args) throws Exception {String str = "The list of prisoners who may be released in coming days includes militants" +" who threw firebombs, in one case at a bus carrying children; stabbed and shot" +" civilians, including women, elderly Jews and suspected Palestinian collaborators; " +"and ambushed and killed border guards, police officers, security agents and soldiers. " +"All of them have been in prison for at least two decades; some were serving life sentences."; MaxentTagger tagger = new MaxentTagger("c:/wsj-0-18-bidirectional-nodistsim.tagger"); Long start = System.currentTimeMillis(); List<List<HasWord>> sentences = MaxentTagger.tokenizeText(new StringReader(str)); System.out.println("Tagging 用时"+(System.currentTimeMillis() - start)+"毫秒"); for (List<HasWord> sentence : sentences) { ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence); System.out.println(Sentence.listToString(tSentence, false)); } }}
2.2.标注结果
Tagging 用时84毫秒The/DT list/NN of/IN prisoners/NNS who/WP may/MD be/VB released/VBN in/IN coming/VBG days/NNS includes/VBZ militants/NNS who/WP threw/VBD firebombs/NNS ,/, in/IN one/CD case/NN at/IN a/DT bus/NN carrying/VBG children/NNS ;/: stabbed/VBN and/CC shot/VBN civilians/NNS ,/, including/VBG women/NNS ,/, elderly/JJ Jews/NNS and/CC suspected/JJ Palestinian/JJ collaborators/NNS ;/: and/CC ambushed/VBN and/CC killed/VBN border/NN guards/NNS ,/, police/NN officers/NNS ,/, security/NN agents/NNS and/CC soldiers/NNS ./.All/DT of/IN them/PRP have/VBP been/VBN in/IN prison/NN for/IN at/IN least/JJS two/CD decades/NNS ;/: some/DT were/VBD serving/VBG life/NN sentences/NNS ./.
下面这张表,是英文单词的词性表
从上面的表和程序的标注结果来看,分词是很准确的。
- 对英文单词的词性标注
- 通过stanford-postagger对英文单词进行词性标注
- 自动化对语料做词性标注
- 词性标注
- 词性标注
- 词性标注
- 词性标注
- 词性标注
- 转载 基于HMM模型的词性标注
- python的jieba分词词性标注
- NLPIR 词性标注的兼容设置
- 中文词性标注的简单实现
- 四、何须动手?完全自动化对语料做词性标注
- 词性标注(1)
- 一阶HMM词性标注
- 词性标注类函数
- 斯坦福词性标注Demo
- 词性标注说明
- 电脑突然重启解决方案
- SVN使用中的经验浅谈
- poj 1000 A+B Problem
- 范围潜变和渐进明晰
- hdu - 4619 - Warm up 2
- 对英文单词的词性标注
- UVa 442 - Matrix Chain Multiplication
- 【COCOS2DX-游戏开发之十四】用外部浏览器打开url的方法
- UNIX网络编程——客户/服务器程序设计示范(一)
- Hibernate缓存的作用
- HDU 2448 Mining Station on the Sea
- jQuery简单的拖动效果实现原理及示例
- Min-Min算法和Max-Min算法
- CPU 工艺与发热量关系