machine-learning - 词性标注器和词 block 划分器

标签 machine-learning pos-tagger

我想使用 JAVA 制作一个词性标注器和词 block 划分器。但我无法弄清楚我应该从哪里开始。所有库都需要什么?

最佳答案

您可以使用各种库

我在我的项目中使用了 OpenNLP。我认为本说明将帮助您浏览 OpenNLP 库。关注此document

  1. 首先从这个page下载模型
  2. 然后将它们添加到您的项目中
  3. 您还需要 Tokenizer 模型将句子分解为标记。然后将这些 token 传递到 POS Tagger。

代码示例

<小时/>

加载模型

InputStream modelIn = null;

try {
  modelIn = new FileInputStream("en-pos-maxent.bin");
  POSModel model = new POSModel(modelIn);
}
catch (IOException e) {
  // Model loading failed, handle the error
  e.printStackTrace();
}
finally {
  if (modelIn != null) {
    try {
      modelIn.close();
    }
    catch (IOException e) {
    }
  }
}
<小时/>

实例化 POSTaggerME

POSTaggerME tagger = new POSTaggerME(model);
<小时/>

生成标签

    String sent[] = new String[]{"Most", "large", "cities", "in", "the", "US", "had",
                                 "morning", "and", "afternoon", "newspapers", "."};
//This is manual String tokens of a sentence. To Generate word token use [Tokenizer Model][6]         
    String tags[] = tagger.tag(sent);

链接

关于machine-learning - 词性标注器和词 block 划分器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28002136/

相关文章:

nlp - 韩语、泰语和印尼语 POS 标记器

machine-learning - vocabulary_size 对 word2vec tensorflow 实现有什么影响?

machine-learning - 如何评估和分析机器学习算法性能?

python - NLTK BigramTagger 不标记半个句子

neural-network - 如何使用 Keras 构建词性标注器?

regex - 如何将 POS 与单词分开

python - 一种拆分串联名称的算法

statistics - 学习最佳参数以最大化奖励

python - 遗传算法如何在不知道搜索量的情况下优化神经网络的权重?

r - 从文本中提取名词+名词或(形容词|名词)+名词