probabilitymodel

Implements the probability models proposed in the article to make a choice in slot where frame matching left several possible roles.

There are four possible models :
  • default does not use any collected data, nor the list of possible roles and makes default assignement depending on the slot class
  • slot_class choose the most likely of the possible roles given the slot class of the slot (the difference with default it is guaranteed that the chosen role will be in the list of possible roles for this slot)
  • slot choose the most likely of the possible roles given the slot type (that is, the slot class, but with the PP class is divided into one class for each preposition)
  • predicate_slot choose the most likely of the possible roles given the slot type and the predicate
class probabilitymodel.ProbabilityModel(vn_classes=None, vn_init_value=None)[source]

Bases: builtins.object

Class used to collect data and apply one probability model

Variables:
  • data_default – str. Dict The default assignements
  • data_slot_class – str. 2D Dict The number of occurences of each role in every slot class
  • data_slot – str. 3D Dict The number of occurences of each role in every slot
  • data_slot – str. 4D Dict The number of occurences of each role in every (slot, predicate)
add_data(slot_class, role, prep, predicate, vnclass=None)[source]

Use one known occurence of a role in a given context to update the data of every model

Parameters:
  • slot_class (str) – The slot class of the slot where the role occured
  • role (str) – The role that occured
  • prep (str) – The preposition which introduced the slot if it was a PP slot
  • predicate (str) – The predicate of which the slot was an argument
  • vnclass (None | str) – The VerbNet class of the predicate
add_data_bootstrap(role, predicate, predicate_classes, slot_class, prep, headword, headword_class)[source]

Use one known occurence of a role in a given context to update the data of the bootstrap algorithm

Parameters:
  • role (str) – The attributed role
  • predicate (str) – The predicate of which the slot is an argument
  • predicate_classes (str List) – The VerbNet classes of the predicate
  • slot_class (str) – The slot class of the slot we want to resolve
  • prep (str) – If the slot is a PP, the preposition that introduced it
  • headword (str:) – The headword of the argument

param headword_class: The WordNet class of the headword :type headword_class: str:

add_data_vnclass(matcher)[source]

Fill data_vnclass using the data of a framematcher object

Parameters:matcher (FrameMatcher) – A frame matcher after at least one matching
best_role(role_set, slot_class, prep, predicate, model)[source]

Apply one probability model to resolve one slot

Parameters:
  • role_set (str Set) – The set of possible roles left by frame matching
  • slot_class (str) – The slot class of the slot we want to resolve
  • prep (str) – If the slot is a PP, the preposition that introduced it
  • predicate (str) – The predicate of which the slot is an argument
  • model (str) – The model that we want to apply
best_roles_bootstrap(role_set, predicate, predicate_classes, slot_class, prep, headword, headword_class, backoff_level, min_evidence)[source]

Computes the two best roles for a slot at a given backoff level of the bootstrap algorithm

Parameters:
  • role_set (str Set) – The set of possible roles left by frame matching
  • predicate (str) – The predicate of which the slot is an argument
  • predicate_classes (str List) – The VerbNet classes of the predicate
  • slot_class (str) – The slot class of the slot we want to resolve
  • prep (str) – If the slot is a PP, the preposition that introduced it
  • headword (str:) – The headword of the argument

param headword_class: The WordNet class of the headword :type headword_class: str: param backoff_level: The backoff level :type backoff_level: int :param min_evidence: The minimum number of occurences that a role must have to be returned :type min_evidence: int

:returns (str, str, float) – The two roles and their probability ratio

check_vnclass_guess(predicate, frame_name, role_matcher)[source]
guess_bad = -1
guess_good = 1
guess_unknown = 0
stats_vnclass()[source]
class probabilitymodel.ProbabilityModelTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test class for ProbabilityModel

test_1()[source]
probabilitymodel.check_depth(data, depth)[source]
probabilitymodel.multi_count(obj)[source]

Returns the sum of all integers in a multidict

probabilitymodel.multi_default_dict(dimension)[source]

Returns an empty int defaultdict of a given dimension

probabilitymodel.multi_get(d, l, default=None)[source]

Traverses multiple levels of a dictionary to get a key or None

probabilitymodel.root_vnclass(vnclass)[source]