Loading CheckerCorrector/DBinterface/DBinterface.java +1 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public class DBinterface { int confidence = SM.isStateMachineFollowed(graph, actions, initialState, initialConf); //System.out.print("The confidence score is: "+ confidence + "\n"); return confidence; return ((int)((double)confidence*100.0/(actions.size()*15))); } catch (SQLException e) { e.printStackTrace(); } Loading CheckerCorrector/GUI/HighlighterGUI.java +25 −12 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ import javax.swing.text.DefaultHighlighter; import DBinterface.DBinterface; import DirectedGraph.BasicGraph; import HashTableMaker.HashTableMaker; import java.sql.SQLException; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; Loading Loading @@ -52,7 +54,7 @@ public class HighlighterGUI extends JFrame { private List<String> extractPhrases(String text, int phraseLength) { List<String> phrases = new ArrayList<>(); String[] words = text.split("\\s+"); for (int i = 0; i <= words.length - phraseLength; i+=phraseLength) { for (int i = 0; i <= words.length - phraseLength; i+=1) { StringBuilder phraseBuilder = new StringBuilder(); for (int j = 0; j < phraseLength; j++) { phraseBuilder.append(words[i + j]); Loading @@ -66,21 +68,32 @@ public class HighlighterGUI extends JFrame { } private void highlightPhrases(List<String> phrases) { try{ DBinterface dbInterface; HashTableMaker manager; if(!this.isDutch){ dbInterface = new DBinterface("SQLite/token_database_english.db", "SQLite/smallDic.txt"); manager = new HashTableMaker("SQLite/hash_database_english.db"); }else{ dbInterface = new DBinterface("SQLite/token_database_dutch.db", "SQLite/DutchTranslation.txt"); manager = new HashTableMaker("SQLite/hash_database_dutch.db"); } BasicGraph basicGraphClass = new BasicGraph(); for (String phrase : phrases) { highlightPhrase(phrase, dbInterface.checkTokenInDatabase(phrase, basicGraphClass.getGraph())); double conf = dbInterface.checkTokenInDatabase(phrase, basicGraphClass.getGraph())*0.8; conf += manager.nGram(phrase, 3)*0.2; //System.out.println(phrase + "| "+ conf); highlightPhrase(phrase, (int)conf); } } catch (SQLException e) { e.printStackTrace(); } } private Color getColorForNumber(int number) { float hue = (float) number / 100; // Hue ranges from 0 to 1 return Color.getHSBColor(hue, 1, 1); float hue = ((float) number / 100); // Hue ranges from 0 to 1 //System.out.println(hue); return Color.getHSBColor(0, hue, 1); } private void highlightPhrase(String phrase, int colorInd) { Loading Loading
CheckerCorrector/DBinterface/DBinterface.java +1 −1 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public class DBinterface { int confidence = SM.isStateMachineFollowed(graph, actions, initialState, initialConf); //System.out.print("The confidence score is: "+ confidence + "\n"); return confidence; return ((int)((double)confidence*100.0/(actions.size()*15))); } catch (SQLException e) { e.printStackTrace(); } Loading
CheckerCorrector/GUI/HighlighterGUI.java +25 −12 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ import javax.swing.text.DefaultHighlighter; import DBinterface.DBinterface; import DirectedGraph.BasicGraph; import HashTableMaker.HashTableMaker; import java.sql.SQLException; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; Loading Loading @@ -52,7 +54,7 @@ public class HighlighterGUI extends JFrame { private List<String> extractPhrases(String text, int phraseLength) { List<String> phrases = new ArrayList<>(); String[] words = text.split("\\s+"); for (int i = 0; i <= words.length - phraseLength; i+=phraseLength) { for (int i = 0; i <= words.length - phraseLength; i+=1) { StringBuilder phraseBuilder = new StringBuilder(); for (int j = 0; j < phraseLength; j++) { phraseBuilder.append(words[i + j]); Loading @@ -66,21 +68,32 @@ public class HighlighterGUI extends JFrame { } private void highlightPhrases(List<String> phrases) { try{ DBinterface dbInterface; HashTableMaker manager; if(!this.isDutch){ dbInterface = new DBinterface("SQLite/token_database_english.db", "SQLite/smallDic.txt"); manager = new HashTableMaker("SQLite/hash_database_english.db"); }else{ dbInterface = new DBinterface("SQLite/token_database_dutch.db", "SQLite/DutchTranslation.txt"); manager = new HashTableMaker("SQLite/hash_database_dutch.db"); } BasicGraph basicGraphClass = new BasicGraph(); for (String phrase : phrases) { highlightPhrase(phrase, dbInterface.checkTokenInDatabase(phrase, basicGraphClass.getGraph())); double conf = dbInterface.checkTokenInDatabase(phrase, basicGraphClass.getGraph())*0.8; conf += manager.nGram(phrase, 3)*0.2; //System.out.println(phrase + "| "+ conf); highlightPhrase(phrase, (int)conf); } } catch (SQLException e) { e.printStackTrace(); } } private Color getColorForNumber(int number) { float hue = (float) number / 100; // Hue ranges from 0 to 1 return Color.getHSBColor(hue, 1, 1); float hue = ((float) number / 100); // Hue ranges from 0 to 1 //System.out.println(hue); return Color.getHSBColor(0, hue, 1); } private void highlightPhrase(String phrase, int colorInd) { Loading