Classes
- class pyfcg.Agent(name='agent')
Bases:
objectThe class for representing PyFCG agents.
- add_category(category)
Add a category to an agent’s categorial network.
- add_cxn(cxn)
Add a construction to an agent’s grammar.
- add_link(category_1, category_2)
Add a link between two categories in an agent’s categorial network.
- clear_cxns()
Delete all constructions from an agent’s grammar.
- comprehend(utterance)
Comprehend an utterance through an agent’s grammar.
- comprehend_all(utterance)
Comprehend an utterance through an agent’s grammar, returning all solutions.
- comprehend_and_formulate(utterance)
Comprehend an utterance and call formulate on the resulting meaning.
- delete_cxn(cxn)
Delete a construction from an agent’s grammar.
- find_cxn_by_name(cxn_name)
Retrieves a construction by name.
- formulate(meaning)
Formulate meaning through an agent’s grammar.
- formulate_all(meaning)
Formulate meaning through an agent’s grammar, returning all solutions.
- formulate_and_comprehend(meaning)
Formulate meaning and call comprehend on the resulting utterance.
- grammar_size()
Return the size of an agent’s grammar (number of constructions).
- load_grammar_from_file(file_name)
Load an FCG grammar spec in JSON format from a file.
- load_grammar_image(pathname)
Loading a grammar image into an agent.
- save_grammar_image(pathname)
Saving an image of an agent’s grammar for later reuse.
- class pyfcg.Construction(name, conditional_pole, contributing_pole=[], attributes={'label': 'cxn', 'score': 0.5}, feature_types=[])
Bases:
objectAn FCG construction.
- decrease_score(delta=0.2, lower_bound=0)
Decrease the score of a construction by delta.
- get_score()
Return the score of a construction.
- increase_score(delta=0.1, upper_bound=1.0)
Increase the score of a construction by delta.
- set_score(score)
Set the score of a construction to score.
- show_in_web_interface()
Show construction in FCG’s web interface.
- class pyfcg.Grammar(grammar_id)
Bases:
objectThe Grammar class implements all functionality required to support FCG grammars in PyFCG. A grammar has an id, cxns, a configuration, a visualization_configuration and a categorial_network.
- add_category(category)
Add a category to a grammar’s categorial network.
- add_cxn(cxn)
Add a new construction to a grammar.
- add_link(category_1, category_2)
Add a link between two categories in a grammar’s categorial network.
- clear_cxns()
Clear all constructions from grammar.
- comprehend(utterance)
Comprehend an utterance based on a grammar and return best solution.
- comprehend_all(utterance)
Comprehend an utterance based on a grammar and return all solutions.
- comprehend_and_formulate(utterance)
Comprehend an utterance, instantiate all variables in the resulting meaning representation and return the result from formulating this meaning representation.
- delete_cxn(cxn)
Delete a construction from a grammar.
- find_cxn_by_name(cxn_name)
Find a construction by name.
- formulate(meaning)
Formulate an utterance for a given meaning based on a grammar, returning the best solution.
- formulate_all(meaning)
Formulate an utterance for a given meaning based on a grammar, returning all solutions.
- formulate_and_comprehend(meaning)
Formulate a meaning representation and comprehend the resulting utterance.
- load_grammar_from_file(file_name)
Read an FCG grammar (in JSON format) from a file.
- load_grammar_image(pathname)
Load a grammar image saved under pathname.
- register_grammar()
Register the grammar in FCG, with all configurations etc. but without constructions
- save_grammar_image(pathname)
Save the grammar to a file (as a binary image).
- set_feature_type(feature_name, feature_type, procedural_attachment=None)
Set a single feature type in the grammar.
- set_feature_types(feature_types, inherit_feature_types=True)
Set the feature types of the grammar.
- set_grammar_configuration(key, value)
Set a configuration key in the grammar to a new value.
- set_grammar_visualization_configuration(key, value)
Set a visualization configuration key in the grammar to a new value.
- show_in_web_interface()
Show grammar in FCG’s web interface.
- size()
Return the size of the grammar (number of constructions).
- class pyfcg.PropBankAgent(name='agent')
Bases:
AgentA class for representing a PropBank agent.
- comprehend(utterance)
Comprehend utterance using the agent’s PropBank grammar and extract the frames from the result.
- learn_grammar_from_conll_file(pathname, training_configuration={}, excluded_rolesets=[])
Learn a grammar from a conll file using the PropBank grammar learning route