2016-06-13 5 views
1

큰 코퍼스에서 자격을 식별하고 있습니다. NamedEntityTagAnnotation을 사용하고 있습니다.스탠포드 NLP : RegexNERAnnotator를 caseInsensitive로 설정하십시오.

문제점 :

내 주석은 대소 문자를 구분하여 읽습니다. 대소 문자를 구분하지 않기를 바랍니다. 따라서

학사 학위 학위

학사 학위 학위 나는이 가능 알고

의 추가 항목을 필요로하지 않습니다. RegexNERAnnotator에는 ignoreCase 필드가 있습니다. 하지만 API를 통해 RegexNERAnnotator에 액세스하는 방법을 모르겠습니다.

 String prevNeToken = "O"; 
    String currNeToken = "O"; 
    boolean newToken = true; 
    for (CoreLabel token : sentence.get(TokensAnnotation.class)) 
    { 
     currNeToken = token.get(NamedEntityTagAnnotation.class); 

     String word = token.get(TextAnnotation.class); 

     if (currNeToken.equals("O")) 
     { 

     if (!prevNeToken.equals("O") && (sbuilder.length() > 0)) 
     { 
      handleEntity(prevNeToken, sbuilder, tokens); 
      newToken = true; 
     } 
     continue; 
     } 

     if (newToken) 
     { 
     prevNeToken = currNeToken; 
     newToken = false; 
     sbuilder.append(word); 
     continue; 
     } 

     if (currNeToken.equals(prevNeToken)) 
     { 
     sbuilder.append(" " + word); 
     } 
     else 
     { 

     handleEntity(prevNeToken, sbuilder, tokens); 
     newToken = true; 
     } 
     prevNeToken = currNeToken; 
    } 

어떤 도움을 주시면 감사하겠습니다 다음과 같이 (내가 인터넷을 cadged 케이스 문제에서 떨어져 작동)

내 현재 코드입니다.

답변

2

대답은 파이프 라인을 설정하는 방법입니다.

Properties props = new Properties(); 

    props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, regexner, depparse, natlog, openie"); 


    //props.put("regexner.mapping", namedEntityPropertiesPath); 

    pipeline = new StanfordCoreNLP(props); 
    pipeline.addAnnotator(new TokensRegexNERAnnotator(namedEntityPropertiesPath, true)); 

하지 사용 props.put ("regexner.mapping", namedEntityPropertiesPath)을 수행;

pipeline.addAnnotator를 사용하십시오.

생성자의 첫 번째 인수는 NER 데이터 파일의 경로입니다. 두 번째는 부울 caseInsensitive입니다.

참고 :이 다음 스탠포드의 NER 목록뿐만 아니라 자신의 사용합니다. 또한 더 복잡한 NER 데이터 파일을 사용합니다.

http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/pipeline/TokensRegexNERAnnotator.html

관련 문제