Skip to content

Commit

Permalink
chore: rename annotator to text annotator #974
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Oct 28, 2021
1 parent 4aeeb9b commit ebb22db
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 33 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions py/examples/tour.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ form.py
form_visibility.py
text.py
text_sizes.py
text_annotator.py
label.py
link.py
progress.py
Expand Down
4 changes: 2 additions & 2 deletions py/h2o_wave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5744,9 +5744,9 @@ def load(__d: Dict) -> 'TextAnnotatorItem':


class TextAnnotator:
"""Create an annotator component.
"""Create a text annotator component.

The annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
The text annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
"""
def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions py/h2o_wave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,9 +2149,9 @@ def text_annotator(
items: List[TextAnnotatorItem],
trigger: Optional[bool] = None,
) -> Component:
"""Create an annotator component.
"""Create a text annotator component.
The annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
The text annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
Args:
name: An identifying name for this component.
Expand Down
4 changes: 2 additions & 2 deletions r/R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -2503,9 +2503,9 @@ ui_text_annotator_item <- function(
return(.o)
}

#' Create an annotator component.
#' Create a text annotator component.
#'
#' The annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
#' The text annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
#'
#' @param name An identifying name for this component.
#' @param title The text annotator's title.
Expand Down
2 changes: 1 addition & 1 deletion ui/src/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as Fluent from '@fluentui/react'
import { B, Model, Packed, S, unpack } from 'h2o-wave'
import React from 'react'
import { stylesheet } from 'typestyle'
import { TextAnnotator, XTextAnnotator } from './annotator'
import { TextAnnotator, XTextAnnotator } from './text_annotator'
import { Button, Buttons, MiniButton, MiniButtons, XButtons, XMiniButton, XMiniButtons, XStandAloneButton } from './button'
import { Checkbox, XCheckbox } from './checkbox'
import { Checklist, XChecklist } from './checklist'
Expand Down
42 changes: 21 additions & 21 deletions ui/src/table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe('Table.tsx', () => {
})
})

describe('filter - badges', () => {
describe('filter - tags', () => {
beforeEach(() => {
tableProps = {
...tableProps,
Expand All @@ -383,55 +383,55 @@ describe('Table.tsx', () => {
label: 'col2',
filterable: true,
cell_type: {
badge: {
name: 'badges',
badges: [
{ label: 'BADGE1', color: 'red' },
{ label: 'BADGE2', color: 'green' },
{ label: 'BADGE3', color: 'blue' },
tag: {
name: 'tags',
tags: [
{ label: 'TAG1', color: 'red' },
{ label: 'TAG2', color: 'green' },
{ label: 'TAG3', color: 'blue' },
]
}
}
},
],
rows: [
{ name: 'rowname1', cells: [cell11, 'BADGE1'] },
{ name: 'rowname2', cells: [cell21, 'BADGE2,BADGE3'] },
{ name: 'rowname3', cells: [cell31, 'BADGE2'] }
{ name: 'rowname1', cells: [cell11, 'TAG1'] },
{ name: 'rowname2', cells: [cell21, 'TAG2,TAG3'] },
{ name: 'rowname3', cells: [cell31, 'TAG2'] }
]
}
})

it('Filters correctly - badges - correct badges are selected', () => {
it('Filters correctly - tags - correct tags are selected', () => {
const { getByTestId, container, getAllByText, getAllByRole } = render(<XTable model={tableProps} />)

fireEvent.click(container.querySelector('.ms-DetailsHeader-filterChevron')!)
fireEvent.click(getAllByText('BADGE3')[1].parentElement!)
fireEvent.click(getAllByText('TAG3')[1].parentElement!)
// Mimic close and reopen filter context menu.
fireEvent.click(getByTestId(name))
fireEvent.click(container.querySelector('.ms-DetailsHeader-filterChevron')!)
const [badge1, badge2, badge3] = getAllByRole('checkbox')
expect(badge1).not.toBeChecked()
expect(badge2).not.toBeChecked()
expect(badge3).toBeChecked()
const [tag1, tag2, tag3] = getAllByRole('checkbox')
expect(tag1).not.toBeChecked()
expect(tag2).not.toBeChecked()
expect(tag3).toBeChecked()
})

it('Filters correctly - badges - multiple filters', () => {
it('Filters correctly - tags - multiple filters', () => {
const { container, getAllByText, getByText, getAllByRole } = render(<XTable model={tableProps} />)

expect(getAllByRole('row')).toHaveLength(tableProps.rows.length + headerRow)
fireEvent.click(container.querySelector('.ms-DetailsHeader-filterChevron')!)
fireEvent.click(getAllByText('BADGE1')[1].parentElement!)
fireEvent.click(getByText('BADGE3').parentElement!)
fireEvent.click(getAllByText('TAG1')[1].parentElement!)
fireEvent.click(getByText('TAG3').parentElement!)
expect(getAllByRole('row')).toHaveLength(2 + headerRow)
})

it('Filters correctly - badges - single', () => {
it('Filters correctly - tags - single', () => {
const { container, getAllByText, getAllByRole } = render(<XTable model={tableProps} />)

expect(getAllByRole('row')).toHaveLength(tableProps.rows.length + headerRow)
fireEvent.click(container.querySelector('.ms-DetailsHeader-filterChevron')!)
fireEvent.click(getAllByText('BADGE1')[1].parentElement!)
fireEvent.click(getAllByText('TAG1')[1].parentElement!)
expect(getAllByRole('row')).toHaveLength(1 + headerRow)
})
})
Expand Down
6 changes: 3 additions & 3 deletions ui/src/annotator.test.tsx → ui/src/text_annotator.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { render, fireEvent } from '@testing-library/react'
import React from 'react'
import { TextAnnotator, XTextAnnotator } from './annotator'
import { TextAnnotator, XTextAnnotator } from './text_annotator'
import { wave } from './ui'

const
name = 'annotator',
name = 'textAnnotator',
items = [{ text: 'Hello there! ' }, { text: 'Pretty good', tag: 'tag1' }, { text: ' day' }],
annotatorProps: TextAnnotator = { name, title: name, tags: [{ name: 'tag1', label: 'Tag 1', color: '$red' }], items },
getSelectionMock = jest.fn(),
pushMock = jest.fn()

describe('Annotator.tsx', () => {
describe('TextAnnotator.tsx', () => {
beforeAll(() => {
window.getSelection = getSelectionMock
wave.push = pushMock
Expand Down
4 changes: 2 additions & 2 deletions ui/src/annotator.tsx → ui/src/text_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ interface TextAnnotatorItem {
}

/**
* Create an annotator component.
* Create a text annotator component.
*
* The annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
* The text annotator component enables user to manually annotate parts of text. Useful for NLP data prep.
*/
export interface TextAnnotator {
/** An identifying name for this component. */
Expand Down
File renamed without changes

0 comments on commit ebb22db

Please sign in to comment.