bluesearch.server.mining_server module

The mining server.

class MiningServer(models_libs, connection)[source]

Bases: flask.app.Flask

The BBS mining server.

Parameters
  • models_libs (dict of str) – Dictionary mapping each type of extraction (‘ee’ for entities, ‘re’ for relations, ‘ae’ for attributes) to the list of paths of available models.

  • connection (sqlalchemy.engine.Engine) – The database connection.

static add_ontology_column(df_all, schema_df)[source]

Add ontology column to dataframe.

check_args_not_null(**kwargs)[source]

Sanity check that arguments provided are not null.

Returns False if all is good.

static create_error_response(error_message)[source]

Create response if there is an error during the process.

Parameters

error_message (str) – Error message to send if there is an issue.

Returns

response – Response to send with the error_message in a json format.

Return type

str

static create_response(df_extractions, etypes_na)[source]

Create the response thanks to dataframe.

Parameters
  • df_extractions (pd.DataFrame) – DataFrame containing all the elements extracted by text mining.

  • etypes_na (Iterable[str]) – Entity types found in the request CSV file for which no available model was found in the library.

Returns

response – Response containing the dataframe converted in csv table.

Return type

requests.response

get_available_etypes(schema_df)[source]

Find entity extraction model for entity types.

Parameters

schema_df (pd.DataFrame) – Schema of the client request.

Returns

  • etypes (set[str]) – Entity types requested and available on the server.

  • etypes_na (set[str]) – Entity types requested but not available on the server.

help()[source]

Respond to the help.

mine_texts(texts, schema_df, debug)[source]

Run mining pipeline on a given list of texts.

pipeline_database()[source]

Respond to a query on specific paragraphs in the database.

pipeline_text()[source]

Respond to a custom text query.

static read_df_from_str(df_str, drop_duplicates=True)[source]

Read a csv file from a string into a pd.DataFrame.