File tree Expand file tree Collapse file tree 2 files changed +22
-10
lines changed
Expand file tree Collapse file tree 2 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public record FaqConfigEntry
1515 public string Answer { get ; set ; } = "" ;
1616
1717 [ JsonPropertyName ( "matched_questions" ) ]
18- public List < string > Questions { get ; set ; } = [ ] ;
18+ public string [ ] Questions { get ; set ; } = [ ] ;
1919
2020 public FaqConfigEntry ( ) { }
2121
@@ -28,12 +28,12 @@ public FaqConfigEntry(string answer)
2828 public FaqConfigEntry ( string answer , IEnumerable < string > questions )
2929 : this ( answer )
3030 {
31- Questions . AddRange ( questions ) ;
31+ Questions = questions . ToArray ( ) ;
3232 }
3333 }
3434
3535 [ JsonPropertyName ( "faqs" ) ]
36- public List < FaqConfigEntry > FaqEntries { get ; set ; } = [ ] ;
36+ public FaqConfigEntry [ ] FaqEntries { get ; set ; } = [ ] ;
3737
3838 public FaqConfigEntry ? GetAnswerEntry ( string answer )
3939 {
Original file line number Diff line number Diff line change 1+ using static BingusLib . FaqHandling . FaqConfig ;
2+
13namespace BingusLib . FaqHandling
24{
35 public class FaqDict
46 {
57 private readonly Dictionary < string , FaqEntry > _faqDict = [ ] ;
68
79 public FaqDict ( FaqConfig faqConfig )
8- : this ( faqConfig . QaEntryEnumerator ( ) ) { }
10+ : this ( faqConfig . FaqEntries ) { }
911
10- public FaqDict ( IEnumerable < ( string title , string question , string answer ) > tqaMapping )
12+ public FaqDict ( IEnumerable < FaqConfigEntry > faqConfigEntries )
1113 {
12- foreach ( var ( title , question , answer ) in tqaMapping )
14+ foreach ( var entry in faqConfigEntries )
1315 {
14- _faqDict [ CleanQuery ( question ) ] = new FaqEntry ( )
16+ _faqDict [ CleanQuery ( entry . Title ) ] = new FaqEntry ( )
1517 {
16- Title = title ,
17- Question = question ,
18- Answer = answer ,
18+ Title = entry . Title ,
19+ Question = entry . Title ,
20+ Answer = entry . Answer ,
1921 } ;
22+
23+ foreach ( var question in entry . Questions )
24+ {
25+ _faqDict [ CleanQuery ( question ) ] = new FaqEntry ( )
26+ {
27+ Title = entry . Title ,
28+ Question = question ,
29+ Answer = entry . Answer ,
30+ } ;
31+ }
2032 }
2133 }
2234
You can’t perform that action at this time.
0 commit comments