chore: init project
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using InboxIntel.Application.Abstractions;
|
||||
using InboxIntel.Domain.Enums;
|
||||
|
||||
namespace InboxIntel.Infrastructure.Sync;
|
||||
|
||||
/// <summary>
|
||||
/// Fast, dependency-free first-pass classifier applied during sync. The AI
|
||||
/// layer can later refine these labels, but this guarantees every email has a
|
||||
/// sensible category even when AI is disabled.
|
||||
/// </summary>
|
||||
public static class HeuristicClassifier
|
||||
{
|
||||
private static readonly string[] FinanceHints = { "invoice", "receipt", "payment", "statement", "bank", "transaction", "billing" };
|
||||
private static readonly string[] SocialHints = { "facebook", "twitter", "linkedin", "instagram", "tiktok" };
|
||||
private static readonly string[] NoReplyHints = { "noreply", "no-reply", "donotreply", "newsletter", "mailer", "notifications" };
|
||||
|
||||
public static EmailCategory Classify(GmailMessageDetail d)
|
||||
{
|
||||
var subject = (d.Subject ?? string.Empty).ToLowerInvariant();
|
||||
var from = d.FromAddress.ToLowerInvariant();
|
||||
|
||||
if (d.HasListUnsubscribe) return EmailCategory.Newsletter;
|
||||
if (FinanceHints.Any(h => subject.Contains(h))) return EmailCategory.Finance;
|
||||
if (SocialHints.Any(h => from.Contains(h))) return EmailCategory.Social;
|
||||
if (NoReplyHints.Any(h => from.Contains(h))) return EmailCategory.Notification;
|
||||
return EmailCategory.Personal;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user