Skip to content

Commit

Permalink
Fix indexing issue in Sequence Salience module.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 671384008
  • Loading branch information
RyanMullins authored and LIT team committed Sep 5, 2024
1 parent 7a1826f commit 58b1d2b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lit_nlp/client/modules/sequence_salience_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,22 +922,25 @@ export class SequenceSalienceModule extends SingleExampleSingleModelModule {
this.salienceTargetOption = i;
};
// prettier-ignore
return html`
<div class='interstitial-target-option' @click=${onClickTarget}>
<div class='interstitial-target-text'>${target.text}</div>
</div>`;
return {
source: target.source,
template: html`<div class='interstitial-target-option'
@click=${onClickTarget}>
<div class='interstitial-target-text'>${target.text}</div>
</div>`,
};
};

// Slightly awkward, but we need to process and /then/ filter, because
// the @click handler needs the original list index.
const optionsFromDataset =
this.salienceTargetOptions
.filter((t) => t.source === TargetSource.REFERENCE)
.map((t, i) => formatOption(t, i));
const optionsFromModel =
this.salienceTargetOptions
.filter((t) => t.source === TargetSource.MODEL_OUTPUT)
.map((t, i) => formatOption(t, i));
const formattedOptions =
this.salienceTargetOptions.map((t, i) => formatOption(t, i));
const optionsFromDataset = formattedOptions
.filter((t) => t.source === TargetSource.REFERENCE)
.map((t) => t.template);
const optionsFromModel = formattedOptions
.filter((t) => t.source === TargetSource.MODEL_OUTPUT)
.map((t) => t.template);

const isLoadingPreds = this.latestLoadPromises.has(MODEL_PREDS_KEY);

Expand Down

0 comments on commit 58b1d2b

Please sign in to comment.