Пример #1
0
class BadTemplate(RegexTemplate):
    slots = {
        'bad': one_or_more_spacesep(BAD_PHRASES),
        'preceder': OPTIONAL_TEXT_PRE,
        'follower': OPTIONAL_TEXT_POST,
    }
    templates = [
        "{preceder}{bad}{follower}",
    ]
    positive_examples = [
        ('bad to be honest', {
            'preceder': '',
            'bad': 'bad',
            'follower': ' to be honest'
        }),
        ('very bad', {
            'preceder': 'very ',
            'bad': 'bad',
            'follower': ''
        }),
        ('not so amazing i think', {
            'preceder': '',
            'bad': 'not so amazing',
            'follower': ' i think'
        }),
    ]
    negative_examples = []
Пример #2
0
class SomethingElseTemplate(RegexTemplate):
    """
    This template captures when the input text contains a "something else" phrase.
    """
    slots = {
        'something_else': one_or_more_spacesep(SOMETHING_ELSE),
    }
    templates = [
        OPTIONAL_TEXT_PRE + '{something_else}' + OPTIONAL_TEXT_POST,
    ]
    positive_examples = [
        ("something else", {
            'something_else': "something else"
        }),
        ("uh something else please", {
            'something_else': "something else"
        }),
        ("any other topic would be better", {
            'something_else': "other topic"
        }),
        ("the next subject if you have one", {
            'something_else': "next subject"
        }),
    ]
    negative_examples = [
        "zebras",
        "this topic",
        "something fun",
    ]
Пример #3
0
class NeutralTemplate(RegexTemplate):
    slots = {
        'neutral': one_or_more_spacesep(NEUTRAL_PHRASES),
        'preceder': OPTIONAL_TEXT_PRE,
        'follower': OPTIONAL_TEXT_POST,
    }
    templates = [
        "{preceder}{neutral}{follower}",
    ]
    positive_examples = [
        ("i'm feeling okay today", {
            'preceder': "i'm feeling ",
            'neutral': 'okay',
            'follower': ' today'
        }),
        ("not so bad", {
            'preceder': "",
            'neutral': 'not so bad',
            'follower': ''
        }),
    ]
    negative_examples = []
Пример #4
0
class GoodTemplate(RegexTemplate):
    slots = {
        'good': one_or_more_spacesep(GOOD_PHRASES),
        'preceder': OPTIONAL_TEXT_PRE,
        'follower': OPTIONAL_TEXT_POST,
    }
    templates = [
        "{preceder}{good}{follower}",
    ]
    positive_examples = [
        ('good thanks', {
            'preceder': '',
            'good': 'good',
            'follower': ' thanks'
        }),
        ('so great', {
            'preceder': 'so ',
            'good': 'great',
            'follower': ''
        }),
    ]
    negative_examples = [
        'okay',
    ]
Пример #5
0
class PositiveNavigationTemplate(RegexTemplate):
    """
    This template captures when the user is expressing a positive navigational intent like
    "i want to talk about X", "i want to talk about", "i want to talk".
    """
    slots = {
        'nav':
        one_or_more_spacesep(POSITIVE_NAVIGATION),
        'nav_about':
        one_or_more_spacesep(['{} about'.format(oneof(POSITIVE_NAVIGATION))]),
        'topic':
        NONEMPTY_TEXT,
    }
    templates = [
        OPTIONAL_TEXT_PRE + "{nav_about}( {topic})?",
        OPTIONAL_TEXT_PRE + "{nav}( {topic})?",
    ]
    positive_examples = [
        ('alexa can you please talk something else', {
            'nav': 'can you please talk',
            'topic': 'something else'
        }),
        ('tell me jokes', {
            'nav': 'tell me',
            'topic': 'jokes'
        }),
        ('tell me a bit', {
            'nav': 'tell me a bit'
        }),
        ("talk about zebras", {
            'nav_about': "talk about",
            'topic': 'zebras'
        }),
        ("talk to me", {
            'nav': "talk to me"
        }),
        ("let's talk about zebras", {
            'nav_about': "let's talk about",
            'topic': 'zebras'
        }),
        ("no i wanna learn about microbiology", {
            'nav_about': "i wanna learn about",
            'topic': 'microbiology'
        }),
        ("can we chat about", {
            'nav_about': "we chat about"
        }),
        ("sure let's talk about it", {
            'nav_about': "let's talk about",
            'topic': 'it'
        }),
        ("can you talk about life", {
            'nav_about': "you talk about",
            'topic': 'life'
        }),
        ("can you tell me about golden buddha", {
            'nav_about': 'you tell me about',
            'topic': 'golden buddha'
        }),
        ("talk more about it please", {
            'nav_about': 'talk more about',
            'topic': 'it please'
        }),
        ("tell me a story about mexico", {
            'nav': 'tell me a',
            'topic': 'story about mexico'
        }),
        ("i need to talk about you", {
            'nav_about': 'i need to talk about',
            'topic': 'you'
        }),
        ("talk to me", {
            'nav': "talk to me"
        }),
        ("i would like to talk to you about cern", {
            'nav_about': "i would like to talk to you about",
            'topic': 'cern'
        }),
        ("talk to me about ash wednesday", {
            'nav_about': "talk to me about",
            'topic': 'ash wednesday'
        }),
        ("no tell me about your childhood", {
            'nav_about': "no tell me about",
            'topic': 'your childhood'
        }),
        ("i don't want to talk about zebras i want to talk about giraffes", {
            'nav_about': "i want to talk about",
            'topic': 'giraffes'
        }),
        ("tell me about giraffes i don't want to talk about zebras", {
            'nav_about': "tell me about",
            'topic': "giraffes i don't want to talk about zebras"
        }),
        ("i'm interested in spiders", {
            'nav': "i'm interested in",
            'topic': 'spiders'
        }),
        ("i am interested in sports", {
            'nav': "i am interested in",
            'topic': 'sports'
        }),
        ("actually i'm really into arachnids", {
            'nav': "i'm really into",
            'topic': 'arachnids'
        }),
        ("hey what do you know about whales", {
            'nav_about': 'do you know about',
            'topic': 'whales'
        }),
        ("do you know anything about whales", {
            'nav_about': 'do you know anything about',
            'topic': 'whales'
        }),
        ("alexa do you know much i'm not sure if you do but yeah anything about whales",
         {
             'nav_about':
             "do you know much i'm not sure if you do but yeah anything about",
             'topic': 'whales'
         }),
        ("do you know whales live a hundred years", {
            'nav': 'do you know',
            'topic': 'whales live a hundred years'
        }),
        ("have you ever heard of ariel osbourne", {
            'nav': 'you ever heard of',
            'topic': 'ariel osbourne'
        }),
        ("what do you think about veganism", {
            'nav_about': 'what do you think about',
            'topic': 'veganism'
        }),
        ("let's switch topics what do you think is going to happen", {
            'nav': 'what do you think',
            'topic': 'is going to happen'
        }),
    ]
    negative_examples = [
        "into politics",
        "why do you want to talk about zebras",
        "stop talk about zebras",
        "don't talk about zebras",
        "i'm not interested in spiders",
        "why are you interested in spiders",
        "do you think i'm cool",
        "i haven't heard of it",
        "do you think so",
    ]
