Class Embedding.DefaultItem

    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultItem​(T defaultItem)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T decode​(byte[] byteArray)
      Decodes the given byte array into an object of input parameter type.
      NDArray embed​(NDManager manager, T[] items)
      Embeds an array of items.
      long embed​(T item)
      Embeds an item.
      byte[] encode​(T input)
      Encodes an object of input type into a byte array.
      boolean hasItem​(T item)
      Returns whether an item is in the embedding.
      java.util.Optional<T> unembed​(long index)
      Returns the item corresponding to the given index.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultItem

        public DefaultItem​(T defaultItem)
    • Method Detail

      • encode

        public byte[] encode​(T input)
                      throws java.io.IOException
        Encodes an object of input type into a byte array. This is used in saving and loading the Embedding objects.
        Specified by:
        encode in interface AbstractIndexedEmbedding<T>
        Parameters:
        input - the input object to be encoded
        Returns:
        the encoded byte array.
        Throws:
        java.io.IOException - if there is an error while encoding
      • decode

        public T decode​(byte[] byteArray)
                 throws java.io.IOException
        Decodes the given byte array into an object of input parameter type.
        Specified by:
        decode in interface AbstractIndexedEmbedding<T>
        Parameters:
        byteArray - the byte array to be decoded
        Returns:
        the decode object of input parameter type
        Throws:
        java.io.IOException - if there was an error while decoding
      • hasItem

        public boolean hasItem​(T item)
        Returns whether an item is in the embedding.
        Specified by:
        hasItem in interface AbstractEmbedding<T>
        Parameters:
        item - the item to test
        Returns:
        true if the item is in the embedding
      • embed

        public NDArray embed​(NDManager manager,
                             T[] items)
        Embeds an array of items.
        Specified by:
        embed in interface AbstractEmbedding<T>
        Parameters:
        manager - the manager for the new embeddings
        items - the items to embed
        Returns:
        the embedding NDArray of Shape(items.length, embeddingSize)
      • embed

        public long embed​(T item)
        Embeds an item.
        Specified by:
        embed in interface AbstractIndexedEmbedding<T>
        Parameters:
        item - the item to embed
        Returns:
        the index of the item in the embedding
      • unembed

        public java.util.Optional<T> unembed​(long index)
        Returns the item corresponding to the given index.
        Specified by:
        unembed in interface AbstractIndexedEmbedding<T>
        Parameters:
        index - the index
        Returns:
        the item corresponding to the given index