Class SequenceElement

    • Field Detail

      • elementFrequency

        protected org.nd4j.shade.guava.util.concurrent.AtomicDouble elementFrequency
      • index

        protected int index
      • codeLength

        protected short codeLength
      • special

        protected boolean special
      • isLabel

        protected boolean isLabel
      • sequencesCount

        protected AtomicLong sequencesCount
      • init

        protected boolean init
      • storageId

        protected Long storageId
      • isLocked

        protected boolean isLocked
    • Constructor Detail

      • SequenceElement

        public SequenceElement()
    • Method Detail

      • getLabel

        public abstract String getLabel()
        This method should return string representation of this SequenceElement, so it can be used for
        Returns:
      • getSequencesCount

        public long getSequencesCount()
        This method returns number of documents/sequences where this element was evidenced
        Returns:
      • setSequencesCount

        public void setSequencesCount​(long count)
        This method sets documents count to specified value
        Parameters:
        count -
      • incrementSequencesCount

        public void incrementSequencesCount()
        Increments document count by one
      • incrementSequencesCount

        public void incrementSequencesCount​(long count)
        Increments document count by specified value
        Parameters:
        count -
      • isLabel

        public boolean isLabel()
        Returns whether this element was defined as label, or no
        Returns:
      • markAsLabel

        public void markAsLabel​(boolean isLabel)
        This method specifies, whether this element should be treated as label for some sequence/document or not.
        Parameters:
        isLabel -
      • getElementFrequency

        public double getElementFrequency()
        This method returns SequenceElement's frequency in current training corpus.
        Returns:
      • setElementFrequency

        public void setElementFrequency​(long value)
        This method sets frequency value for this element
        Parameters:
        value -
      • incrementElementFrequency

        public void incrementElementFrequency()
        Increases element frequency counter by 1
      • increaseElementFrequency

        public void increaseElementFrequency​(int by)
        Increases element frequency counter by argument
        Parameters:
        by -
      • equals

        public boolean equals​(Object object)
        Equals method override should be properly implemented for any extended class, otherwise it will be based on label equality
        Overrides:
        equals in class Object
        Parameters:
        object -
        Returns:
      • getIndex

        public int getIndex()
        Returns index in Huffman tree
        Returns:
        index >= 0, if tree was built, -1 otherwise
      • setIndex

        public void setIndex​(int index)
        Sets index in Huffman tree
        Parameters:
        index -
      • getCodes

        public List<Byte> getCodes()
        Returns Huffman tree codes
        Returns:
      • setCodes

        public void setCodes​(List<Byte> codes)
        Sets Huffman tree codes
        Parameters:
        codes -
      • getPoints

        public List<Integer> getPoints()
        Returns Huffman tree points
        Returns:
      • setPoints

        public void setPoints​(List<Integer> points)
        Sets Huffman tree points
        Parameters:
        points -
      • setPoints

        public void setPoints​(int[] points)
        Sets Huffman tree points
        Parameters:
        points -
      • getCodeLength

        public int getCodeLength()
        Returns Huffman code length. Please note: maximum vocabulary/tree size depends on code length
        Returns:
      • setCodeLength

        public void setCodeLength​(short codeLength)
        This method fills codes and points up to codeLength
        Parameters:
        codeLength -
      • getLongHash

        public static final long getLongHash​(@NonNull
                                             @NonNull String string)
      • getGradient

        @Deprecated
        public double getGradient​(int index,
                                  double g,
                                  double lr)
        Deprecated.
        Returns gradient for this specific element, at specific position
        Parameters:
        index -
        g -
        lr -
        Returns:
      • setHistoricalGradient

        @Deprecated
        public void setHistoricalGradient​(org.nd4j.linalg.api.ndarray.INDArray gradient)
        Deprecated.
      • getHistoricalGradient

        @Deprecated
        public org.nd4j.linalg.api.ndarray.INDArray getHistoricalGradient()
        Deprecated.
      • hashCode

        public int hashCode()
        hashCode method override should be properly implemented for any extended class, otherwise it will be based on label hashCode
        Overrides:
        hashCode in class Object
        Returns:
        hashCode for this SequenceElement
      • toJSON

        public abstract String toJSON()
        Returns:
      • getStorageId

        public Long getStorageId()
      • mapper

        public static org.nd4j.shade.jackson.databind.ObjectMapper mapper()