Example usage for org.deeplearning4j.text.documentiterator LabelAwareIterator getLabelsSource

List of usage examples for org.deeplearning4j.text.documentiterator LabelAwareIterator getLabelsSource

Introduction

In this page you can find the example usage for org.deeplearning4j.text.documentiterator LabelAwareIterator getLabelsSource.

Prototype

LabelsSource getLabelsSource();

Source Link

Usage

From source file:com.github.tteofili.p2h.Par2HierUtils.java

License:Apache License

/**
 * transforms paragraph vectors into hierarchical vectors
 * @param iterator iterator over docs//from  ww  w. j  a v  a 2s.  c  o m
 * @param lookupTable the paragraph vector table
 * @param labels the labels
 * @param k the no. of centroids
 * @return a map doc->hierarchical vector
 */
static Map<String, INDArray> getPar2Hier(LabelAwareIterator iterator, WeightLookupTable<VocabWord> lookupTable,
        List<String> labels, int k, Method method) {
    Collections.sort(labels);
    LabelsSource labelsSource = iterator.getLabelsSource();
    PatriciaTrie<String> trie = new PatriciaTrie<>();
    for (String label : labels) {
        trie.put(label, label);
    }

    Map<String, INDArray> hvs = new TreeMap<>();
    // for each doc
    for (String node : labelsSource.getLabels()) {
        Par2HierUtils.getPar2HierVector(lookupTable, trie, node, k, hvs, method);
    }
    return hvs;
}