def translate_query(self, query_text): """ Perform the actual translation. :param query_text: :param relation_oracle: :param entity_oracle: :return: """ # Parse query. logger.info("Translating query: %s." % query_text) start_time = time.time() # Parse the query. query = self.parse_and_identify_entities(query_text) # Set the relation oracle. query.relation_oracle = self.scorer.get_parameters().relation_oracle # Identify the target type. target_identifier = AnswerTypeIdentifier() target_identifier.identify_target(query) # Get content tokens of the query. query.query_content_tokens = get_content_tokens(query.query_tokens) # Match the patterns. pattern_matcher = QueryPatternMatcher(query, self.query_extender, self.sparql_backend) ert_matches = [] ermrt_matches = [] ermrert_matches = [] ert_matches = pattern_matcher.match_ERT_pattern() ermrt_matches = pattern_matcher.match_ERMRT_pattern() ermrert_matches = pattern_matcher.match_ERMRERT_pattern() duration = (time.time() - start_time) * 1000 logging.info("Total translation time: %.2f ms." % duration) return ert_matches + ermrt_matches + ermrert_matches