coordle/backend/coordle_backend.py
def search(self, query: Union[str, deque]) -> tuple:
        '''
        Given a string or deque, parse the thing. Returns None, None, errmsgs
        if string is malformatted. If given deque, it does no checks whether 
        query is right, so use it carefully. 
        '''
        if type(query) == str:
            queryqueue, errmsgs = self._preprocess_query(query)
        elif type(query) == deque:
            queryqueue, errmsgs = query, []
        else:
            raise ValueError(f'Got unsupported type for query, got {type(deque)}')

        # Happens only if queryqueue is empty
        if errmsgs is None:
            return [], [], []

        # If invalid query
        if queryqueue is None:
            return None, None, errmsgs

        # Parse queryqueue
        self.uidcache = {} 

        results = self.parse(queryqueue)

        results_list = np.array(list(results))
        scores = np.array([self.uidcache[doc.uid] for doc in results_list])

        sort_idx = np.argsort(scores)[::-1]
        results_list = results_list[sort_idx]
        scores = scores[sort_idx]

        scores = scores/scores.sum()*100

        return results_list, scores, errmsgs

        Given a string or deque, parse the thing. Returns None, None, errmsgs
        if string is malformatted. If given deque, it does no checks whether 
        query is right, so use it carefully. 
        
Given a string or deque, parse the thing. Returns None, None, errmsgs
if string is malformatted. If given deque, it does no checks whether
query is right, so use it carefully.
Given a string or deque parse the thing . Returns None None errmsgs if string is malformatted . If given deque it does no checks whether query is right so use it carefully .
def search(self, query: Union[str, deque]) -> tuple:
        if type(query) == str:
            queryqueue, errmsgs = self._preprocess_query(query)
        elif type(query) == deque:
            queryqueue, errmsgs = query, []
        else:
            raise ValueError(f'Got unsupported type for query, got {type(deque)}')
        if errmsgs is None:
            return [], [], []
        if queryqueue is None:
            return None, None, errmsgs
        self.uidcache = {} 
        results = self.parse(queryqueue)
        results_list = np.array(list(results))
        scores = np.array([self.uidcache[doc.uid] for doc in results_list])
        sort_idx = np.argsort(scores)[::-1]
        results_list = results_list[sort_idx]
        scores = scores[sort_idx]
        scores = scores/scores.sum()*100
        return results_list, scores, errmsgs
def search ( self , query : Union [ str , deque ] ) -> tuple : if type ( query ) == str : queryqueue , errmsgs = self . _preprocess_query ( query ) elif type ( query ) == deque : queryqueue , errmsgs = query , [ ] else : raise ValueError ( f'Got unsupported type for query, got {type(deque)}' ) if errmsgs is None : return [ ] , [ ] , [ ] if queryqueue is None : return None , None , errmsgs self . uidcache = { } results = self . parse ( queryqueue ) results_list = np . array ( list ( results ) ) scores = np . array ( [ self . uidcache [ doc . uid ] for doc in results_list ] ) sort_idx = np . argsort ( scores ) [ : : - 1 ] results_list = results_list [ sort_idx ] scores = scores [ sort_idx ] scores = scores / scores . sum ( ) * 100 return results_list , scores , errmsgs
Given a string or deque, parse the thing.
Given a string or deque parse the thing .
'''
        Given a string or deque, parse the thing. Returns None, None, errmsgs
        if string is malformatted. If given deque, it does no checks whether 
        query is right, so use it carefully. 
        ''' # Happens only if queryqueue is empty # If invalid query # Parse queryqueue
self
query
Union[str, deque]