feat: implement AI-driven knowledge extraction service with semantic caching and persistent storage

This commit is contained in:
2026-04-26 08:51:46 +02:00
parent 59074a05a0
commit d8e6931289
13 changed files with 423 additions and 3 deletions
@@ -0,0 +1,37 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
namespace NexusReader.Infrastructure.Helpers;
public static class ContentHasher
{
public static string ComputeHash(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
return string.Empty;
}
var normalizedInput = Normalize(input);
var inputBytes = Encoding.UTF8.GetBytes(normalizedInput);
var hashBytes = SHA256.HashData(inputBytes);
return Convert.ToHexString(hashBytes).ToLowerInvariant();
}
public static string Normalize(string input)
{
if (string.IsNullOrWhiteSpace(input))
{
return string.Empty;
}
// Trim and collapse all consecutive whitespace characters into a single space
var normalized = Regex.Replace(input.Trim(), @"\s+", " ");
// Convert to lower-case as AI analysis is generally not case-sensitive for concepts/quizzes
return normalized.ToLowerInvariant();
}
}