Skip to content

Commit

Permalink
[ML] Adds placeholder text for testing NLP models (elastic#132486)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored May 20, 2022
1 parent bc31053 commit 7e15097
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import { i18n } from '@kbn/i18n';
import { InferenceBase, InferResponse } from '../inference_base';
import { getGeneralInputComponent } from '../text_input';
import { getNerOutputComponent } from './ner_output';
Expand Down Expand Up @@ -52,7 +52,10 @@ export class NerInference extends InferenceBase<NerResponse> {
}

public getInputComponent(): JSX.Element {
return getGeneralInputComponent(this);
const placeholder = i18n.translate('xpack.ml.trainedModels.testModelsFlyout.ner.inputText', {
defaultMessage: 'Enter a phrase to test',
});
return getGeneralInputComponent(this, placeholder);
}

public getOutputComponent(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export class FillMaskInference extends InferenceBase<TextClassificationResponse>

public getInputComponent(): JSX.Element {
const placeholder = i18n.translate(
'xpack.ml.trainedModels.testModelsFlyout.langIdent.inputText',
'xpack.ml.trainedModels.testModelsFlyout.fillMask.inputText',
{
defaultMessage: 'Mask token: [MASK]. e.g. Paris is the [MASK] of France.',
defaultMessage:
'Enter a phrase to test. Use [MASK] as a placeholder for the missing words.',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import { InferenceBase, InferenceType } from '../inference_base';
import { processResponse } from './common';
import { getGeneralInputComponent } from '../text_input';
Expand Down Expand Up @@ -44,7 +45,13 @@ export class LangIdentInference extends InferenceBase<TextClassificationResponse
}

public getInputComponent(): JSX.Element {
return getGeneralInputComponent(this);
const placeholder = i18n.translate(
'xpack.ml.trainedModels.testModelsFlyout.langIdent.inputText',
{
defaultMessage: 'Enter a phrase to test',
}
);
return getGeneralInputComponent(this, placeholder);
}

public getOutputComponent(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import { InferenceBase } from '../inference_base';
import { processResponse } from './common';
import type { TextClassificationResponse, RawTextClassificationResponse } from './common';
Expand Down Expand Up @@ -45,7 +46,13 @@ export class TextClassificationInference extends InferenceBase<TextClassificatio
}

public getInputComponent(): JSX.Element {
return getGeneralInputComponent(this);
const placeholder = i18n.translate(
'xpack.ml.trainedModels.testModelsFlyout.textClassification.inputText',
{
defaultMessage: 'Enter a phrase to test',
}
);
return getGeneralInputComponent(this, placeholder);
}

public getOutputComponent(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import { i18n } from '@kbn/i18n';
import { InferenceBase, InferResponse } from '../inference_base';
import { getGeneralInputComponent } from '../text_input';
import { getTextEmbeddingOutputComponent } from './text_embedding_output';
Expand Down Expand Up @@ -53,7 +54,13 @@ export class TextEmbeddingInference extends InferenceBase<TextEmbeddingResponse>
}

public getInputComponent(): JSX.Element {
return getGeneralInputComponent(this);
const placeholder = i18n.translate(
'xpack.ml.trainedModels.testModelsFlyout.textEmbedding.inputText',
{
defaultMessage: 'Enter a phrase to test',
}
);
return getGeneralInputComponent(this, placeholder);
}

public getOutputComponent(): JSX.Element {
Expand Down

0 comments on commit 7e15097

Please sign in to comment.