Class EntityCachingAbstractSequencePriorBIO<IN extends CoreMap>

    • Field Detail

      • sequence

        protected int[] sequence
      • backgroundSymbol

        protected final int backgroundSymbol
      • numClasses

        protected final int numClasses
      • possibleValues

        protected final int[] possibleValues
    • Constructor Detail

      • EntityCachingAbstractSequencePriorBIO

        public EntityCachingAbstractSequencePriorBIO​(String backgroundSymbol,
                                                     Index<String> classIndex,
                                                     Index<String> tagIndex,
                                                     List<IN> doc)
    • Method Detail

      • leftWindow

        public int leftWindow()
        Description copied from interface: SequenceModel
        How many label positions to the left influence the label assignment at a particular position.
        Specified by:
        leftWindow in interface SequenceModel
        Returns:
        The size of the left window used by this sequence model
      • rightWindow

        public int rightWindow()
        Description copied from interface: SequenceModel
        How many label positions to the right influence the label assignment at a particular position.
        Specified by:
        rightWindow in interface SequenceModel
        Returns:
        the size of the right window used by this sequence model
      • getPossibleValues

        public int[] getPossibleValues​(int position)
        Description copied from interface: SequenceModel
        Return the valid sequence labels (as integer indices) for a particular position in the sequence. Since the sequence is padded at each end, typically sequence items 0...leftWindow-1 are null, leftWindow...length+leftWindow-1 are words, length+leftWindow...length+leftWindow+rightWindow-1 are null.
        Specified by:
        getPossibleValues in interface SequenceModel
        Parameters:
        position - The position
        Returns:
        The set of possible int values at this position, as an int array
      • scoreOf

        public double scoreOf​(int[] sequence,
                              int pos)
        Description copied from interface: SequenceModel
        Computes the score of the element at the given position in the sequence, conditioned on the values of the elements in all other positions of the provided sequence. Typically, this is an unnormalized log conditional probability of the label at the given position in the sequence, given the input data nd the other labels.
        Specified by:
        scoreOf in interface SequenceModel
        Parameters:
        sequence - The sequence containing the prediction and the rest of the labels to condition on
        pos - The position of the element to give a score for
        Returns:
        The score of the label at the specified position in the sequence
      • length

        public int length()
        Specified by:
        length in interface SequenceModel
        Returns:
        the length of the sequence
      • getNumClasses

        public int getNumClasses()
        get the number of classes in the sequence model.
      • getConditionalDistribution

        public double[] getConditionalDistribution​(int[] sequence,
                                                   int position)
      • scoresOf

        public double[] scoresOf​(int[] sequence,
                                 int position)
        Description copied from interface: SequenceModel
        Computes the scores of labels for the element at the given position in the sequence, conditioned on the values of the labels at all other positions of the provided sequence. The returned array elements correspond index-by-index to the possible values returned by getPossibleValues(int). The label at sequence[position] is ignored in the calculations. The scores are often given as an unnormalized log conditional distribution over possible labels. Otherwise, they may be probabilities. If it is a probability distribution, conceptually, the scores should sum to 1 (perhaps after transforming them). Note that implementations often alter sequence[position] to do their calculations, and so access to the array isn't threadsafe, but should restore its value afterwards.
        Specified by:
        scoresOf in interface SequenceModel
        Parameters:
        sequence - The sequence containing the rest of the values to condition on
        position - The position of the element to give a distribution for
        Returns:
        The scores of the possible tokens at the specified position in the sequence
      • setInitialSequence

        public void setInitialSequence​(int[] initialSequence)
        Description copied from interface: SequenceListener
        Informs this sequence listener that the value of the whole sequence is initialized to sequence.
        Specified by:
        setInitialSequence in interface SequenceListener
      • extractEntity

        public edu.stanford.nlp.ie.EntityBIO extractEntity​(int[] sequence,
                                                           int position,
                                                           String tag)
        extracts the entity starting at the given position and adds it to the entity list. returns the index of the last element in the entity (not index+1)
      • otherOccurrences

        public int[] otherOccurrences​(edu.stanford.nlp.ie.EntityBIO entity)
        finds other locations in the sequence where the sequence of words in this entity occurs.
      • toArray

        public static int[] toArray​(List<Integer> list)
      • matches

        public boolean matches​(edu.stanford.nlp.ie.EntityBIO entity,
                               int position)
      • updateSequenceElement

        public void updateSequenceElement​(int[] sequence,
                                          int position,
                                          int oldVal)
        Description copied from interface: SequenceListener
        Informs this sequence listener that the value of the element at position pos has changed. This allows this sequence model to update its internal model if desired.
        Specified by:
        updateSequenceElement in interface SequenceListener
      • toString

        public String toString​(int pos)