mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
33e8babb17
* Enable hidding inline_category in HighlightedText * add changeset * Update test_highlighted_text.py * add changeset * Update gradio/components/highlighted_text.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * add story --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
114 lines
3.1 KiB
Svelte
114 lines
3.1 KiB
Svelte
<script>
|
|
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
|
|
import HighlightedText from "./Index.svelte";
|
|
</script>
|
|
|
|
<Meta title="Components/HighlightedText" component={HighlightedText} />
|
|
|
|
<Template let:args>
|
|
<HighlightedText
|
|
value={[
|
|
{ token: "zebras", class_or_confidence: "+" },
|
|
{ token: "dogs", class_or_confidence: "-" },
|
|
{ token: "elephants", class_or_confidence: "+" }
|
|
]}
|
|
{...args}
|
|
/>
|
|
</Template>
|
|
|
|
<Story name="Highlighted Text Default" />
|
|
<Story name="Highlighted Text with legend" args={{ show_legend: true }} />
|
|
<Story name="Highlighted Text with label" args={{ label: "animals" }} />
|
|
<Story
|
|
name="Highlighted Text with new lines"
|
|
args={{
|
|
value: [
|
|
{ token: "zebras", class_or_confidence: "+" },
|
|
{ token: "\n" },
|
|
{ token: "dogs", class_or_confidence: "-" },
|
|
{ token: "\n" },
|
|
{ token: "elephants", class_or_confidence: "+" }
|
|
]
|
|
}}
|
|
/>
|
|
<Story
|
|
name="Highlighted Text with color map"
|
|
args={{ color_map: { "+": "green", "-": "red" } }}
|
|
/>
|
|
|
|
<Story
|
|
name="Highlighted Text with combine adjacent"
|
|
args={{
|
|
value: [
|
|
{ token: "The", class_or_confidence: null },
|
|
{ token: "quick", class_or_confidence: "adjective" },
|
|
{ token: " sneaky", class_or_confidence: "adjective" },
|
|
{ token: "fox", class_or_confidence: "subject" },
|
|
{ token: " jumped ", class_or_confidence: "past tense verb" },
|
|
{ token: "over the", class_or_confidence: null },
|
|
{ token: "lazy dog", class_or_confidence: "object" }
|
|
],
|
|
combine_adjacent: true
|
|
}}
|
|
/>
|
|
|
|
<Story
|
|
name="Highlighted Text without combine adjacent"
|
|
args={{
|
|
value: [
|
|
{ token: "The", class_or_confidence: null },
|
|
{ token: "quick", class_or_confidence: "adjective" },
|
|
{ token: " sneaky", class_or_confidence: "adjective" },
|
|
{ token: "fox", class_or_confidence: "subject" },
|
|
{ token: " jumped ", class_or_confidence: "past tense verb" },
|
|
{ token: "over the", class_or_confidence: null },
|
|
{ token: "lazy dog", class_or_confidence: "object" }
|
|
]
|
|
}}
|
|
/>
|
|
|
|
<Story
|
|
name="Highlighted Text with combine adjacent and new lines"
|
|
args={{
|
|
value: [
|
|
{ token: "The", class_or_confidence: null },
|
|
{ token: "quick", class_or_confidence: "adjective" },
|
|
{ token: " sneaky", class_or_confidence: "adjective" },
|
|
{ token: "fox", class_or_confidence: "subject" },
|
|
{ token: "\n", class_or_confidence: null },
|
|
{ token: " jumped ", class_or_confidence: "past tense verb" },
|
|
{ token: "\n", class_or_confidence: null },
|
|
{ token: "over the", class_or_confidence: null },
|
|
{ token: "lazy dog", class_or_confidence: "object" }
|
|
],
|
|
|
|
combine_adjacent: true
|
|
}}
|
|
/>
|
|
|
|
<Story
|
|
name="Highlighted Text in scores mode"
|
|
args={{
|
|
value: [
|
|
{ token: "the", class_or_confidence: -1 },
|
|
{ token: "quick", class_or_confidence: 1 },
|
|
{ token: "fox", class_or_confidence: 0.3 }
|
|
],
|
|
show_legend: true
|
|
}}
|
|
/>
|
|
|
|
<Story
|
|
name="Highlighted Text with hidden inline category"
|
|
args={{
|
|
value: [
|
|
{ token: "the", class_or_confidence: -1 },
|
|
{ token: "quick", class_or_confidence: 1 },
|
|
{ token: "fox", class_or_confidence: 0.3 }
|
|
],
|
|
show_legend: false,
|
|
show_inline_category: false,
|
|
interactive: false
|
|
}}
|
|
/>
|