Exemple #1
0
    def test_training_data4(self):
        from experiment import sample_wins_and_losses
        from metrics import SemanticsOracleAccuracyMetric
        from scoring import Model
        from travel import TravelDomain
        from geonames import GeoNamesAnnotator

        domain = TravelDomain()
        rules = self.rules_travel + self.rules_travel_locations + self.rules_travel_modes + self.rules_travel_triggers + self.rules_request_types + self.rules_optionals
        grammar = Unit2Grammar(rules=rules, annotators=[GeoNamesAnnotator(live_requests=False)])
        model = Model(grammar=grammar)
        metric = SemanticsOracleAccuracyMetric()

        # If printing=True, prints a sampling of wins (correct semantics in 
        # first parse) and losses on the dataset.
        metric_values = sample_wins_and_losses(domain=domain, model=model, metric=metric, seed=31, printing=False)
Exemple #2
0
def travel_demo():
    from travel import TravelDomain
    demo_learning_from_semantics(TravelDomain())
Exemple #3
0
# Extend domain.ops:

# Make sure things are working:
display_examples(('the one', 'the average of one and four'),
                 grammar=math_grammar,
                 domain=math_domain)

# ## Travel domain

# Here's an illustration of how parsing and interpretation work in this domain:

# In[ ]:

from travel import TravelDomain

travel_domain = TravelDomain()
travel_grammar = travel_domain.grammar()

display_examples(("flight from Boston to San Francisco",
                  "directions from New York to Philadelphia",
                  "directions New York to Philadelphia"),
                 grammar=travel_grammar,
                 domain=travel_domain)

# For these questions, we'll combine grammars with machine learning.
# Here's now to train and evaluate a model using the grammar
# that is included in `TravelDomain` along with a basic feature
# function.

# In[ ]: