framenet_tools package

Submodules

framenet_tools.config module

class framenet_tools.config.ConfigManager(path: str = None)

Bases: object

create_config(path: str)

Creates a config file and saves all necessary variables

Returns:
load_config(path: str = None)

Loads the config file and saves all found variables

NOTE: If no config file was found, the default configs will be loaded instead

Returns:A boolean - True if the config file was loaded, False if defaults were loaded
load_defaults()

Loads the builtin defaults

Returns:
paths_to_string(files: List[List[str]])

Helper function for turning a list of file paths into a structured string

Parameters:files – A list of files
Returns:The string containing all files

framenet_tools.evaluator module

framenet_tools.evaluator.calc_f(tp: int, fp: int, fn: int)

Calculates the F1-Score

NOTE: This follows standard evaluation metrics TAKEN FROM: Open-SESAME (https://github.com/swabhs/open-sesame)

Parameters:
  • tp – True Postivies Count
  • fp – False Postivies Count
  • fn – False Negatives Count
Returns:

A Triple of Precision, Recall and F1-Score

framenet_tools.evaluator.evaluate_fee_identification(m_reader: framenet_tools.data_handler.reader.DataReader, original_reader: framenet_tools.data_handler.reader.DataReader)

Evaluates the Frame Evoking Element Identification only

Parameters:
  • m_reader – The reader containing the predicted annotations
  • original_reader – The original reader containing the gold annotations
Returns:

A Triple of True positives, False positives and False negatives

framenet_tools.evaluator.evaluate_frame_identification(m_reader: framenet_tools.data_handler.reader.DataReader, original_reader: framenet_tools.data_handler.reader.DataReader)

Evaluates the Frame Identification

Parameters:
  • m_reader – The reader containing the predicted annotations
  • original_reader – The original reader containing the gold annotations
Returns:

A Triple of True positives, False positives and False negatives

framenet_tools.evaluator.evaluate_span_identification(cM: framenet_tools.config.ConfigManager, span_identifier: framenet_tools.span_identification.spanidentifier.SpanIdentifier = None)

Evaluates the span identification for its F1 score

Parameters:
  • cM – The ConfigManager containing the evaluation files
  • span_identifier – Optionally an instance of a SpanIdentifier
Returns:

A Triple of Precision, Recall and F1-Score

framenet_tools.evaluator.evaluate_stages(m_reader: framenet_tools.data_handler.reader.DataReader, original_reader: framenet_tools.data_handler.reader.DataReader, levels: List[int])

Evaluates the stages specified in levels

Parameters:
  • m_reader – The reader including the predicted data
  • original_reader – The reader which holds the gold data
  • levels – The levels to evaluate for
Returns:

A triple of Precision, Recall and the F1-Score

framenet_tools.main module

framenet_tools.main.check_files(path)
framenet_tools.main.create_argparser()

Creates the ArgumentParser and defines all of its arguments.

Returns:the set up ArgumentParser
framenet_tools.main.eval_args(parser: <MagicMock id='139663473705928'>, args: List[str] = None)

Evaluates the given arguments and runs to program accordingly.

Parameters:
  • parser – The ArgumentParser for getting the specified arguments
  • args – Possibility for manually passing arguments.
Returns:

framenet_tools.main.main()

The main entry point

Returns:

framenet_tools.pipeline module

class framenet_tools.pipeline.Pipeline(cM: framenet_tools.config.ConfigManager, levels: List[int])

Bases: object

The SRL pipeline

Contains the stages of Frame evoking element identification, Frame identification, Span identification and Role identification.

evaluate()

Evaluates all the specified stages of the pipeline.

NOTE: Depending on the certain levels of the pipeline, the propagated error can be large!

Returns:
load_dataset(files: List[str])

Helper function for loading datasets.

Parameters:files – A List of files to load the datasets from.
Returns:A reader object containing the loaded data.
predict(file: str, out_path: str)

Predicts a raw file and exports the predictions to the given file. Also only predicts up to the specified level.

NOTE: Prediction is only possible up to the level on which the pipeline was trained!

Parameters:
  • file – The raw input text file
  • out_path – The path to save the outputs to (can be None)
Returns:

train(data: List[str], dev_data: List[str] = None)

Trains all stages up to the specified level

Parameters:
  • data – The data to train on
  • dev_data – The data to check evaluation on
Returns:

framenet_tools.pipeline.get_stages(i: int, cM: framenet_tools.config.ConfigManager)

Creates a list of stages up to the bound specified

Parameters:i – The upper bound of the pipeline stages
Returns:A list of stages

framenet_tools.pipelinestage module

class framenet_tools.pipelinestage.PipelineStage(cM: framenet_tools.config.ConfigManager)

Bases: abc.ABC

Abstract stage of the pipeline

predict(m_reader: framenet_tools.data_handler.reader.DataReader)

Predict the given data

NOTE: Changes the object itself

Parameters:m_reader – The DataReader object
Returns:
train(m_reader: framenet_tools.data_handler.reader.DataReader, m_reader_dev: framenet_tools.data_handler.reader.DataReader)

Train the stage on the given data

Parameters:
  • m_reader – The DataReader object which contains the training data
  • m_reader_dev – The DataReader object for evaluation and auto stopping (NOTE: not necessarily given, as the focus might lie on maximizing the training data)
Returns:

Module contents