【发布时间】:2016-06-24 12:08:02
【问题描述】:
我一直在尝试使用 stanford Core NLP。我希望训练我自己的 NER 模型。从 SO 的论坛和官方网站上描述了使用属性文件来做到这一点。我将如何通过 API 做到这一点?。
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, sentiment, regexner");
props.setProperty("regexner.mapping", "resources/customRegexNER.txt");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String processedQuestion = "Who is the prime minister of Australia?"
//Annotation annotation = pipeline.process(processedQuestion);
Annotation document = new Annotation(processedQuestion);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
// To get the tokens for the parsed sentence
for (CoreMap tokens : sentence.get(TokensAnnotation.class)) {
String token = tokens.get(TextAnnotation.class);
String POS = tokens.get(PartOfSpeechAnnotation.class);
String NER = tokens.get(NamedEntityTagAnnotation.class);
String Sentiment = tokens.get(SentimentClass.class);
String lemma = tokens.get(LemmaAnnotation.class);
- 如何以及在哪里添加道具文件?
- N-gram 标记化(例如,将总理视为单个标记,稍后将此标记传递给 POS,NER 而不是传递两个标记(总理和部长))?
【问题讨论】:
标签: java stanford-nlp tokenize named-entity-recognition