本文作者:合肥工业大学 管理学院 钱洋 email:1563178220@qq.com 内容可能有不到之处,欢迎交流。

未经本人允许禁止转载

文章目录

  • 简介
  • stanford-corenlp
  • java程序

简介

在做英文文本数据分析时,第一步便是词形还原。例如,一段文本中了出现‘options’和‘option’,其实这两个单词表示一个意思,那么在预处理时‘options’和‘option’都处理成‘option’。
例如,下面给定的文本:

jhend925  https://blog.csdn.net/timo1160139211/article/details/77603141. All 2015 GTIs have heated seats, including the S trim level
with no options. I used to own a 2013 335i with the news system and now own
a 2011 M3 with the stalk system you talked about. The new system on the 2013 was much better.
Ok, yeah, you have to turn it on every time, but it's much easier to adjust speed

进行分割单词与标点符号,并进行词形还原。

stanford-corenlp

stanford-corenlp是一款非常强大的自然语言处理工具,准确率很高。我们可以利用这款工具,完成上述操作。其需要的jar包包括:

java程序

如下,为一个java操作程序:

package com.lda.datadeal;import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;
public class Test {public static void main(String[] args)  {String aString = "jhend925  https://blog.csdn.net/timo1160139211/article/details/77603141. All 2015 GTIs have heated seats, including the S trim level with no options. I used to own a 2013 335i with the news system and now own a 2011 M3 with the stalk system you talked about. The new system on the 2013 was much better. Ok, yeah, you have to turn it on every time, but it's much easier to adjust speed";List<String> word = getlema(aString);for (int i = 0; i < word.size(); i++) {System.out.println(word.get(i));}}/*** 词形还原* @param string:字符串* @return List<String> 分词、提取词形还原后的结果* */public static List<String> getlema(String text){//单词集合List<String> wordslist = new ArrayList<>();;//StanfordCoreNLP词形还原Properties props = new Properties();  // set up pipeline propertiesprops.put("annotators", "tokenize, ssplit, pos, lemma");   //分词、分句、词性标注和次元信息。StanfordCoreNLP pipeline = new StanfordCoreNLP(props);Annotation document = new Annotation(text);pipeline.annotate(document);List<CoreMap> words = document.get(CoreAnnotations.SentencesAnnotation.class);for(CoreMap word_temp: words) {for (CoreLabel token: word_temp.get(CoreAnnotations.TokensAnnotation.class)) {String lema = token.get(CoreAnnotations.LemmaAnnotation.class);  // 获取对应上面word的词元信息,即我所需要的词形还原后的单词wordslist.add(lema);}}return wordslist;}
}

这里写了一个方法getlema,方法的输入是一串文本,输出是分词、词形还原后的结果。为了方便读者直接的理解,以下将控制台输出的结果显示出来:
在实际处理中,可根据getlema方法返回的结果进行再次处理,如去除标点符号、去除停用词、去除URL类型的字符。

jhend925
https://blog.csdn.net/timo1160139211/article/details/77603141
.
all
2015
gti
have
heat
seat
,
include
the
s
trim
level
with
no
option
.
I
use
to
own
a
2013
335us
with
the
news
system
and
now
own
a
2011
m3
with
the
stalk
system
you
talk
about
.
the
new
system
on
the
2013
be
much
better
.
Ok
,
yeah
,
you
have
to
turn
it
on
every
time
,
but
it
be
much
easier
to
adjust
speed

Java基于stanford-corenlp实现英文词形还原相关推荐

  1. NLP工具——Stanford CoreNLP的python封装包 处理中文

    文章目录 1.StanfordCoreNLP是什么? 2.StanfordNLP是什么? 3.StanfordNLP的使用 3.1 安装 3.2 运行 3.3 如何处理中文? 3.4 demo 4.第 ...

  2. NLP:自然语言处理技术之词语级别相关术语解释(如上位词/WordNet)、基于词汇层面的词法分析六大任务(分词/词性标注/词干提取-词形还原/新词发现/形态分析/拼写校正)的简介及其应用

    NLP:自然语言处理技术之词语级别相关术语解释(如上位词/WordNet).基于词汇层面的词法分析(Lexical Analysis)六大任务(分词/词性标注/词干提取-词形还原/新词发现/形态分析/ ...

  3. Stanford CoreNLP Stanza使用手册

    1. 手动下载工具包:(参考https://github.com/stanfordnlp/stanza/issues/275) 默认英语工具包:https://nlp.stanford.edu/sof ...

  4. Ubuntu下安装Stanford CoreNLP

    Stanford CoreNLP提供了一系列自然语言分析工具.它能够给出基本的词形,词性,不管是公司名还是人名等,格式化的日期,时间,量词,并且能够标记句子的结构,语法形式和字词依赖,指明那些名字指向 ...

  5. Stanford Corenlp中文分词自定义词典(扩展词典)

    Stanford Corenlp是斯坦福大学的自然语言处理工具,其中中文分词是基于条件随机场CRF (Conditional Random Field) ,不是基于字典的直接匹配.最近调用Stanfo ...

  6. 自然语言处理——词性标注、词干提取、词形还原

    目录 词性标注 方法 工具 实例 词干提取和词形还原 算法 步骤 词性标注 一般而言,文本里的动词可能比较重要,而助词可能不太重要: 我今天真好看 我今天真好看啊 甚至有时候同一个词有着不同的意思: ...

  7. stanford corenlp的TokensRegex

    最近做一些音乐类.读物类的自然语言理解,就调研使用了下Stanford corenlp,记录下来. 功能 Stanford Corenlp是一套自然语言分析工具集包括: POS(part of spe ...

  8. Stanford CoreNLP遇到的问题

    Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOExcept ...

  9. java基于quasar实现协程池【后篇】

    java基于quasar实现协程池[前篇]:java基于quasar实现协程池_爪哇盘古的博客-CSDN博客 在上一个文章中讲述了通过仿照java自写线程池的方式改写成quasar协程池,功能可以说实 ...

最新文章

  1. 如何php防止XSS攻击
  2. 阿里云mariadb无法启动问题
  3. ios 图片逆时针旋转_iphone-IOS 竖直拍照被旋转,image-orientation 让图片自动旋转
  4. 读书笔记—《销售铁军》随记9-最后一篇
  5. Docker学习总结(38)——开发环境中使用docker run安装Redis再总结
  6. DeFi巨鲸0xb1向DeBank打赏5 ETH
  7. Ubuntu18.04忘记密码解决
  8. java regex 简单使用
  9. IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is...
  10. 系统版本与服务器版本不一致,服务器sql版本不一致,请问如何恢復备份
  11. python去除图片马赛克_【Night Beam】去除文本马赛克的随机算法!
  12. HTML5 学习笔记(一)——HTML5概要与新增标签
  13. “松鼠症”患者看过来 整理电子相册的秘笈都在这了
  14. 在setTimeout或者ajax等异步方法中回调函数的写法与调用
  15. 数据架构师、数据分析师、数据工程师哪个工资更高?
  16. 一篇搞懂OOA/OOD/OOP的区别
  17. 第一章:基于Visual C++ 6.0使用运动控制卡控制电机转动实验操作指导
  18. 为什么python编译fourth = raw.input(‘Year: ‘)[3]时会报错
  19. 华为鸿蒙系统操作教程_华为鸿蒙2.0系统怎么退回EMUI11系统?手把手教你如何进行操作...
  20. 3d打印出现孔洞和裂缝问题

热门文章

  1. PHP5时间相差八小时问题[三种方法]
  2. 面试官系统精讲Java源码及大厂真题 - 13 差异对比:集合在 Java 7 和 8 有何不同和改进
  3. ZooKeeper管理员指南
  4. 快速搭建Nextcloud+OnlyOffice私有云办公平台
  5. vue3 composition-api useRoute useRouter 别混淆
  6. mui switch 实现方案 让你的html 设计更贴近原生
  7. 【Java】统计字符串中每个字符出现的次数
  8. Android Studio Button背景颜色无法修改
  9. C#开发笔记之07-如何实现交换2个变量的值而不引入中间变量?
  10. css blink不闪烁_使它闪烁HTML教程–如何使用Blink标签以及代码示例