fibber.fibber module

class fibber.fibber.Fibber(arg_dict, dataset_name, strategy_name, field='text0', trainset=None, testset=None, output_dir='.', bert_clf_steps=5000)[source]

Bases: object

Fibber is a unified interface for paraphrase strategies.

Initialize

Parameters
  • arg_dict (dict) – a dict of hyper parameters for the MetricBundle and strategy.

  • dataset_name (str) – the name of the dataset.

  • strategy_name (str) – the strategy name.

  • field (str) –

  • trainset (dict) – fibber dataset.

  • testset (dict) – fibber testset.

  • output_dir (str) – directory to cache the strategy.

get_metric_bundle()[source]

“Get the metric bundle.

paraphrase(data_record, n=20)[source]

Paraphrase a given data record.

Parameters
  • data_record (dict) – data record to be paraphrased.

  • n (int) – number of paraphrases.

Returns

  • a list of str as paraphrased sentences.

  • a list of dict as corresponding metrics.

paraphrase_a_random_sentence(n=20, from_testset=True)[source]

Randomly pick one data, then paraphrase it.

Parameters
  • n (int) – number of paraphrases.

  • from_testset (bool) – if true, select data from test set, otherwise from training set.

Returns

  • a str as the original text.

  • a list of str as the paraphrased text.

  • a list of dict as corresponding metrics.