nerd/nerd_client.py
def disambiguate_query(self, query, language=None, entities=None):
        """ Call the disambiguation service in order to disambiguate a search query.

        Args:
            text (str): Query to be disambiguated.
            language (str): language of text (if known)
            entities (list): list of entities or mentions to be supplied by
                the user.

        Returns:
            dict, int: API response and API status.
        """

        body = {
            "shortText": query,
            "entities": [],
            "onlyNER": "false",
            "customisation": "generic"
        }

        if language:
            body['language'] = {"lang": language}

        if entities:
            body['entities'] = entities

        files = {'query': str(body)}

        logger.debug('About to submit the following query {}'.format(body))

        res, status = self.post(
            self.disambiguate_service,
            files=files,
            headers={'Accept': 'application/json'},
        )

        if status == 200:
            return self.decode(res), status
        else:
            logger.debug('Disambiguation failed.')
            return None, status
def disambiguate_query(self, query, language=None, entities=None):
        body = {
            "shortText": query,
            "entities": [],
            "onlyNER": "false",
            "customisation": "generic"
        }

        if language:
            body['language'] = {"lang": language}

        if entities:
            body['entities'] = entities

        files = {'query': str(body)}

        logger.debug('About to submit the following query {}'.format(body))

        res, status = self.post(
            self.disambiguate_service,
            files=files,
            headers={'Accept': 'application/json'},
        )

        if status == 200:
            return self.decode(res), status
        else:
            logger.debug('Disambiguation failed.')
            return None, status
def disambiguate_query ( self , query , language = None , entities = None ) : body = { "shortText" : query , "entities" : [ ] , "onlyNER" : "false" , "customisation" : "generic" } if language : body [ 'language' ] = { "lang" : language } if entities : body [ 'entities' ] = entities files = { 'query' : str ( body ) } logger . debug ( 'About to submit the following query {}' . format ( body ) ) res , status = self . post ( self . disambiguate_service , files = files , headers = { 'Accept' : 'application/json' } , ) if status == 200 : return self . decode ( res ) , status else : logger . debug ( 'Disambiguation failed.' ) return None , status
Call the disambiguation service in order to disambiguate a search query.

        Args:
            text (str): Query to be disambiguated.
            language (str): language of text (if known)
            entities (list): list of entities or mentions to be supplied by
                the user.

        Returns:
            dict, int: API response and API status.
Call the disambiguation service in order to disambiguate a search query .