Semantics: string matching and interpreting methods

gini.semantics module

class gini.semantics.Bottle(vocab=[])[source]

Bases: object

Container for semantic information (and magical creatures)

fname_match = None

matching options

match_all_concepts(string)[source]

Returns sorted list of all Concept`s matching ``string`

match_concept(string)[source]

Find all matches in this Bottle for string and return the best match

negative = None

Allow the use of “not” and a “-” before a term to negate the term

parse_string(string, best=False)[source]

Parses string trying to match each word to a Concept. If best, will only return the top matches

process_string(string)[source]

Searches the string (or list of strings) for an action word (a Concept that has and action attached to it), then calls the appropriate function with a dictionary of the identified words (according to vocab).

For examples, see demo.py

set_action(concept_name, action_meth)[source]

helper function to set the action attr of any Concept`s in ``self.vocab` that match concept_name to action_meth

vocab = None

list of Concepts to match with

class gini.semantics.Concept(name, example_lists, parent=None, action=None, meta=None)[source]

Bases: object

action = None

Method to run if this is used as an action

examples = None

List of example strings for each item

matches(string, fuzzy=90, fname_match=True, fuzzy_fragment=None, guess=False)[source]

Returns whether this Concept matches string

meta = None

Any information to attach to this object

name = None

Arbitrary label for concept

class gini.semantics.ConceptMatch(concept)[source]

Bases: object

amount = None

The degree of match (when using fuzzy matching)

concept = None

A back-reference to the original matching concept

examples = None

List of matching example

item = None

Matching item

negative = None

This concept is currently being used in the negative sense (i.e., “not ____”)

string = None

The string this concept was matched to

type = None

The type of match this was found in (e.g., exact or fuzzy)

gini.semantics.sort_matches(matches)[source]

Sorts a list of matches best to worst