Skip to content

Commit

Permalink
Add logging in that text the post problem was found
Browse files Browse the repository at this point in the history
  • Loading branch information
ktos committed Jan 3, 2020
1 parent 74c6a9f commit 56e6abd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/PostAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

using Eleia.ML;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -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 };
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/PostProblems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Eleia
public abstract class PostProblems
{
public float Probability { get; set; }
public string Paragraph { get; set; }
}

/// <summary>
Expand All @@ -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}";
}
}
}
3 changes: 2 additions & 1 deletion test/PostAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit 56e6abd

Please sign in to comment.