From b863c3b21e08e4038e6e74edc51c3264fc687c20 Mon Sep 17 00:00:00 2001 From: Lemon73-Computing Date: Sat, 27 Apr 2024 14:55:16 +0900 Subject: [PATCH 1/2] change: api bug - showing emotion of `- perple-name / emotion` is not working --- AliceConsole/Program.cs | 2 +- AnovSyntax/Anov.cs | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/AliceConsole/Program.cs b/AliceConsole/Program.cs index 9b3522c..b348353 100644 --- a/AliceConsole/Program.cs +++ b/AliceConsole/Program.cs @@ -11,7 +11,7 @@ if (line == "") Console.ReadLine(); else if (line is not null) - Anov.Read(line); + Console.WriteLine(Anov.Read(line)); } Console.ReadLine(); } diff --git a/AnovSyntax/Anov.cs b/AnovSyntax/Anov.cs index e137827..12c6f60 100644 --- a/AnovSyntax/Anov.cs +++ b/AnovSyntax/Anov.cs @@ -8,7 +8,7 @@ public class Anov /// Read the text in anov syntax. /// /// The text in anov syntax - public static void Read(string str) + public static string Read(string str) { Match match; @@ -16,40 +16,42 @@ public static void Read(string str) // Read "> place" match = Regex.Match(str, @"> (.*)"); if (match.Success) - Console.WriteLine(""); + return(""); // Unsupported // Read "bgm: background-music" match = Regex.Match(str, @"bgm: (.*)"); if (match.Success) - Console.WriteLine(""); + return(""); // Unsupported // Read "movie: movie" match = Regex.Match(str, @"movie: (.*)"); if (match.Success) - Console.WriteLine(""); + return(""); // Read "- people-name / emotion" match = Regex.Match(str, @"- (.*?)/"); if (match.Success) - Console.Write(match.Groups[1].Value.Trim()); + return(match.Groups[1].Value.Trim()); else { // Read "- people-name" match = Regex.Match(str, @"- (.*)"); if (match.Success) - Console.Write(match.Groups[1].Value.Trim()); + return(match.Groups[1].Value.Trim()); } // Read "/ emotion" match = Regex.Match(str, @"/ (.*)"); if (match.Success) - Console.Write(" (" + match.Groups[1].Value.Trim() + ")"); + return(" (" + match.Groups[1].Value.Trim() + ")"); // Read "[conversatioc-content]" match = Regex.Match(str, @"\[(.*?)\]"); if (match.Success) - Console.WriteLine(" \"" + match.Groups[1].Value.Trim() + "\""); + return(" \"" + match.Groups[1].Value.Trim() + "\""); + + return(""); } } From fcb75f3a4a39acbc45dc71f2f1168ebb8ea29a62 Mon Sep 17 00:00:00 2001 From: Lemon73-Computing Date: Sat, 27 Apr 2024 17:19:11 +0900 Subject: [PATCH 2/2] change: out put method (fix bug that was not working on `- people-name / emotion`) --- AnovSyntax/Anov.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/AnovSyntax/Anov.cs b/AnovSyntax/Anov.cs index 12c6f60..7ebd0a7 100644 --- a/AnovSyntax/Anov.cs +++ b/AnovSyntax/Anov.cs @@ -11,47 +11,48 @@ public class Anov public static string Read(string str) { Match match; + string _return = ""; // Unsupported // Read "> place" match = Regex.Match(str, @"> (.*)"); if (match.Success) - return(""); + _return += ""; // Unsupported // Read "bgm: background-music" match = Regex.Match(str, @"bgm: (.*)"); if (match.Success) - return(""); + _return += ""; // Unsupported // Read "movie: movie" match = Regex.Match(str, @"movie: (.*)"); if (match.Success) - return(""); + _return += ""; // Read "- people-name / emotion" match = Regex.Match(str, @"- (.*?)/"); if (match.Success) - return(match.Groups[1].Value.Trim()); + _return += match.Groups[1].Value.Trim(); else { // Read "- people-name" match = Regex.Match(str, @"- (.*)"); if (match.Success) - return(match.Groups[1].Value.Trim()); + _return += match.Groups[1].Value.Trim(); } // Read "/ emotion" match = Regex.Match(str, @"/ (.*)"); if (match.Success) - return(" (" + match.Groups[1].Value.Trim() + ")"); + _return += " (" + match.Groups[1].Value.Trim() + ")"; // Read "[conversatioc-content]" match = Regex.Match(str, @"\[(.*?)\]"); if (match.Success) - return(" \"" + match.Groups[1].Value.Trim() + "\""); + _return += " \"" + match.Groups[1].Value.Trim() + "\""; - return(""); + return _return; } }