def process(cls, params): Validator.process(params) if 'error' in params: cls.LOGGER.error(message=params['error']) abort(404, message=params['error']) StandardNLP.process(params) FeatureExtractor.process(params) Classifier.process(params) Executor.process(params) Logger.process(params) Sanitizer.process(params)
def climbing(examples, services, step_size): """ Returns the set of services to climb on if any. """ to_be_climbed = set() for service, queries in examples.iteritems(): current = services[service] for query in queries: confidences, keywords = get_confs_kws(query, services) chosen_name = max(confidences.keys(), key=confidences.get) conf = confidences[chosen_name] if chosen_name != service and conf >= THRESHOLD: # Here the query was misclassified chosen = services[chosen_name] for kw in keywords: original = kw if kw in chosen._variables: # traverse through dummies while isinstance(chosen._variables[kw], str): kw = chosen._variables[kw] chosen._variables[kw] -= step_size kw = original if kw in current._variables: # traverse through dummies while isinstance(current._variables[kw], str): kw = current._variables[kw] current._variables[kw] += step_size Logger.log_heuristic('"{}"'.format(query)) Logger.log_heuristic( 'was supposed to be in {}'.format(service)) Logger.log_heuristic('was in {}'.format(chosen_name)) Logger.log_heuristic( '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') to_be_climbed.add(chosen_name) to_be_climbed.add(service) return to_be_climbed