Пример #6
0
class NegativeNavigationTemplate(RegexTemplate):
    """
    This template captures when the user is expressing a negative navigational intent like
    "i don't want to talk about X", "i don't want to talk about", "i don't want to talk", "change the subject".
    """
    slots = {
        'change_the_subject':
        "(?<!don't )(change|new) (the )?(subject|category|topic)",
        'nav':
        one_or_more_spacesep(NEGATIVE_NAVIGATION),
        'nav_about':
        one_or_more_spacesep(['{} about'.format(oneof(NEGATIVE_NAVIGATION))]),
        'topic':
        NONEMPTY_TEXT,
    }
    templates = [
        OPTIONAL_TEXT_PRE + "{change_the_subject}" + OPTIONAL_TEXT_POST,
        OPTIONAL_TEXT_PRE + "{nav_about}( {topic})?",
        OPTIONAL_TEXT_PRE + "{nav}( {topic})?",
    ]
    positive_examples = [
        ('change the subject', {
            'change_the_subject': 'change the subject'
        }),
        ('change the topic', {
            'change_the_subject': 'change the topic'
        }),
        ('new subject', {
            'change_the_subject': 'new subject'
        }),
        ('can we change the category', {
            'change_the_subject': 'change the category'
        }),
        ('change subject', {
            'change_the_subject': 'change subject'
        }),
        ('alexa change the subject please', {
            'change_the_subject': 'change the subject'
        }),
        ('stop talking about', {
            'nav_about': 'stop talking about'
        }),
        ('stop talking about movies', {
            'nav_about': 'stop talking about',
            'topic': 'movies'
        }),
        ('oh my god please stop talking about movies', {
            'nav_about': 'stop talking about',
            'topic': 'movies'
        }),
        ("i don't think i wanna talk to you anymore", {
            'nav': "don't think i wanna talk to you",
            'topic': 'anymore'
        }),
        ("stop talking", {
            'nav': "stop talking"
        }),
        ("i'm not interested in spiders", {
            'nav': "not interested in",
            'topic': 'spiders'
        }),
        ("we were never really interested in spiders", {
            'nav': "never really interested in",
            'topic': 'spiders'
        }),
    ]
    negative_examples = [
        'talk about movies',
        "don't change the subject",
        "no don't change the subject",
        "why don't you want to talk about it",
        "i'm interested in spiders",
        "why are you interested in spiders",
    ]
Пример #7
0
    'telling',
]

THIS = [
    "this",
    "that",
    "it",
    'those',
    'any',
    'of',
]

SOMETHING_ELSE = [
    "((something|anything) )+(else|different)+",
    "((the|some) )*{}( (topic|subject|thing))*".format(
        one_or_more_spacesep(['other', 'next'])),
]

CONVERSANTS = [
    'i',
    'you',
    'alexa',
    'we',
    'us',
    'he',
    'she',
    'they',
    "i'm",
    "you're",
    "we're",
    "she's",