简体   繁体   English

如何在使用简单的CoreNLP API时设置tokenizer选项?

[英]How to set tokenizer options when using the simple CoreNLP API?

I'm aware of the tokenizer options that are available in CoreNLP and I know how to set them in the standard version. 我知道CoreNLP中提供的tokenizer选项,我知道如何在标准版本中设置它们。

Is there way to pass the options, eg the untokenizable=noneKeep , when using the Simple CoreNLP interfaces? 有没有办法在使用Simple CoreNLP接口时传递选项,例如untokenizable=noneKeep

You can build a Document with properties. 您可以使用属性构建文档。

package edu.stanford.nlp.examples;

import edu.stanford.nlp.simple.*;

import java.util.*;

public class SimpleExample {

    public static void main(String[] args) {
        Properties props = new Properties();
        props.setProperty("tokenize.options", "untokenizable=allKeep");
        Document doc = new Document(props, "Joe Smith was born in California.  He moved to Chicago last year.");
        for (Sentence sent : doc.sentences()) {
            System.out.println(sent.tokens());
            System.out.println(sent.nerTags());
            System.out.println(sent.parse());
        }
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM