def runTest(self): rule = grammar.connected(grammar.Any('hiphop'), grammar.Any('dance')) self.matchRule(rule, 'hiphop dance') self.matchRule(rule, 'hiphop & salsa dance') self.matchRule(rule, 'hiphop&salsa dance') self.notMatchRule(rule, 'hiphop. salsa dance') self.notMatchRule(rule, 'hiphop and salsa. dance') self.notMatchRule(rule, 'hiphop and other music where we dance') # Ensure our 'intermediate word' doesn't match falsely! class_blues = grammar.commutative_connected( grammar.Any('int'), grammar.Any('blues'), ) self.notMatchRule(class_blues, 'international blues')
def runTest(self): self.matchRule(dance_keywords.CLASS, 'beginner breakdance') self.matchRule(dance_keywords.CLASS, 'beginner') self.matchRule(dance_keywords.EASY_DANCE, u'χορός') self.matchRule(dance_keywords.EASY_DANCE, u'www.danceaholics.co.uk') self.matchRule(all_styles.DANCE_WRONG_STYLE, 'khaligi-belly') self.matchRule(rules.GOOD_DANCE, 'hiphop dance') self.notMatchRule(rules.GOOD_DANCE, 'hiphop.\ndance') #self.matchRule(rules., 'classic w/ mark oliver') self.notMatchRule(grammar.Any('[ck]\W?i\W?'), u'wej\u015bci\xf3wka!') # Ensure commutative_connected self.matchRule(rules.GOOD_DANCE, 'lock dance') self.matchRule(rules.GOOD_DANCE, 'lockdance')
def get_preprocess_removal(cls): return { 'fr': grammar.Any('dans'), # in 'ro': grammar.Any('a'), # of (not 'and') }
def get_preprocess_removal(cls): return { 'it': grammar.Any('poi') # then }
if regex_style.get_name() not in verticals: regex = regex_style.get_cached_basic_regex() if regex: regexes.add(regex) regexes.update(misc_keyword_sets) return regexes # Classifiers need to generate a BAD_KEYWORDS of "other" styles of dance, # which are dependent on having access to all the other styles of dance. # # So let's generate a regex of "other dance styles" for each style, # and use it to construct a Classifier once (and all its associated regexes). # CLASSIFIERS = {} for style in _STYLE_LIST: other_style_regexes = all_styles_except(style.get_name()) CLASSIFIERS[style.get_name()] = style.get_classifier(other_style_regexes) _global_preprocess_removal = {} for style in _STYLE_LIST: for language, rule in style.get_preprocess_removal().iteritems(): if language not in _global_preprocess_removal: _global_preprocess_removal[language] = [] _global_preprocess_removal[language].append(rule) PREPROCESS_REMOVAL = {} for language, rules in _global_preprocess_removal.iteritems(): PREPROCESS_REMOVAL[language] = grammar.Name( 'PREPROCESS_REMOVAL_%s' % language, grammar.Any(*rules))
def get_preprocess_removal(cls): return { None: grammar.Any('brentford lock'), }
def get_basic_regex_new(cls): return grammar.Any( cls._get_classifier().SUPER_STRONG_KEYWORDS, cls._get_classifier().GOOD_DANCE, cls._get_classifier().AMBIGUOUS_DANCE, )
class Classifier(street.StreetBaseClassifier): GOOD_DANCE = keywords.STYLE_POP AMBIGUOUS_DANCE = keywords.STYLE_POP_WEAK GOOD_BAD_PAIRINGS = [ (grammar.Any(keywords.STYLE_POP, 'pop'), keywords.WRONG_POP), ]