Loading DirectedGraph/BasicGraph.java +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ public class BasicGraph { graph.addEdge(State.ARTICLE, State.ADJECTIVE); graph.addEdge(State.ADJECTIVE, State.DOT); graph.addEdge(State.ADJECTIVE, State.NOUN); graph.addEdge(State.ADJECTIVE, State.COMMA); graph.addEdge(State.NOUN, State.DOT); graph.addEdge(State.NOUN, State.COMMA); graph.addEdge(State.DOT, State.END); Loading Main.java +8 −10 Original line number Diff line number Diff line Loading @@ -4,19 +4,16 @@ import DirectedGraph.BasicGraph; import DirectedGraph.DirectedGraph; import StateMachine.*; import DBinterface.DBinterface; import util.*; public class Main { public static void main(String[] args) { //DirectedGraph<State> graph = new DirectedGraph<>(); String sentence; if(args.length > 0){ sentence = args[0]; }else{ sentence = "it a very good book, but it is small book."; System.out.println("Please enter a sentence. Program used the default sentence:\n" + sentence + "\n--------------------------------------------"); } ArgumentParser argPars = ArgumentParser.of(args);; if(argPars.isCheckSentence()){ BasicGraph basicGraphClass = new BasicGraph(); DirectedGraph<State> graph = basicGraphClass.getGraph(); Loading @@ -26,7 +23,8 @@ public class Main { // Tokenize the sentence DBinterface dbInterface = new DBinterface(); dbInterface.checkTokenInDatabase(sentence, graph); dbInterface.checkTokenInDatabase(argPars.getSentence(), graph); } } } Loading SQLite/mydatabase.db (12 KiB) File changed.No diff preview for this file type. View original file View changed file StateMachine/StateMachine.java +5 −0 Original line number Diff line number Diff line Loading @@ -6,13 +6,18 @@ import DirectedGraph.DirectedGraph; public class StateMachine{ public int isStateMachineFollowed(DirectedGraph<State> graph, List<State> actions, State initialState, int initialConf) { int confidence = initialConf; //System.out.println("----------------------------------------------------"); State currentState = initialState; for (State action : actions) { //System.out.print(currentState); List<State> transitions = graph.getAdjacentNodes(currentState); if (!transitions.contains(action)) { //System.out.print("? " + action); currentState = State.START; confidence += 10; // Action not allowed in current state } //System.out.println(); currentState = action; // Transition to the next state } return confidence; Loading checker.jar +1.27 KiB (13.5 MiB) File changed.No diff preview for this file type. View original file View changed file Loading
DirectedGraph/BasicGraph.java +1 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ public class BasicGraph { graph.addEdge(State.ARTICLE, State.ADJECTIVE); graph.addEdge(State.ADJECTIVE, State.DOT); graph.addEdge(State.ADJECTIVE, State.NOUN); graph.addEdge(State.ADJECTIVE, State.COMMA); graph.addEdge(State.NOUN, State.DOT); graph.addEdge(State.NOUN, State.COMMA); graph.addEdge(State.DOT, State.END); Loading
Main.java +8 −10 Original line number Diff line number Diff line Loading @@ -4,19 +4,16 @@ import DirectedGraph.BasicGraph; import DirectedGraph.DirectedGraph; import StateMachine.*; import DBinterface.DBinterface; import util.*; public class Main { public static void main(String[] args) { //DirectedGraph<State> graph = new DirectedGraph<>(); String sentence; if(args.length > 0){ sentence = args[0]; }else{ sentence = "it a very good book, but it is small book."; System.out.println("Please enter a sentence. Program used the default sentence:\n" + sentence + "\n--------------------------------------------"); } ArgumentParser argPars = ArgumentParser.of(args);; if(argPars.isCheckSentence()){ BasicGraph basicGraphClass = new BasicGraph(); DirectedGraph<State> graph = basicGraphClass.getGraph(); Loading @@ -26,7 +23,8 @@ public class Main { // Tokenize the sentence DBinterface dbInterface = new DBinterface(); dbInterface.checkTokenInDatabase(sentence, graph); dbInterface.checkTokenInDatabase(argPars.getSentence(), graph); } } } Loading
SQLite/mydatabase.db (12 KiB) File changed.No diff preview for this file type. View original file View changed file
StateMachine/StateMachine.java +5 −0 Original line number Diff line number Diff line Loading @@ -6,13 +6,18 @@ import DirectedGraph.DirectedGraph; public class StateMachine{ public int isStateMachineFollowed(DirectedGraph<State> graph, List<State> actions, State initialState, int initialConf) { int confidence = initialConf; //System.out.println("----------------------------------------------------"); State currentState = initialState; for (State action : actions) { //System.out.print(currentState); List<State> transitions = graph.getAdjacentNodes(currentState); if (!transitions.contains(action)) { //System.out.print("? " + action); currentState = State.START; confidence += 10; // Action not allowed in current state } //System.out.println(); currentState = action; // Transition to the next state } return confidence; Loading
checker.jar +1.27 KiB (13.5 MiB) File changed.No diff preview for this file type. View original file View changed file