src/python/txtai/pipeline.py
def score(self, start, end, maxlength):
        """
        Scores all possible combinations of start and end index up to maxlength. Returns
        the best match.

        Args:
            start: start index scores
            end: end index scores
            maxlength: max number of tokens to allow in a match

        Returns:
            (start index, end index, score) of best scoring combination
        """

        # Score all possible combinations of start, end indices
        scores = np.matmul(np.expand_dims(start, -1), np.expand_dims(end, 1))

        # Zero out candidates with end < start and end - start > maxlength
        candidates = np.tril(np.triu(scores), maxlength - 1)

        # Get index of best rated combination
        # pylint: disable=E1101
        index = np.argmax(candidates.flatten())

        # Get (start, end, score) of best rated combination
        # pylint: disable=E1126, W0632
        start, end = np.unravel_index(index, candidates.shape)[1:]
        return start, end, candidates[0, start, end]

        Scores all possible combinations of start and end index up to maxlength. Returns
        the best match.

        Args:
            start: start index scores
            end: end index scores
            maxlength: max number of tokens to allow in a match

        Returns:
            (start index, end index, score) of best scoring combination
        
Scores all possible combinations of start and end index up to maxlength. Returns
the best match.
Scores all possible combinations of start and end index up to maxlength . Returns the best match .
def score(self, start, end, maxlength):
        scores = np.matmul(np.expand_dims(start, -1), np.expand_dims(end, 1))
        candidates = np.tril(np.triu(scores), maxlength - 1)
        index = np.argmax(candidates.flatten())
        start, end = np.unravel_index(index, candidates.shape)[1:]
        return start, end, candidates[0, start, end]
def score ( self , start , end , maxlength ) : scores = np . matmul ( np . expand_dims ( start , - 1 ) , np . expand_dims ( end , 1 ) ) candidates = np . tril ( np . triu ( scores ) , maxlength - 1 ) index = np . argmax ( candidates . flatten ( ) ) start , end = np . unravel_index ( index , candidates . shape ) [ 1 : ] return start , end , candidates [ 0 , start , end ]
Scores all possible combinations of start and end index up to maxlength.
Scores all possible combinations of start and end index up to maxlength .
"""
        Scores all possible combinations of start and end index up to maxlength. Returns
        the best match.

        Args:
            start: start index scores
            end: end index scores
            maxlength: max number of tokens to allow in a match

        Returns:
            (start index, end index, score) of best scoring combination
        """ # Score all possible combinations of start, end indices # Zero out candidates with end < start and end - start > maxlength # Get index of best rated combination # pylint: disable=E1101 # Get (start, end, score) of best rated combination # pylint: disable=E1126, W0632
(start index, end index, score) of best scoring combination
( start index end index score ) of best scoring combination
self
start
start index scores
start index scores
end
end index scores
end index scores
maxlength
max number of tokens to allow in a match
max number of tokens to allow in a match