Skip to content

Commit 9240b6c

Browse files
committed
Add option for only exact matches
1 parent abd1cef commit 9240b6c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

BingusApi/Controllers/FaqController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public FaqController(FaqHandler faqHandler, BingusConfig bingusConfig, FaqConfig
2626
_faqHandler = faqHandler;
2727
_bingusConfig = bingusConfig;
2828
_faqConfig = faqConfig;
29-
_faqDict = bingusConfig.UseQ2A ? new FaqDict(faqConfig) : null;
29+
_faqDict = new FaqDict(faqConfig);
3030
}
3131

3232
private static FaqEntry GetEntry(ILazyItem<float[]> item)

BingusLib/FaqHandling/FaqConfig.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public record FaqConfigEntry
2020
[JsonPropertyName("questions")]
2121
public string[] Questions { get; set; } = [];
2222

23+
[JsonPropertyName("exact_only")]
24+
public bool ExactOnly { get; set; } = false;
25+
2326
public FaqConfigEntry() { }
2427

2528
public FaqConfigEntry(string answer)
@@ -54,10 +57,15 @@ IEnumerable<string> questions
5457
return null;
5558
}
5659

57-
public IEnumerable<(string title, string question, string answer)> QaEntryEnumerator()
60+
public IEnumerable<(string title, string question, string answer)> QaEntryEnumerator(
61+
bool noExactOnly = true
62+
)
5863
{
5964
foreach (var entry in FaqEntries)
6065
{
66+
if (noExactOnly && entry.ExactOnly)
67+
continue;
68+
6169
foreach (var keyword in entry.Keywords)
6270
{
6371
yield return (entry.Title, keyword, entry.Answer);
@@ -70,10 +78,15 @@ IEnumerable<string> questions
7078
}
7179
}
7280

73-
public IEnumerable<(string title, string question, string answer)> AnswerEntryEnumerator()
81+
public IEnumerable<(string title, string question, string answer)> AnswerEntryEnumerator(
82+
bool noExactOnly = true
83+
)
7484
{
7585
foreach (var entry in FaqEntries)
7686
{
87+
if (noExactOnly && entry.ExactOnly)
88+
continue;
89+
7790
// If we want to use an example question:
7891
// entry.Questions.FirstOrDefault(entry.Title)
7992
yield return (entry.Title, "", entry.Answer);

0 commit comments

Comments
 (0)