Class FeatureSequence

    • Constructor Detail

      • FeatureSequence

        public FeatureSequence​(Alphabet dict,
                               int[] features)
        Creates a FeatureSequence given all of the objects in the sequence.
        Parameters:
        dict - A dictionary that maps objects in the sequence to numeric indices.
        features - An array where features[i] gives the index in dict of the ith element of the sequence.
      • FeatureSequence

        public FeatureSequence​(Alphabet dict,
                               int[] features,
                               int len)
      • FeatureSequence

        public FeatureSequence​(Alphabet dict,
                               int capacity)
      • FeatureSequence

        public FeatureSequence​(Alphabet dict)
    • Method Detail

      • getFeatures

        public int[] getFeatures()
      • getLength

        public final int getLength()
      • size

        public final int size()
        Specified by:
        size in interface Sequence
      • getIndexAtPosition

        public final int getIndexAtPosition​(int pos)
      • getObjectAtPosition

        public java.lang.Object getObjectAtPosition​(int pos)
      • get

        public java.lang.Object get​(int pos)
        Specified by:
        get in interface Sequence
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • growIfNecessary

        protected void growIfNecessary()
      • add

        public void add​(int featureIndex)
      • add

        public void add​(java.lang.Object key)
      • addFeatureWeightsTo

        public void addFeatureWeightsTo​(double[] weights)
      • addFeatureWeightsTo

        public void addFeatureWeightsTo​(double[] weights,
                                        double scale)
      • toFeatureIndexSequence

        public int[] toFeatureIndexSequence()
      • toSortedFeatureIndexSequence

        public int[] toSortedFeatureIndexSequence()
      • prune

        public void prune​(Alphabet newAlphabet)
        Remove features from the sequence that occur fewer than cutoff times in the corpus, as indicated by the provided counts. Also swap in the new, reduced alphabet. This method alters the instance in place; it is not appropriate if the original instance will be needed.
      • prune

        public void prune​(double[] counts,
                          Alphabet newAlphabet,
                          int cutoff)
        Remove features from the sequence that occur fewer than cutoff times in the corpus, as indicated by the provided counts. Also swap in the new, reduced alphabet. This method alters the instance in place; it is not appropriate if the original instance will be needed.