Search in sources :

Example 1 with TaggedEntity

use of org.knime.ext.textprocessing.nodes.tagging.TaggedEntity in project knime-cloud by knime.

the class EntityTagger method tagEntities.

@Override
protected List<TaggedEntity> tagEntities(final Sentence sentence) {
    final String textValue = sentence.getTextWithWsSuffix();
    final DetectEntitiesRequest request = new DetectEntitiesRequest().withText(textValue).withLanguageCode(m_languageCode);
    final DetectEntitiesResult result = m_client.detectEntities(request);
    return // 
    result.getEntities().stream().map(// 
    entity -> new TaggedEntity(entity.getText(), entity.getType())).collect(Collectors.toList());
}
Also used : AmazonEntityTag(org.knime.cloud.aws.mlservices.utils.tagsets.AmazonEntityTag) Arrays(java.util.Arrays) List(java.util.List) AbstractDocumentTagger(org.knime.ext.textprocessing.nodes.tagging.AbstractDocumentTagger) Sentence(org.knime.ext.textprocessing.data.Sentence) Document(org.knime.ext.textprocessing.data.Document) Tag(org.knime.ext.textprocessing.data.Tag) AmazonComprehend(com.amazonaws.services.comprehend.AmazonComprehend) TaggedEntity(org.knime.ext.textprocessing.nodes.tagging.TaggedEntity) DetectEntitiesRequest(com.amazonaws.services.comprehend.model.DetectEntitiesRequest) DetectEntitiesResult(com.amazonaws.services.comprehend.model.DetectEntitiesResult) Collectors(java.util.stream.Collectors) TaggedEntity(org.knime.ext.textprocessing.nodes.tagging.TaggedEntity) DetectEntitiesResult(com.amazonaws.services.comprehend.model.DetectEntitiesResult) DetectEntitiesRequest(com.amazonaws.services.comprehend.model.DetectEntitiesRequest)

Example 2 with TaggedEntity

use of org.knime.ext.textprocessing.nodes.tagging.TaggedEntity in project knime-cloud by knime.

the class SyntaxTagger method tagEntities.

@Override
protected List<TaggedEntity> tagEntities(final Sentence sentence) {
    final String textValue = sentence.getTextWithWsSuffix();
    // Create the delete syntax request
    final DetectSyntaxRequest request = new DetectSyntaxRequest().withText(textValue).withLanguageCode(m_languageCode);
    final DetectSyntaxResult result = m_client.detectSyntax(request);
    return // 
    result.getSyntaxTokens().stream().map(// 
    token -> new TaggedEntity(token.getText(), token.getPartOfSpeech().getTag())).collect(Collectors.toList());
}
Also used : UniversalDependenciesPOSTagSet(org.knime.ext.textprocessing.data.UniversalDependenciesPOSTagSet) DetectSyntaxRequest(com.amazonaws.services.comprehend.model.DetectSyntaxRequest) Arrays(java.util.Arrays) List(java.util.List) AbstractDocumentTagger(org.knime.ext.textprocessing.nodes.tagging.AbstractDocumentTagger) Sentence(org.knime.ext.textprocessing.data.Sentence) Document(org.knime.ext.textprocessing.data.Document) DetectSyntaxResult(com.amazonaws.services.comprehend.model.DetectSyntaxResult) Tag(org.knime.ext.textprocessing.data.Tag) AmazonComprehend(com.amazonaws.services.comprehend.AmazonComprehend) TaggedEntity(org.knime.ext.textprocessing.nodes.tagging.TaggedEntity) Collectors(java.util.stream.Collectors) TaggedEntity(org.knime.ext.textprocessing.nodes.tagging.TaggedEntity) DetectSyntaxRequest(com.amazonaws.services.comprehend.model.DetectSyntaxRequest) DetectSyntaxResult(com.amazonaws.services.comprehend.model.DetectSyntaxResult)

Aggregations

AmazonComprehend (com.amazonaws.services.comprehend.AmazonComprehend)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Document (org.knime.ext.textprocessing.data.Document)2 Sentence (org.knime.ext.textprocessing.data.Sentence)2 Tag (org.knime.ext.textprocessing.data.Tag)2 AbstractDocumentTagger (org.knime.ext.textprocessing.nodes.tagging.AbstractDocumentTagger)2 TaggedEntity (org.knime.ext.textprocessing.nodes.tagging.TaggedEntity)2 DetectEntitiesRequest (com.amazonaws.services.comprehend.model.DetectEntitiesRequest)1 DetectEntitiesResult (com.amazonaws.services.comprehend.model.DetectEntitiesResult)1 DetectSyntaxRequest (com.amazonaws.services.comprehend.model.DetectSyntaxRequest)1 DetectSyntaxResult (com.amazonaws.services.comprehend.model.DetectSyntaxResult)1 AmazonEntityTag (org.knime.cloud.aws.mlservices.utils.tagsets.AmazonEntityTag)1 UniversalDependenciesPOSTagSet (org.knime.ext.textprocessing.data.UniversalDependenciesPOSTagSet)1