Loading Checker/CLI.javadeleted 100644 → 0 +0 −25 Original line number Diff line number Diff line import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class CLI { public static void main(String[] args) { // Check if the correct number of arguments are passed if (args.length > 1 && "--file".equals(args[0])) { String path = args[1]; try { // Read the entire file content into a single String String content = new String(Files.readAllBytes(Paths.get(path))); // Now, you can analyze this content Checker checker = new Checker(); checker.analyze(content); } catch (IOException e) { // Handle exceptions, like file not found System.err.println("Error reading file: " + e.getMessage()); } } else { System.out.println("Invalid arguments. Usage: CLI --file [path]"); } } } Checker/Checker.java +32 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,36 @@ public class Checker { Map<String, Integer> sentenceScores = detector.analyzeSentences(sentences); Map<String, Integer> phraseScores = detector.analyzePhrases(sentences); // Output results // Output results in JSON format System.out.println("{"); System.out.println("\"sentences\": " + sentenceScores + ","); System.ou No newline at end of file System.out.println("\"sentences\": " + mapToJson(sentenceScores) + ","); System.out.println("\"phrases\": " + mapToJson(phraseScores)); System.out.println("}"); } private static String mapToJson(Map<String, Integer> map) { StringBuilder jsonBuilder = new StringBuilder("{"); for (Map.Entry<String, Integer> entry : map.entrySet()) { jsonBuilder.append("\"" + entry.getKey() + "\": " + entry.getValue() + ","); } jsonBuilder.deleteCharAt(jsonBuilder.length() - 1); // remove last comma jsonBuilder.append("}"); return jsonBuilder.toString(); } public static void main(String[] args) { if (args.length > 1 && "--file".equals(args[0])) { // check syntax String path = args[1]; try { // Read entire file String content = new String(Files.readAllBytes(Paths.get(path))); Checker checker = new Checker(); // Run checker checker.analyze(content); } catch (IOException e) { System.err.println("Error reading file: " + e.getMessage()); } } else { System.out.println("Invalid arguments. Usage: CLI --file [path]"); } } } Loading
Checker/CLI.javadeleted 100644 → 0 +0 −25 Original line number Diff line number Diff line import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class CLI { public static void main(String[] args) { // Check if the correct number of arguments are passed if (args.length > 1 && "--file".equals(args[0])) { String path = args[1]; try { // Read the entire file content into a single String String content = new String(Files.readAllBytes(Paths.get(path))); // Now, you can analyze this content Checker checker = new Checker(); checker.analyze(content); } catch (IOException e) { // Handle exceptions, like file not found System.err.println("Error reading file: " + e.getMessage()); } } else { System.out.println("Invalid arguments. Usage: CLI --file [path]"); } } }
Checker/Checker.java +32 −3 Original line number Diff line number Diff line Loading @@ -12,7 +12,36 @@ public class Checker { Map<String, Integer> sentenceScores = detector.analyzeSentences(sentences); Map<String, Integer> phraseScores = detector.analyzePhrases(sentences); // Output results // Output results in JSON format System.out.println("{"); System.out.println("\"sentences\": " + sentenceScores + ","); System.ou No newline at end of file System.out.println("\"sentences\": " + mapToJson(sentenceScores) + ","); System.out.println("\"phrases\": " + mapToJson(phraseScores)); System.out.println("}"); } private static String mapToJson(Map<String, Integer> map) { StringBuilder jsonBuilder = new StringBuilder("{"); for (Map.Entry<String, Integer> entry : map.entrySet()) { jsonBuilder.append("\"" + entry.getKey() + "\": " + entry.getValue() + ","); } jsonBuilder.deleteCharAt(jsonBuilder.length() - 1); // remove last comma jsonBuilder.append("}"); return jsonBuilder.toString(); } public static void main(String[] args) { if (args.length > 1 && "--file".equals(args[0])) { // check syntax String path = args[1]; try { // Read entire file String content = new String(Files.readAllBytes(Paths.get(path))); Checker checker = new Checker(); // Run checker checker.analyze(content); } catch (IOException e) { System.err.println("Error reading file: " + e.getMessage()); } } else { System.out.println("Invalid arguments. Usage: CLI --file [path]"); } } }