저는 작업중인 프로젝트에서 java에서 openNLP API를 사용하고 있습니다. 것은 나의 프로그램으로 나는 오직 서신 만 처리한다. 코드 :openNLP 자바 - 멀티 용어 포르투갈어 NER
String line = input.nextLine();
InputStream inputStreamTokenizer = new FileInputStream("/home/bruno/openNLP/apache-opennlp-1.7.2-src/models/pt-token.bin");
TokenizerModel tokenModel = new TokenizerModel(inputStreamTokenizer);
//Instantiating the TokenizerME class
TokenizerME tokenizer = new TokenizerME(tokenModel);
String tokens[] = tokenizer.tokenize(line);
InputStream inputStream = new FileInputStream("/home/bruno/openNLP/apache-opennlp-1.7.2-src/models/pt-sent.bin");
SentenceModel model = new SentenceModel(inputStream);
//Instantiating the SentenceDetectorME class
SentenceDetectorME detector = new SentenceDetectorME(model);
//Detecting the sentence
String sentences[] = detector.sentDetect(line);
//Loading the NER-location model
//InputStream inputStreamLocFinder = new FileInputStream("/home/bruno/openNLP/apache-opennlp-1.7.2-src/models/en-ner-location.bin");
//TokenNameFinderModel model = new TokenNameFinderModel(inputStreamLocFinder);
//Loading the NER-person model
InputStream inputStreamNameFinder = new FileInputStream("/home/bruno/TryOllie/data/pt-ner-floresta.bin");
TokenNameFinderModel model2 = new TokenNameFinderModel(inputStreamNameFinder);
//Instantiating the NameFinderME class
NameFinderME nameFinder2 = new NameFinderME(model2);
//Finding the names of a location
Span nameSpans2[] = nameFinder2.find(tokens);
//Printing the spans of the locations in the sentence
//for(Span s: nameSpans)
//System.out.println(s.toString()+" "+tokens[s.getStart()]);
Set<String> x = new HashSet<String>();
x.add("event");
x.add("artprod");
x.add("place");
x.add("organization");
x.add("person");
x.add("numeric");
SimpleTokenizer simpleTokenizer = SimpleTokenizer.INSTANCE;
Span[] tokenz = simpleTokenizer.tokenizePos(line);
Set<String> tk = new HashSet<String>();
for(Span tok : tokenz){
tk.add(line.substring(tok.getStart(), tok.getEnd()));
}
for(Span n: nameSpans2)
{
if(x.contains(n.getType()))
System.out.println(n.toString()+ " -> " + tokens[n.getStart()]);
}
내가 얻을 출력은 다음과 같습니다 일을하려고
Ficheiro com extensao: file.txt
[1..2) event -> choque[3..4) event -> cadeia[6..7) artprod -> viaturas[13..14) event -> feira[16..18) place -> Avenida[20..21) place -> Porto[24..25) event -> incêndio[2..3) event -> acidente[5..6) artprod -> viaturas[44..45) organization -> JN[46..47) person -> António[47..48) place -> Campos[54..60) organization -> Batalhão[1..2) event -> acidente[6..8) numeric -> 9[11..12) place -> Porto-Matosinhos[21..22) event -> ocorrência[29..30) artprod -> .[4..5) organization -> Sapadores[7..10) organization -> Bombeiros[14..15) numeric -> 15
무엇 메신저, 멀티 용어 NER입니다 안토니오 캄포스는 사람이 아닌 사람처럼 -> 안토니오 및 장소 - > Campos 또는 Organisation Nova de Lisboa
임 문장에 텍스트를 깨는을하고, 토큰 화 각 단어를, 그래서 내 프로그램은 개별적으로 각각의 단어에서보고, 내 문제가있다 어디, 내가 가지고 토큰 화하는 것이 아니라 나는 말을보고 예를 들어 사람 안토니오 캄포스를 찾을 때 안토니오가 아닌 한 사람으로, 캄포 스는 장소 또는 다른 사람으로 찾아야합니다 ... 페르난도 페소아의 유니버 시티와 같은 단체들도 마찬가지입니다. 그것을 하나의 조직으로, 조직으로서의 대학으로, 다른 사람과 마찬가지로 페르난도와 사람과 페소 아로 발견하십시오. – Break
알았어, 네 문제는 이해하지만 이건 어떻게 ** 스탠포드 -NLP ** 일인지. NER은이 프로세스가 완료된 후에 만 작동합니다 (tokenize, ssplit, pos, lemma). 따라서 NER 프로세스가 단어를 잘못 쓰는 것이 확실합니다. 이 [link] (https://stanfordnlp.github.io/CoreNLP/dependencies.html)로 아이디어를 얻을 수 있습니다. –
그래서, 단 하나의 단어 만 볼 수 있습니다. 즉, NER로 내 문제를 해결할 수 없다는 뜻입니까? – Break