Class/Object

com.intel.analytics.zoo.feature.text

TextSet

Related Docs: object TextSet | package text

Permalink

abstract class TextSet extends AnyRef

TextSet wraps a set of TextFeature.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TextSet
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TextSet()

    Permalink

Abstract Value Members

  1. abstract def generateWordIndexMap(removeTopN: Int = 0, maxWordsNum: Int = 5000, minFreq: Int = 1, existingMap: Map[String, Int] = null): Map[String, Int]

    Permalink

    Generate wordIndex map based on sorted word frequencies in descending order.

    Generate wordIndex map based on sorted word frequencies in descending order. Return the result map, which will also be stored in 'wordIndex'. Make sure you call this after tokenize. Otherwise you will get an exception. See word2idx for more details.

  2. abstract def isDistributed: Boolean

    Permalink

    Whether it is a DistributedTextSet.

  3. abstract def isLocal: Boolean

    Permalink

    Whether it is a LocalTextSet.

  4. abstract def loadWordIndex(path: String): TextSet

    Permalink

    Load the wordIndex map which was saved after the training, so that this TextSet can directly use this wordIndex during inference.

    Load the wordIndex map which was saved after the training, so that this TextSet can directly use this wordIndex during inference. Each separate line should be "word id".

    Note that after calling loadWordIndex, you do not need to specify any argument when calling word2idx in the preprocessing pipeline as now you are using exactly the loaded wordIndex for transformation.

    For LocalTextSet, load txt from a local file system. For DistributedTextSet, load txt from a local or distributed file system (such as HDFS).

    path

    The path to the text file.

  5. abstract def randomSplit(weights: Array[Double]): Array[TextSet]

    Permalink

    Randomly split into array of TextSet with provided weights.

    Randomly split into array of TextSet with provided weights. Only available for DistributedTextSet for now.

    weights

    Array of Double indicating the split portions.

  6. abstract def toDataSet: DataSet[Sample[Float]]

    Permalink

    Convert TextSet to DataSet of Sample.

  7. abstract def toDistributed(sc: SparkContext = null, partitionNum: Int = 4): DistributedTextSet

    Permalink

    Convert to a DistributedTextSet.

    Convert to a DistributedTextSet.

    Need to specify SparkContext to convert a LocalTextSet to a DistributedTextSet. In this case, you may also want to specify partitionNum, the default of which is 4.

  8. abstract def toLocal(): LocalTextSet

    Permalink

    Convert to a LocalTextSet.

  9. abstract def transform(transformer: Preprocessing[TextFeature, TextFeature]): TextSet

    Permalink

    Transform from one TextSet to another.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ->(transformer: Preprocessing[TextFeature, TextFeature]): TextSet

    Permalink
  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def generateSample(): TextSet

    Permalink

    Generate BigDL Sample.

    Generate BigDL Sample. Need to word2idx first. See TextFeatureToSample for more details.

  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def getWordIndex: Map[String, Int]

    Permalink

    Get the word index map of this TextSet.

    Get the word index map of this TextSet. If the TextSet hasn't been transformed from word to index, null will be returned.

  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def normalize(): TextSet

    Permalink

    Do normalization on tokens.

    Do normalization on tokens. Need to tokenize first. See Normalizer for more details.

  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. def saveWordIndex(path: String): Unit

    Permalink

    Save wordIndex map to text file, which can be used for future inference.

    Save wordIndex map to text file, which can be used for future inference. Each separate line will be "word id".

    For LocalTextSet, save txt to a local file system. For DistributedTextSet, save txt to a local or distributed file system (such as HDFS).

    path

    The path to the text file.

  20. def setWordIndex(vocab: Map[String, Int]): TextSet.this.type

    Permalink

    Assign a wordIndex map for this TextSet to use during word2idx.

    Assign a wordIndex map for this TextSet to use during word2idx. If you load the wordIndex from the saved file, you are recommended to use loadWordIndex directly.

    vocab

    Map of each word (String) and its index (integer).

  21. def shapeSequence(len: Int, truncMode: TruncMode = TruncMode.pre, padElement: Int = 0): TextSet

    Permalink

    Shape the sequence of indices to a fixed length.

    Shape the sequence of indices to a fixed length. Need to word2idx first. See SequenceShaper for more details.

  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. def tokenize(): TextSet

    Permalink

    Do tokenization on original text.

    Do tokenization on original text. See Tokenizer for more details.

  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. def word2idx(removeTopN: Int = 0, maxWordsNum: Int = 1, minFreq: Int = 1, existingMap: Map[String, Int] = null): TextSet

    Permalink

    Map word tokens to indices.

    Map word tokens to indices. Important: Take care that this method behaves a bit differently for training and inference.


    During the training, you need to generate a new wordIndex map according to the texts you are dealing with. Thus this method will first do the map generation and then convert words to indices based on the generated map. You can specify the following arguments which pose some constraints when generating the map. In the result map, index will start from 1 and corresponds to the occurrence frequency of each word sorted in descending order. Here we adopt the convention that index 0 will be reserved for unknown words. After word2idx, you can get the generated wordIndex map by calling 'getWordIndex'. Also, you can call saveWordIndex to save this wordIndex map to be used in future training.

    removeTopN

    Non-negative integer. Remove the topN words with highest frequencies in the case where those are treated as stopwords. Default is 0, namely remove nothing.

    maxWordsNum

    Integer. The maximum number of words to be taken into consideration. Default is -1, namely all words will be considered. Otherwise, it should be a positive integer.

    minFreq

    Positive integer. Only those words with frequency >= minFreq will be taken into consideration. Default is 1, namely all words that occur will be considered.

    existingMap

    Existing map of word index if any. Default is null and in this case a new map with index starting from 1 will be generated. If not null, then the generated map will preserve the word index in existingMap and assign subsequent indices to new words. ---------------------------------------Inference-------------------------------------------- During the inference, you are supposed to use exactly the same wordIndex map as in the training stage instead of generating a new one. Thus please be aware that you do not need to specify any of the above arguments. You need to call loadWordIndex or setWordIndex beforehand for map loading. Need to tokenize first. See WordIndexer for more details.

Inherited from AnyRef

Inherited from Any

Ungrouped