我使用斯坦福大学的CoreNLP进行提取。下面是试图提取货币和货币符号的句子。
2015年3月5日开云发行5亿欧元0.875 %
我需要提取的数据是欧元5亿欧元0.875
在默认情况下,它的判决为
2015年3月5日开云发行**500,000,000,0.875 %
所以我写了
public static readonly TokenizerFactory TokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(),
"normalizeCurrency=false");
DocumentPreprocessor docPre = new DocumentPreprocessor(new java.io.StringReader(textChunk));
docPre.setTokenizerFactory(TokenizerFactory);现在这句话恰如其分地
2015年3月5日开云发行5亿欧元0.875 %
但当我做的时候
props.put("annotators", "tokenize, cleanxml, ssplit, pos, lemma, ner, regexner");
props.setProperty("ner.useSUTime", "0");
_pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(text);
_pipeline.annotate(document);案文=2015年3月5日开云发行5亿欧元,0.875 %
正在获得输出
<token id="9">
<word>$</word>
<lemma></lemma>
<CharacterOffsetBegin>48</CharacterOffsetBegin>
<CharacterOffsetEnd>49</CharacterOffsetEnd>
<POS>CD</POS>
<NER>MONEY</NER>
<NormalizedNER>$5.000000000875E9</NormalizedNER>
</token>所以我添加了行$5.000000000875E9,但是输出仍然与props.put("tokenize.options", "normalizeCurrency=false");相同。
有人能帮帮我吗。谢谢
发布于 2017-03-27 06:48:03
当我运行此代码时,它没有将货币符号更改为"$":
package edu.stanford.nlp.examples;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import java.util.*;
public class TokenizeOptionsExample {
public static void main(String[] args) {
Annotation document = new Annotation("5 March 2015 Kering Issue of €500,000,000 0.875 per cent");
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit");
props.setProperty("tokenize.options", "normalizeCurrency=false");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
for (CoreLabel token : document.get(CoreAnnotations.TokensAnnotation.class)) {
System.out.println(token);
}
}
}https://stackoverflow.com/questions/42969278
复制相似问题