スタンフォードを使用しているテキストから数字の実体を認識しようとしているという問題があります。たとえば、2000万円の場合は「Number」のように取得しています:["20 -5、 "million-6"]、どうすれば20百万人が集まるように答えを最適化できますか?上記の例で(5,6)のようなインデックス番号を無視するにはどうしたらいいですか?私はJava言語を使用しています。スタンフォードの番号名の実体認識
public void extractNumbers(String text) throws IOException {
number = new HashMap<String, ArrayList<String>>();
n= new ArrayList<String>();
edu.stanford.nlp.pipeline.Annotation document = new edu.stanford.nlp.pipeline.Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {
if (!token.get(CoreAnnotations.NamedEntityTagAnnotation.class).equals("O")) {
if (token.get(CoreAnnotations.NamedEntityTagAnnotation.class).equals("NUMBER")) {
n.add(token.toString());
number.put("Number",n);
}
}
}
}
少し拡張したいと思うかもしれません。どちらのモデルを使用しましたか?どの言語を使用していますか?また、あなたが行ったことを正確に示すコードスニペットも役立ちます。 – entrophy
@entrophy質問: –
を編集しました。クラスのオブジェクトはここで 'パイプライン'です。どのスタンフォードパイプラインを使用しているかのように。 – entrophy