def init_from_config():
     config_params = globals.config
     sparql_backend = globals.get_sparql_backend(config_params)
     query_extender = QueryCandidateExtender.init_from_config()
     entity_linker = EntityLinker.init_from_config()
     parser = CoreNLPParser.init_from_config()
     scorer_obj = ranker.SimpleScoreRanker('DefaultScorer')
     return QueryTranslator(sparql_backend, query_extender, entity_linker,
                            parser, scorer_obj)
예제 #2
0
 def init_from_config():
     config_params = globals.config
     sparql_backend = globals.get_sparql_backend(config_params)
     query_extender = QueryCandidateExtender.init_from_config()
     entity_linker = EntityLinker.init_from_config()
     parser = CoreNLPParser.init_from_config()
     scorer_obj = ranker.SimpleScoreRanker('DefaultScorer')
     return QueryTranslator(sparql_backend, query_extender,
                            entity_linker, parser, scorer_obj)
예제 #3
0
파일: translator.py 프로젝트: DenXX/aqqu
    def get_from_config(cls, config_params):
        sparql_backend = globals.get_sparql_backend(config_params)
        query_extender = QueryCandidateExtender.init_from_config()
        entity_linker = globals.get_entity_linker()
        parser = globals.get_parser()
        scorer_obj = ranker.SimpleScoreRanker('DefaultScorer')
        ngram_notable_types_npmi_path = config_params.get('QueryCandidateExtender', 'ngram-notable-types-npmi', '')
        notable_types_npmi_threshold = float(config_params.get('QueryCandidateExtender', 'notable-types-npmi-threshold'))
        ngram_notable_types_npmi = None
        if ngram_notable_types_npmi_path and os.path.exists(ngram_notable_types_npmi_path):
            import cPickle as pickle
            try:
                with open(ngram_notable_types_npmi_path, 'rb') as inp:
                    logger.info("Loading types model from disk...")
                    ngram_notable_types_npmi = pickle.load(inp)
            except IOError as exc:
                logger.error("Error reading types model: %s" % str(exc))
                ngram_notable_types_npmi = None

        return SparqlQueryTranslator(sparql_backend, query_extender,
                                     entity_linker, parser, scorer_obj,
                                     ngram_notable_types_npmi,
                                     notable_types_npmi_threshold)