diff --git a/src/Bot.cs b/src/Bot.cs index c1b2b6f..a65e14d 100644 --- a/src/Bot.cs +++ b/src/Bot.cs @@ -184,7 +184,7 @@ public async Task AnalyzePostAsync(Post post) if (problems.Count > 0) { - logger.LogInformation("Found problems in post {0}\n{1}\n{2}", post.id, post.url, post.text.Length < 50 ? post.text : post.text.Substring(0, 50)); + logger.LogInformation("Found problems in post {0}\n{1}", post.id, post.url); foreach (var item in problems) { logger.LogDebug(item.ToString()); diff --git a/src/CoyoteApi/CoyoteHandler.cs b/src/CoyoteApi/CoyoteHandler.cs index caaefcb..967bd15 100644 --- a/src/CoyoteApi/CoyoteHandler.cs +++ b/src/CoyoteApi/CoyoteHandler.cs @@ -179,7 +179,8 @@ public async Task GetSinglePost(int postId) text = result.data.text, topic_id = result.data.topic_id, user = result.data.user, - user_name = result.data.user_name + user_name = result.data.user_name, + url = result.data.url }; return post; diff --git a/src/PostAnalyzer.cs b/src/PostAnalyzer.cs index 811bda3..2cbe137 100644 --- a/src/PostAnalyzer.cs +++ b/src/PostAnalyzer.cs @@ -31,6 +31,7 @@ using Eleia.ML; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Linq; @@ -85,7 +86,7 @@ private NotFormattedCodeFound CheckForUnformattedCode(CoyoteApi.Post post) if (result.Prediction && result.Probability > codeDetectorTreshold) { - return new NotFormattedCodeFound { Probability = result.Probability }; + return new NotFormattedCodeFound { Probability = result.Probability, Paragraph = para }; } } diff --git a/src/PostProblems.cs b/src/PostProblems.cs index 286258e..aed62d1 100644 --- a/src/PostProblems.cs +++ b/src/PostProblems.cs @@ -38,6 +38,7 @@ namespace Eleia public abstract class PostProblems { public float Probability { get; set; } + public string Paragraph { get; set; } } /// @@ -47,7 +48,7 @@ public class NotFormattedCodeFound : PostProblems { public override string ToString() { - return $"Potentially not formatted code found (prob: {Probability})"; + return $"Potentially not formatted code found (prob: {Probability}) in: {Paragraph}"; } } } \ No newline at end of file diff --git a/test/PostAnalyzerTests.cs b/test/PostAnalyzerTests.cs index 306261d..c6d71dd 100644 --- a/test/PostAnalyzerTests.cs +++ b/test/PostAnalyzerTests.cs @@ -119,9 +119,10 @@ public void Analyze_PostWithUnformattedCodeThreshold097_UnformattedCodeFound() [Fact] public void NotFormattedCodeFoundToString_WithValue_ShouldReturnProbabilityInText() { - var pp = new NotFormattedCodeFound { Probability = 0.123f }; + var pp = new NotFormattedCodeFound { Probability = 0.123f, Paragraph = "lorem" }; Assert.Contains("123", pp.ToString()); + Assert.Contains("lorem", pp.ToString()); } } } \ No newline at end of file