Loading CheckerCorrector/Checker.java +2 −2 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class Checker { } jsonMaker.toJson("data.json"); jsonMaker.toJson("confidence_ourChecker.json"); System.out.println("##########################################################"); } Loading @@ -96,7 +96,7 @@ public class Checker { jsonMaker.addPhrase(phrase, dbInterface.checkTokenInDatabase(phrase.toLowerCase(), graph)); System.out.println("------------------------------------------------------------"); } jsonMaker.toJson("data.json"); jsonMaker.toJson("confidence_ourChecker.json"); System.out.println("##########################################################"); } Loading CheckerCorrector/samples/confidenceChecker.py 0 → 100644 +55 −0 Original line number Diff line number Diff line import json import language_tool_python def get_error_confidence(sentence): # Initialize LanguageTool tool = language_tool_python.LanguageTool('en-US') # Tokenize the sentence sentences = sentence.split(".") # Initialize dictionaries to store confidence scores for sentences and phrases sentence_confidence = {} phrase_confidence = {} # Iterate over each sentence for sent in sentences: # Calculate confidence score for the sentence sent_confidence = {"text": sent.strip()} # Check for errors in the entire sentence sent_matches = tool.check(sent.strip()) sent_confidence["confidence"] = min(len(sent_matches) * 100 / max(len(sent.split()), 1), 100) # Add confidence score for the sentence sentence_confidence[sent.strip()] = sent_confidence["confidence"] # Generate phrases of lengths 2 to 4 and calculate confidence scores words = sent.strip().split() for length in range(2, 5): for i in range(len(words) - length + 1): phrase = ' '.join(words[i:i+length]) # Check for errors in the phrase matches = tool.check(phrase) # Calculate confidence score confidence_score = len(matches) * 100 / max(len(phrase.split()), 1) # Add confidence score for the phrase phrase_confidence[phrase] = min(confidence_score, 100) return sentence_confidence, phrase_confidence # Read input from checker.txt with open("checker.txt", "r") as file: input_text = file.read() # Get confidence scores sentences_confidence, phrases_confidence = get_error_confidence(input_text) # Create JSON structure output_json = {"sentences": sentences_confidence, "phrases": phrases_confidence} # Save to a JSON file with open("confidence__pyhton3rdParty.json", "w") as json_file: json.dump(output_json, json_file, indent=2) print("JSON file saved successfully.") CheckerCorrector/samples/confidence__pyhton3rdParty.json 0 → 100644 +115 −0 Original line number Diff line number Diff line { "sentences": { "it a very good book, but it is small small book": 18.181818181818183, "it is very bad": 25.0, "I am sopistcated": 33.333333333333336, "This is so strange a word choice": 0.0, "if you good you will do it": 28.571428571428573, "this is a reminder that if you fail to complete you will pass the test": 6.666666666666667, "": 0.0 }, "phrases": { "it a": 50.0, "a very": 50.0, "very good": 50.0, "good book,": 50.0, "book, but": 50.0, "but it": 50.0, "it is": 50.0, "is small": 50.0, "small small": 50.0, "small book": 50.0, "it a very": 33.333333333333336, "a very good": 33.333333333333336, "very good book,": 33.333333333333336, "good book, but": 33.333333333333336, "book, but it": 33.333333333333336, "but it is": 33.333333333333336, "it is small": 33.333333333333336, "is small small": 66.66666666666667, "small small book": 33.333333333333336, "it a very good": 25.0, "a very good book,": 25.0, "very good book, but": 25.0, "good book, but it": 25.0, "book, but it is": 25.0, "but it is small": 25.0, "it is small small": 50.0, "is small small book": 50.0, "is very": 50.0, "very bad": 50.0, "it is very": 33.333333333333336, "is very bad": 33.333333333333336, "it is very bad": 25.0, "I am": 0.0, "am sopistcated": 100.0, "I am sopistcated": 33.333333333333336, "This is": 0.0, "is so": 50.0, "so strange": 50.0, "strange a": 50.0, "a word": 50.0, "word choice": 50.0, "This is so": 0.0, "is so strange": 33.333333333333336, "so strange a": 33.333333333333336, "strange a word": 33.333333333333336, "a word choice": 33.333333333333336, "This is so strange": 0.0, "is so strange a": 25.0, "so strange a word": 25.0, "strange a word choice": 25.0, "if you": 50.0, "you good": 50.0, "good you": 50.0, "you will": 50.0, "will do": 50.0, "do it": 50.0, "if you good": 66.66666666666667, "you good you": 33.333333333333336, "good you will": 33.333333333333336, "you will do": 33.333333333333336, "will do it": 33.333333333333336, "if you good you": 25.0, "you good you will": 25.0, "good you will do": 25.0, "you will do it": 25.0, "this is": 50.0, "is a": 50.0, "a reminder": 50.0, "reminder that": 50.0, "that if": 50.0, "you fail": 50.0, "fail to": 50.0, "to complete": 50.0, "complete you": 50.0, "will pass": 50.0, "pass the": 50.0, "the test": 50.0, "this is a": 33.333333333333336, "is a reminder": 33.333333333333336, "a reminder that": 33.333333333333336, "reminder that if": 33.333333333333336, "that if you": 33.333333333333336, "if you fail": 33.333333333333336, "you fail to": 33.333333333333336, "fail to complete": 33.333333333333336, "to complete you": 33.333333333333336, "complete you will": 33.333333333333336, "you will pass": 33.333333333333336, "will pass the": 33.333333333333336, "pass the test": 33.333333333333336, "this is a reminder": 25.0, "is a reminder that": 25.0, "a reminder that if": 25.0, "reminder that if you": 25.0, "that if you fail": 25.0, "if you fail to": 25.0, "you fail to complete": 25.0, "fail to complete you": 25.0, "to complete you will": 25.0, "complete you will pass": 25.0, "you will pass the": 25.0, "will pass the test": 25.0 } } No newline at end of file CheckerCorrector/samples/confidence_ourChecker.json 0 → 100644 +44 −0 Original line number Diff line number Diff line { "sentences": { "it a very good book, but it is small small book.": 16, "this is a reminder that if you fail to complete you will pass the test.": 67, "i am sopistcated.": 12, "if you good you will do it.": 51, "it is very bad.": 19, "this is so strange a word choice.": 16 }, "phrases": { "you good": 10, "a very good": 0, "it is": 0, "it a very good": 8, "if you": 0, "is very": 0, "it a very": 8, "am sopistcated.": 5, "this is a reminder": 19, "this is so strange": 19, "good you": 10, "a very": 0, "it is very": 19, "so strange": 0, "is a": 0, "it a": 10, "is a reminder": 19, "very bad.": 0, "this is so": 19, "if you good you": 35, "is very bad.": 0, "a reminder": 0, "it is very bad.": 19, "this is": 0, "is so strange": 0, "is so": 0, "very good": 0, "this is a": 19, "i am": 10, "i am sopistcated.": 12, "you good you": 16, "if you good": 27 } } No newline at end of file CheckerCorrector/samples/confidence_scores.json 0 → 100644 +115 −0 Original line number Diff line number Diff line { "sentences": { "it a very good book, but it is small small book": 18.181818181818183, "it is very bad": 25.0, "I am sopistcated": 33.333333333333336, "This is so strange a word choice": 0.0, "if you good you will do it": 28.571428571428573, "this is a reminder that if you fail to complete you will pass the test": 6.666666666666667, "": 0.0 }, "phrases": { "it a": 50.0, "a very": 50.0, "very good": 50.0, "good book,": 50.0, "book, but": 50.0, "but it": 50.0, "it is": 50.0, "is small": 50.0, "small small": 50.0, "small book": 50.0, "it a very": 33.333333333333336, "a very good": 33.333333333333336, "very good book,": 33.333333333333336, "good book, but": 33.333333333333336, "book, but it": 33.333333333333336, "but it is": 33.333333333333336, "it is small": 33.333333333333336, "is small small": 66.66666666666667, "small small book": 33.333333333333336, "it a very good": 25.0, "a very good book,": 25.0, "very good book, but": 25.0, "good book, but it": 25.0, "book, but it is": 25.0, "but it is small": 25.0, "it is small small": 50.0, "is small small book": 50.0, "is very": 50.0, "very bad": 50.0, "it is very": 33.333333333333336, "is very bad": 33.333333333333336, "it is very bad": 25.0, "I am": 0.0, "am sopistcated": 100.0, "I am sopistcated": 33.333333333333336, "This is": 0.0, "is so": 50.0, "so strange": 50.0, "strange a": 50.0, "a word": 50.0, "word choice": 50.0, "This is so": 0.0, "is so strange": 33.333333333333336, "so strange a": 33.333333333333336, "strange a word": 33.333333333333336, "a word choice": 33.333333333333336, "This is so strange": 0.0, "is so strange a": 25.0, "so strange a word": 25.0, "strange a word choice": 25.0, "if you": 50.0, "you good": 50.0, "good you": 50.0, "you will": 50.0, "will do": 50.0, "do it": 50.0, "if you good": 66.66666666666667, "you good you": 33.333333333333336, "good you will": 33.333333333333336, "you will do": 33.333333333333336, "will do it": 33.333333333333336, "if you good you": 25.0, "you good you will": 25.0, "good you will do": 25.0, "you will do it": 25.0, "this is": 50.0, "is a": 50.0, "a reminder": 50.0, "reminder that": 50.0, "that if": 50.0, "you fail": 50.0, "fail to": 50.0, "to complete": 50.0, "complete you": 50.0, "will pass": 50.0, "pass the": 50.0, "the test": 50.0, "this is a": 33.333333333333336, "is a reminder": 33.333333333333336, "a reminder that": 33.333333333333336, "reminder that if": 33.333333333333336, "that if you": 33.333333333333336, "if you fail": 33.333333333333336, "you fail to": 33.333333333333336, "fail to complete": 33.333333333333336, "to complete you": 33.333333333333336, "complete you will": 33.333333333333336, "you will pass": 33.333333333333336, "will pass the": 33.333333333333336, "pass the test": 33.333333333333336, "this is a reminder": 25.0, "is a reminder that": 25.0, "a reminder that if": 25.0, "reminder that if you": 25.0, "that if you fail": 25.0, "if you fail to": 25.0, "you fail to complete": 25.0, "fail to complete you": 25.0, "to complete you will": 25.0, "complete you will pass": 25.0, "you will pass the": 25.0, "will pass the test": 25.0 } } No newline at end of file Loading
CheckerCorrector/Checker.java +2 −2 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class Checker { } jsonMaker.toJson("data.json"); jsonMaker.toJson("confidence_ourChecker.json"); System.out.println("##########################################################"); } Loading @@ -96,7 +96,7 @@ public class Checker { jsonMaker.addPhrase(phrase, dbInterface.checkTokenInDatabase(phrase.toLowerCase(), graph)); System.out.println("------------------------------------------------------------"); } jsonMaker.toJson("data.json"); jsonMaker.toJson("confidence_ourChecker.json"); System.out.println("##########################################################"); } Loading
CheckerCorrector/samples/confidenceChecker.py 0 → 100644 +55 −0 Original line number Diff line number Diff line import json import language_tool_python def get_error_confidence(sentence): # Initialize LanguageTool tool = language_tool_python.LanguageTool('en-US') # Tokenize the sentence sentences = sentence.split(".") # Initialize dictionaries to store confidence scores for sentences and phrases sentence_confidence = {} phrase_confidence = {} # Iterate over each sentence for sent in sentences: # Calculate confidence score for the sentence sent_confidence = {"text": sent.strip()} # Check for errors in the entire sentence sent_matches = tool.check(sent.strip()) sent_confidence["confidence"] = min(len(sent_matches) * 100 / max(len(sent.split()), 1), 100) # Add confidence score for the sentence sentence_confidence[sent.strip()] = sent_confidence["confidence"] # Generate phrases of lengths 2 to 4 and calculate confidence scores words = sent.strip().split() for length in range(2, 5): for i in range(len(words) - length + 1): phrase = ' '.join(words[i:i+length]) # Check for errors in the phrase matches = tool.check(phrase) # Calculate confidence score confidence_score = len(matches) * 100 / max(len(phrase.split()), 1) # Add confidence score for the phrase phrase_confidence[phrase] = min(confidence_score, 100) return sentence_confidence, phrase_confidence # Read input from checker.txt with open("checker.txt", "r") as file: input_text = file.read() # Get confidence scores sentences_confidence, phrases_confidence = get_error_confidence(input_text) # Create JSON structure output_json = {"sentences": sentences_confidence, "phrases": phrases_confidence} # Save to a JSON file with open("confidence__pyhton3rdParty.json", "w") as json_file: json.dump(output_json, json_file, indent=2) print("JSON file saved successfully.")
CheckerCorrector/samples/confidence__pyhton3rdParty.json 0 → 100644 +115 −0 Original line number Diff line number Diff line { "sentences": { "it a very good book, but it is small small book": 18.181818181818183, "it is very bad": 25.0, "I am sopistcated": 33.333333333333336, "This is so strange a word choice": 0.0, "if you good you will do it": 28.571428571428573, "this is a reminder that if you fail to complete you will pass the test": 6.666666666666667, "": 0.0 }, "phrases": { "it a": 50.0, "a very": 50.0, "very good": 50.0, "good book,": 50.0, "book, but": 50.0, "but it": 50.0, "it is": 50.0, "is small": 50.0, "small small": 50.0, "small book": 50.0, "it a very": 33.333333333333336, "a very good": 33.333333333333336, "very good book,": 33.333333333333336, "good book, but": 33.333333333333336, "book, but it": 33.333333333333336, "but it is": 33.333333333333336, "it is small": 33.333333333333336, "is small small": 66.66666666666667, "small small book": 33.333333333333336, "it a very good": 25.0, "a very good book,": 25.0, "very good book, but": 25.0, "good book, but it": 25.0, "book, but it is": 25.0, "but it is small": 25.0, "it is small small": 50.0, "is small small book": 50.0, "is very": 50.0, "very bad": 50.0, "it is very": 33.333333333333336, "is very bad": 33.333333333333336, "it is very bad": 25.0, "I am": 0.0, "am sopistcated": 100.0, "I am sopistcated": 33.333333333333336, "This is": 0.0, "is so": 50.0, "so strange": 50.0, "strange a": 50.0, "a word": 50.0, "word choice": 50.0, "This is so": 0.0, "is so strange": 33.333333333333336, "so strange a": 33.333333333333336, "strange a word": 33.333333333333336, "a word choice": 33.333333333333336, "This is so strange": 0.0, "is so strange a": 25.0, "so strange a word": 25.0, "strange a word choice": 25.0, "if you": 50.0, "you good": 50.0, "good you": 50.0, "you will": 50.0, "will do": 50.0, "do it": 50.0, "if you good": 66.66666666666667, "you good you": 33.333333333333336, "good you will": 33.333333333333336, "you will do": 33.333333333333336, "will do it": 33.333333333333336, "if you good you": 25.0, "you good you will": 25.0, "good you will do": 25.0, "you will do it": 25.0, "this is": 50.0, "is a": 50.0, "a reminder": 50.0, "reminder that": 50.0, "that if": 50.0, "you fail": 50.0, "fail to": 50.0, "to complete": 50.0, "complete you": 50.0, "will pass": 50.0, "pass the": 50.0, "the test": 50.0, "this is a": 33.333333333333336, "is a reminder": 33.333333333333336, "a reminder that": 33.333333333333336, "reminder that if": 33.333333333333336, "that if you": 33.333333333333336, "if you fail": 33.333333333333336, "you fail to": 33.333333333333336, "fail to complete": 33.333333333333336, "to complete you": 33.333333333333336, "complete you will": 33.333333333333336, "you will pass": 33.333333333333336, "will pass the": 33.333333333333336, "pass the test": 33.333333333333336, "this is a reminder": 25.0, "is a reminder that": 25.0, "a reminder that if": 25.0, "reminder that if you": 25.0, "that if you fail": 25.0, "if you fail to": 25.0, "you fail to complete": 25.0, "fail to complete you": 25.0, "to complete you will": 25.0, "complete you will pass": 25.0, "you will pass the": 25.0, "will pass the test": 25.0 } } No newline at end of file
CheckerCorrector/samples/confidence_ourChecker.json 0 → 100644 +44 −0 Original line number Diff line number Diff line { "sentences": { "it a very good book, but it is small small book.": 16, "this is a reminder that if you fail to complete you will pass the test.": 67, "i am sopistcated.": 12, "if you good you will do it.": 51, "it is very bad.": 19, "this is so strange a word choice.": 16 }, "phrases": { "you good": 10, "a very good": 0, "it is": 0, "it a very good": 8, "if you": 0, "is very": 0, "it a very": 8, "am sopistcated.": 5, "this is a reminder": 19, "this is so strange": 19, "good you": 10, "a very": 0, "it is very": 19, "so strange": 0, "is a": 0, "it a": 10, "is a reminder": 19, "very bad.": 0, "this is so": 19, "if you good you": 35, "is very bad.": 0, "a reminder": 0, "it is very bad.": 19, "this is": 0, "is so strange": 0, "is so": 0, "very good": 0, "this is a": 19, "i am": 10, "i am sopistcated.": 12, "you good you": 16, "if you good": 27 } } No newline at end of file
CheckerCorrector/samples/confidence_scores.json 0 → 100644 +115 −0 Original line number Diff line number Diff line { "sentences": { "it a very good book, but it is small small book": 18.181818181818183, "it is very bad": 25.0, "I am sopistcated": 33.333333333333336, "This is so strange a word choice": 0.0, "if you good you will do it": 28.571428571428573, "this is a reminder that if you fail to complete you will pass the test": 6.666666666666667, "": 0.0 }, "phrases": { "it a": 50.0, "a very": 50.0, "very good": 50.0, "good book,": 50.0, "book, but": 50.0, "but it": 50.0, "it is": 50.0, "is small": 50.0, "small small": 50.0, "small book": 50.0, "it a very": 33.333333333333336, "a very good": 33.333333333333336, "very good book,": 33.333333333333336, "good book, but": 33.333333333333336, "book, but it": 33.333333333333336, "but it is": 33.333333333333336, "it is small": 33.333333333333336, "is small small": 66.66666666666667, "small small book": 33.333333333333336, "it a very good": 25.0, "a very good book,": 25.0, "very good book, but": 25.0, "good book, but it": 25.0, "book, but it is": 25.0, "but it is small": 25.0, "it is small small": 50.0, "is small small book": 50.0, "is very": 50.0, "very bad": 50.0, "it is very": 33.333333333333336, "is very bad": 33.333333333333336, "it is very bad": 25.0, "I am": 0.0, "am sopistcated": 100.0, "I am sopistcated": 33.333333333333336, "This is": 0.0, "is so": 50.0, "so strange": 50.0, "strange a": 50.0, "a word": 50.0, "word choice": 50.0, "This is so": 0.0, "is so strange": 33.333333333333336, "so strange a": 33.333333333333336, "strange a word": 33.333333333333336, "a word choice": 33.333333333333336, "This is so strange": 0.0, "is so strange a": 25.0, "so strange a word": 25.0, "strange a word choice": 25.0, "if you": 50.0, "you good": 50.0, "good you": 50.0, "you will": 50.0, "will do": 50.0, "do it": 50.0, "if you good": 66.66666666666667, "you good you": 33.333333333333336, "good you will": 33.333333333333336, "you will do": 33.333333333333336, "will do it": 33.333333333333336, "if you good you": 25.0, "you good you will": 25.0, "good you will do": 25.0, "you will do it": 25.0, "this is": 50.0, "is a": 50.0, "a reminder": 50.0, "reminder that": 50.0, "that if": 50.0, "you fail": 50.0, "fail to": 50.0, "to complete": 50.0, "complete you": 50.0, "will pass": 50.0, "pass the": 50.0, "the test": 50.0, "this is a": 33.333333333333336, "is a reminder": 33.333333333333336, "a reminder that": 33.333333333333336, "reminder that if": 33.333333333333336, "that if you": 33.333333333333336, "if you fail": 33.333333333333336, "you fail to": 33.333333333333336, "fail to complete": 33.333333333333336, "to complete you": 33.333333333333336, "complete you will": 33.333333333333336, "you will pass": 33.333333333333336, "will pass the": 33.333333333333336, "pass the test": 33.333333333333336, "this is a reminder": 25.0, "is a reminder that": 25.0, "a reminder that if": 25.0, "reminder that if you": 25.0, "that if you fail": 25.0, "if you fail to": 25.0, "you fail to complete": 25.0, "fail to complete you": 25.0, "to complete you will": 25.0, "complete you will pass": 25.0, "you will pass the": 25.0, "will pass the test": 25.0 } } No newline at end of file