Skip to content

Commit

Permalink
Merge branch 'logtext'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktos committed Jan 3, 2020
2 parents 74c6a9f + bf7b793 commit 307efaf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/CoyoteApi/CoyoteHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public async Task<Post> 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;
Expand Down
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 307efaf

Please sign in to comment.