This commit is contained in:
parent
19c32468df
commit
2fb22d70fe
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
@ -8,6 +8,7 @@
|
||||
"type": "java",
|
||||
"name": "Launch Java Program",
|
||||
"request": "launch",
|
||||
"vmArgs": "-Xmx4G -Xms1024m",
|
||||
"mainClass": ""
|
||||
},
|
||||
{
|
||||
|
||||
23
pom.xml
23
pom.xml
@ -12,6 +12,7 @@
|
||||
<dl4j-master.version>1.0.0-M2</dl4j-master.version>
|
||||
<!-- Change the nd4j.backend property to nd4j-cuda-X-platform to use CUDA GPUs -->
|
||||
<nd4j.backend>nd4j-native</nd4j.backend>
|
||||
<corenlp.version>4.5.6</corenlp.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -46,6 +47,28 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--Stanford CoreNLP-->
|
||||
<!--License: GPL-->
|
||||
<dependency>
|
||||
<groupId>edu.stanford.nlp</groupId>
|
||||
<artifactId>stanford-corenlp</artifactId>
|
||||
<version>${corenlp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>edu.stanford.nlp</groupId>
|
||||
<artifactId>stanford-corenlp</artifactId>
|
||||
<version>${corenlp.version}</version>
|
||||
<classifier>models</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>edu.stanford.nlp</groupId>
|
||||
<artifactId>stanford-corenlp</artifactId>
|
||||
<version>${corenlp.version}</version>
|
||||
<classifier>models-english</classifier>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--GSON-->
|
||||
<dependency>
|
||||
|
||||
@ -4,6 +4,7 @@ import java.io.File;
|
||||
|
||||
import org.studiorailgun.conversation.categorization.SentenceFunctionCategorizor;
|
||||
import org.studiorailgun.conversation.evaluators.greet.GreetingEval;
|
||||
import org.studiorailgun.conversation.parser.NLPParser;
|
||||
import org.studiorailgun.conversation.tracking.Conversation;
|
||||
import org.studiorailgun.knowledge.KnowledgeWeb;
|
||||
|
||||
@ -30,6 +31,9 @@ public class Globals {
|
||||
GreetingEval.init();
|
||||
SentenceFunctionCategorizor.init();
|
||||
|
||||
//init nlp parser
|
||||
NLPParser.init();
|
||||
|
||||
//init web
|
||||
Globals.web = FileUtils.loadObjectFromFile(new File(webPath), KnowledgeWeb.class);
|
||||
Globals.web.initLinks();
|
||||
|
||||
@ -3,7 +3,7 @@ package org.studiorailgun.conversation;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.studiorailgun.Globals;
|
||||
import org.studiorailgun.conversation.parser.CommandParser;
|
||||
import org.studiorailgun.conversation.command.CommandParser;
|
||||
import org.studiorailgun.conversation.tracking.Quote;
|
||||
|
||||
public class AgentLoop {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.studiorailgun.conversation.parser;
|
||||
package org.studiorailgun.conversation.command;
|
||||
|
||||
import org.studiorailgun.conversation.AgentLoop;
|
||||
import org.studiorailgun.conversation.llm.LLMLoop;
|
||||
|
||||
@ -2,7 +2,7 @@ package org.studiorailgun.conversation.llm;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.studiorailgun.conversation.parser.CommandParser;
|
||||
import org.studiorailgun.conversation.command.CommandParser;
|
||||
import org.studiorailgun.kobold.KoboldPrinter;
|
||||
import org.studiorailgun.kobold.KoboldRequest;
|
||||
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package org.studiorailgun.conversation.parser;
|
||||
|
||||
import edu.stanford.nlp.coref.data.CorefChain;
|
||||
import edu.stanford.nlp.ling.*;
|
||||
import edu.stanford.nlp.ie.util.*;
|
||||
import edu.stanford.nlp.pipeline.*;
|
||||
import edu.stanford.nlp.semgraph.*;
|
||||
import edu.stanford.nlp.trees.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Parses a sentence
|
||||
*/
|
||||
public class NLPParser {
|
||||
|
||||
public static String text = "Joe Smith was born in California. " +
|
||||
"In 2017, he went to Paris, France in the summer. " +
|
||||
"His flight left at 3:00pm on July 10th, 2017. " +
|
||||
"After eating some escargot for the first time, Joe said, \"That was delicious!\" " +
|
||||
"He sent a postcard to his sister Jane Smith. " +
|
||||
"After hearing about Joe's trip, Jane decided she might go to France one day.";
|
||||
|
||||
static StanfordCoreNLP pipeline;
|
||||
|
||||
/**
|
||||
* Initializes the part-of-speech Parser
|
||||
*/
|
||||
public static void init(){
|
||||
// set up pipeline properties
|
||||
Properties props = new Properties();
|
||||
// set the list of annotators to run
|
||||
props.setProperty("annotators", "tokenize,pos,lemma,ner,parse,depparse,coref,kbp,quote");
|
||||
// set a property for an annotator, in this case the coref annotator is being set to use the neural algorithm
|
||||
props.setProperty("coref.algorithm", "neural");
|
||||
// build pipeline
|
||||
pipeline = new StanfordCoreNLP(props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the input sentence
|
||||
* @param input The input sentence
|
||||
*/
|
||||
public static void parse(String input){
|
||||
// create a document object
|
||||
CoreDocument document = new CoreDocument(text);
|
||||
// annnotate the document
|
||||
pipeline.annotate(document);
|
||||
|
||||
//TODO: grab information from document here
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user