0
OpenNLP를 사용하고 있지만 정확한 이름, 위치, 조직 엔티티를 제공하지 않습니다. 스탠포드 파서를 사용하여 엔티티를 추출하는 방법은 무엇입니까?스탠포드 파서를 사용하여 엔티티를 추출하는 방법은 무엇입니까?
OpenNLP를 사용하고 있지만 정확한 이름, 위치, 조직 엔티티를 제공하지 않습니다. 스탠포드 파서를 사용하여 엔티티를 추출하는 방법은 무엇입니까?스탠포드 파서를 사용하여 엔티티를 추출하는 방법은 무엇입니까?
내 코드가 도움이됩니다. 여기
내 코드입니다public class stanfrdIntro {
public static void main(String[] args) throws IOException, SAXException,
TikaException {
String serializedClassifier = "classifiers/english.all.3class.distsim.crf.ser.gz";
AbstractSequenceClassifier<CoreLabel> classifier = CRFClassifier
.getClassifierNoExceptions(serializedClassifier);
if (args.length > 1) {
String fileContents = IOUtils.slurpFile(args[1]);
List<List<CoreLabel>> out = classifier.classify(fileContents);
for (List<CoreLabel> sentence : out) {
for (CoreLabel word : sentence) {
System.out.print(word.word() + '/' +
word.get(CoreAnnotations.AnswerAnnotation.class) + ' ');
}
System.out.println();
}
out = classifier.classifyFile(args[1]);
for (List<CoreLabel> sentence : out) {
for (CoreLabel word : sentence) {
System.out.print(word.word() + '/' +
word.get(CoreAnnotations.AnswerAnnotation.class) + ' ');
}
System.out.println();
}
} else {
String s1 = "Good afternoon Rahul Kulhari, how are you today?";
String s2 =
"I go to school at Stanford University, which is located in California.";
stanfrdIntro si = new stanfrdIntro();
String s1 = si.contentEx();
s1 = s1.replaceAll("\\s+", " ");
System.out.println(s1);
String t=classifier.classifyWithInlineXML(s1);
System.out.println(Arrays.toString(getTagValues(t).toArray()));
XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression expr = xpath.compile("//PERSON/text()");
Object value = expr.evaluate(doc, XPathConstants.STRING);
System.out.println(t);
System.out.println(classifier.classifyToString(s1));
Set<String> s=classifier.;
for(String s13: s)
{
System.out.println(s13);
}
System.out.println(classifier.classifyWithInlineXML(s1));
System.out.println(classifier.classifyToString(s1, "xml", true));
int i=0;
for (List<CoreLabel> lcl : classifier.classify(s2)) {
for (CoreLabel cl : lcl) {
System.out.println(i++ + ":");
System.out.println(cl);
}
}
}
}
}