NamedEntitiesExplorer
Find the people, organizations and places named in text items.
Uses Davlan/xlm-roberta-base-ner-hrl, trained on ten languages
including English, Spanish, Portuguese, German, French and Chinese.
Entities are counted by their text and type; the chart shows the most
frequent ones next to a table with counts and types.
Parameters
- top_n : integer, default=
20 - How many entities to show, between 1 and 200.
- min_score : number, default=
0.6 - Lowest model confidence, between 0 and 1, for an entity to count.
- device : string, default=
CPU - Device the model runs on. A GPU is much faster than the CPU.
Methods
find_entities(self, values: List[str]) -> List[Tuple[str, str]]
NamedEntitiesExplorerReturn the confident entities of the texts.
Parameters
- values : List[str]
- The texts.
Returns
- List[Tuple[str, str]]
(entity text, type label)for every confident mention.
launch_exploration(self, dataset: 'DashAIDataset', explorer_info: DashAI.back.dependencies.database.models.Explorer) -> Any
NamedEntitiesExplorerBuild a table and a bar chart of the most named entities.
Parameters
- dataset : DashAIDataset
- The selected text.
- explorer_info : Explorer
- The explorer record.
Returns
- plotly.graph_objects.Figure
- The entity table above the bar chart.
load_pretrained(self, source: str) -> Any
NamedEntitiesExplorerLoad the token classification pipeline.
Parameters
- source : str
- A local directory or the Hub repo id.
Returns
- transformers.Pipeline
- A pipeline that groups word pieces into whole entities.
component_dir(cls) -> pathlib.Path
DownloadableMixinReturn this component's own storage directory.
Returns
- pathlib.Path
<COMPONENT_PATH>/<ClassName>.
delete(cls) -> None
DownloadableMixinRemove the component's downloaded artifacts.
download(cls, report: Optional[Callable[[Optional[float], Optional[str]], NoneType]] = None) -> None
HFDownloadableMixinDownload all repos listed in hf_repos() into component_dir().
Parameters
- report : ProgressReporter, optional
- Callback invoked before each repo download with
report(None, "Downloading <repo_id>").Nonemeans no progress reporting.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_metadata(cls) -> Dict[str, Any]
BaseExplorerGet metadata for the explorer, used by the DashAI frontend.
Returns
- Dict[str, Any]
- Dictionary containing display name, description, image preview path, category, icon, color, allowed semantic types, allowed dtypes, input cardinality constraints, and any optional capability flags declared by the explorer.
get_results(self, exploration_path: str, options: Dict[str, Any]) -> List[Any]
TextAnalysisExplorerLoad the saved figure as a plotly artifact.
Parameters
- exploration_path : str
- The file written by
save_notebook. - options : Dict[str, Any]
- Rendering options (unused).
Returns
- List[Artifact]
- One plotly artifact.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
hf_repos(cls)
HFPretrainedDownloadMixinDerive the single repo entry from MODEL_NAME.
Returns
- list of tuple of (str, str)
[(MODEL_NAME, "model")]or an empty list when unset.
is_downloaded(cls) -> bool
HFDownloadableMixinReturn whether all repo directories exist and are non-empty.
Returns
- bool
Truewhen every repo listed inhf_repos()has a non-empty local directory;Falseotherwise (including when the list is empty).
prepare_dataset(self, loaded_dataset: Any, columns: List[Dict[str, Any]]) -> Any
TextAnalysisExplorerKeep the selected column and the item columns a document provides.
Parameters
- loaded_dataset : DashAIDataset
- The loaded explorer input.
- columns : List[Dict[str, Any]]
- The selected columns.
Returns
- DashAIDataset
- The selected columns, followed by
kind,pageandpositionwhen the input has them.
pretrained(self) -> Any
PretrainedToolReturn the loaded model, loading it on first use.
Returns
- Any
- The value :meth:
load_pretrainedreturned.
save_notebook(self, notebook_info: Any, explorer_info: Any, save_path: Any, result: Any) -> str
TextAnalysisExplorerSave the plotly figure of the exploration as JSON.
Parameters
- notebook_info : Notebook
- The notebook record (unused).
- explorer_info : Explorer
- The explorer record, whose id names the file.
- save_path : Path
- The directory to save into.
- result : plotly.graph_objects.Figure
- The figure from
launch_exploration.
Returns
- str
- The saved file path as a POSIX string.
set_context(self, context: Dict[str, Any]) -> None
BaseExplorerSet optional runtime context for explorers that need extra inputs.
setup_device(self, label: Optional[str]) -> None
PretrainedToolChoose the device and forget any loaded model.
Parameters
- label : str, optional
- The
deviceparameter.
text_column(dataset: Any, explorer_info: Any) -> List[str]
TextAnalysisExplorerReturn the selected text values, with missing values as empty text.
Parameters
- dataset : DashAIDataset
- The prepared dataset.
- explorer_info : Explorer
- The explorer record naming the selected column.
Returns
- List[str]
- The values of the first selected column.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.
validate_columns(cls, explorer_info: DashAI.back.dependencies.database.models.Explorer, column_spec: Dict[str, Dict[str, str]]) -> bool
BaseExplorerValidate that the selected columns satisfy the explorer's constraints.
Parameters
- explorer_info : Explorer
- The database record for the explorer instance, including the selected columns.
- column_spec : Dict[str, Dict[str, str]]
- A mapping from column name to a dict with at least
"type"(semantic type name) and"dtype"(dtype string).
Returns
- bool
- True if all column constraints are satisfied, False otherwise.
validate_parameters(cls, params: Dict[str, Any]) -> bool
BaseExplorerValidate explorer parameters against the explorer's schema.
Parameters
- params : Dict[str, Any]
- The configuration parameters to validate.
Returns
- BaseExplorerSchema
- The validated and parsed schema instance. Subclasses that override this method may return a bool to indicate pass/fail without returning the model instance.