@@ -169,7 +169,8 @@ export const answerCitationOverlaps = (
169169export const pickCitationsByAnswer = (
170170 sourceDocuments : SourceDocument [ ] ,
171171 answer : string ,
172- preferred : SourceDocument [ ]
172+ preferred : SourceDocument [ ] ,
173+ presentNames ?: Set < string >
173174) : SourceDocument [ ] => {
174175 const webDocuments = sourceDocuments . filter (
175176 ( doc ) => sourceKind ( doc ) === 'web'
@@ -182,12 +183,16 @@ export const pickCitationsByAnswer = (
182183 answer ,
183184 preferred
184185 ) ;
185- return [ ...citedLocal , ...flagUsedWebDocuments ( webDocuments , answer ) ] ;
186+ return [
187+ ...citedLocal ,
188+ ...flagUsedWebDocuments ( webDocuments , answer , presentNames ) ,
189+ ] ;
186190} ;
187191
188192const flagUsedWebDocuments = (
189193 webDocuments : SourceDocument [ ] ,
190- answer : string
194+ answer : string ,
195+ presentNames ?: Set < string >
191196) : SourceDocument [ ] => {
192197 if ( webDocuments . length === 0 ) return webDocuments ;
193198
@@ -205,7 +210,9 @@ const flagUsedWebDocuments = (
205210 return scored . map ( ( s ) => ( {
206211 ...s . doc ,
207212 used :
208- maxOverlap > 0 && s . overlap >= maxOverlap * ANSWER_CITATION_OVERLAP_RATIO ,
213+ maxOverlap > 0 &&
214+ s . overlap >= maxOverlap * ANSWER_CITATION_OVERLAP_RATIO &&
215+ ( presentNames === undefined || presentNames . has ( s . doc . name ) ) ,
209216 } ) ) ;
210217} ;
211218
0 commit comments