spaCy REST Client
Ent(ity) Request
var request = new SpacyEntRequest(
"en_core_web_md", // the model to use
"the text to analyze",
);
var response = client.getEntities(request);
// Check the return code
if (!response.isSuccessful()) {
// handle error
}
response.forEachRemaining(entity -> {
// Do something with the enitites
entity.getStart();
entity.getEnd();
entity.getText();
entity.getType();
})
Dep(endencies) Request
var request = new SpacyDepRequest(
"en_core_web_md", // the model to use
"the text to analyze",
false, // true if we should collapse punctuation, false otherwise
false // true if we should collapse phrases, false otherwise
);
var response = client.getDependencies(request);
// Check the return code
if (!response.isSuccessful()) {
// handle error
}
response.getArcs().forEach(arc -> {
// Do something with the arcs
arc.getStart();
arc.getEnd();
arc.getDir();
arc.getLabel();
arc.getText();
});
response.getWords().forEach(word -> {
// Do something with the arcs
word.getTag();
word.getText();
});
©2024 Pureinsights Technology Corporation