Symphony OpenNLP Client

Symphony OpenNLP Client provided by Symphony Platform Solutions team

License

License

Categories

Categories

Java Languages ORM Data
GroupId

GroupId

com.symphony.platformsolutions
ArtifactId

ArtifactId

symphony-opennlp-java
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Symphony OpenNLP Client
Symphony OpenNLP Client provided by Symphony Platform Solutions team
Project URL

Project URL

https://github.com/SymphonyPlatformSolutions/symphony-opennlp-java
Source Code Management

Source Code Management

https://github.com/SymphonyPlatformSolutions/symphony-opennlp-java

Download symphony-opennlp-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.symphony.platformsolutions/symphony-opennlp-java/ -->
<dependency>
    <groupId>com.symphony.platformsolutions</groupId>
    <artifactId>symphony-opennlp-java</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.symphony.platformsolutions/symphony-opennlp-java/
implementation 'com.symphony.platformsolutions:symphony-opennlp-java:1.0.2'
// https://jarcasting.com/artifacts/com.symphony.platformsolutions/symphony-opennlp-java/
implementation ("com.symphony.platformsolutions:symphony-opennlp-java:1.0.2")
'com.symphony.platformsolutions:symphony-opennlp-java:jar:1.0.2'
<dependency org="com.symphony.platformsolutions" name="symphony-opennlp-java" rev="1.0.2">
  <artifact name="symphony-opennlp-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.symphony.platformsolutions', module='symphony-opennlp-java', version='1.0.2')
)
libraryDependencies += "com.symphony.platformsolutions" % "symphony-opennlp-java" % "1.0.2"
[com.symphony.platformsolutions/symphony-opennlp-java "1.0.2"]

Dependencies

compile (3)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.9.9.2
org.slf4j : slf4j-api jar 1.7.25
org.apache.opennlp : opennlp-tools jar 1.9.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

symphony-opennlp-java

Library for integration with openNLP for Symphony bots Given a message and a file with a list of patterns, returns a list of actions and any given parameters found.

Install using maven

    <dependency>
        <groupId>com.symphony.platformsolutions</groupId>
        <artifactId>symphony-opennlp-java</artifactId>
        <version>1.0.0</version>
    </dependency>

Configuration

Create a nlp-config.json file in your project which includes the following properties

{
  "posmodelPath": "full path to OpenNLP POS model",
  "sentenceSplitterModelPath": "full path to OpenNLP Sentence model",
  "patternsFile": "full path to your patterns.json file"
}

Create a patterns.json file. It defines a list of patterns to be mapped into actions. For example:

[
  {"action":"buyShares",
    "posrequirementList":[
      {"options":["buy","purchase"],"parameter":null,"pos":"V"},
      {"options":null,"parameter":"quantity","pos":"CD"},
      {"options":["shares","stock"],"parameter":null,"pos":"NN"},
      {"options":null,"parameter":null,"pos":"IN"},
      {"options":null,"parameter":"product","pos":"NN"}]
  },
  {"action":"buyShares",
    "posrequirementList":[
      {"options":["buy","purchase"],"parameter":null,"pos":"V"},
      {"options":null,"parameter":"product","pos":"NN"},
      {"options":null,"parameter":"quantity","pos":"CD"}]
  },
  {"action":"buyShares",
    "posrequirementList":[
      {"options":["buy","purchase"],"parameter":null,"pos":"V"},
      {"options":null,"parameter":"product","pos":"*"},
      {"options":null,"parameter":"quantity","pos":"CD"}]
  },
  {"action":"buyShares",
    "posrequirementList":[
      {"options":["buy","purchase"],"parameter":null,"pos":"V"},
      {"options":null,"parameter":"quantity","pos":"CD"},
      {"options":null,"parameter":"product","pos":"NN"}]
  },
  {"action": "decision",
  "posrequirementList":[{"pos":"UH","options":["yes","yeah","sure","yep","confirm","y"],"parameter":"decisionBool", "value": "true"}]
  },
  {"action": "decision",
    "posrequirementList":[{"pos":"UH","options":["no","nope","reject","n"],"parameter":"decisionBool", "value": "false"}]
  },
  {"action":"headlines",
    "posrequirementList":[
      {"options":["headlines","news","articles"],"parameter":null,"pos":"NN"},
      {"options":null,"parameter":null,"pos":"*"},
      {"options":null,"parameter":"product","pos":"NN"}]
  },
  {"action":"headlines",
    "posrequirementList":[
      {"options":null,"parameter":"product","pos":"NN"},
      {"options":["headlines","news","articles"],"parameter":null,"pos":"NN"}
      ]
  }
]

For each Pattern object:

  • action is the name of the action to be mapped to, many patterns can match the same action
  • posrequirementList is the list of Parts of speech requiements for the pattern
    • options (optional) defines a specific list of words that the POS needs to match to fit the pattern
    • paramater (optional) defines the name of the pafamater that the value of this POS would fill
    • pos (required) defines the POS to match for, or * for any POS in that position For a list of POS click here

How to use in your bot code:

URL nlpUrl = getClass().getResource("nlp-config.json");
NLPConfig nlpConfig = NLPConfigLoader.loadFromFile(nlpUrl.getPath());
NLPService nlp = new NLPService(nlpConfig);
List<Action> actions = nlp.match(inboundMessage.getMessageText());
com.symphony.platformsolutions

Symphony Platform Solutions

Symphony supported software client, bots, apps, and examples.

Versions

Version
1.0.2
1.0.1
1.0.0