2017-05-06 14 views
1

スタンフォードを使用しているテキストから数字の実体を認識しようとしているという問題があります。たとえば、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); 
       } 
      } 

     } 

    } 
+0

少し拡張したいと思うかもしれません。どちらのモデルを使用しましたか?どの言語を使用していますか?また、あなたが行ったことを正確に示すコードスニペットも役立ちます。 – entrophy

+0

@entrophy質問: –

+0

を編集しました。クラスのオブジェクトはここで 'パイプライン'です。どのスタンフォードパイプラインを使用しているかのように。 – entrophy

答えて

0

単にあなたがこれらのトークンから、何が必要な場合は、CoreLabel年代javadocを見て代わりtoken.toString()

token.originalText()を使用CoreLabelクラスの任意のオブジェクトから正確なテキストを取得します。

+0

それは私の2番目の質問のための良い人、ありがとう –