Java Code Examples for gnu.trove.list.TIntList#addAll()

The following examples show how to use gnu.trove.list.TIntList#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortedNeighborhoodBlocking.java    From JedAIToolkit with Apache License 2.0 6 votes vote down vote up
protected int[] getMixedSortedEntities(String[] sortedTerms) {
    int datasetLimit = entityProfilesD1.size();
    final TIntList sortedEntityIds = new TIntArrayList();

    for (String blockingKey : sortedTerms) {
        final TIntList sortedIds = new TIntArrayList();
        final TIntList d1EntityIds = invertedIndexD1.get(blockingKey);
        if (d1EntityIds != null) {
            sortedIds.addAll(d1EntityIds);
        }

        final TIntList d2EntityIds = invertedIndexD2.get(blockingKey);
        if (d2EntityIds != null) {
            for (TIntIterator iterator = d2EntityIds.iterator(); iterator.hasNext();) {
                sortedIds.add(datasetLimit + iterator.next());
            }
        }

        sortedIds.shuffle(random);
        sortedEntityIds.addAll(sortedIds);
    }

    return sortedEntityIds.toArray();
}
 
Example 2
Source File: DateEncoder.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns an array containing the sub-field bucket indices for
 * each sub-field of the inputData. To get the associated field names for each of
 * the buckets, call getScalarNames().
 * @param  	input 	The data from the source. This is typically a object with members.
 *
 * @return 	array of bucket indices
 */
public int[] getBucketIndices(DateTime input) {

    TDoubleList scalars = getScalars(input);

    TIntList l = new TIntArrayList();
    List<EncoderTuple> encoders = getEncoders(this);
    if(encoders != null && encoders.size() > 0) {
        int i = 0;
        for(EncoderTuple t : encoders) {
            l.addAll(t.getEncoder().getBucketIndices(scalars.get(i)));
            ++i;
        }
    }else{
        throw new IllegalStateException("Should be implemented in base classes that are not " +
                "containers for other encoders");
    }
    return l.toArray();
}
 
Example 3
Source File: DateEncoderTest.java    From htm.java with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Check bucket index support
 */
@Test
public void testBucketIndexSupport() {

    setUp();
    initDE();

    int[] bucketIndices = de.getBucketIndices(dt);
    System.out.println(String.format("bucket indices: %s", Arrays.toString(bucketIndices)));
    List<Encoding> bucketInfo = de.getBucketInfo(bucketIndices);

    List<Double> expectedList = Arrays.asList(320.25, 3.5, .167, 14.8);

    TIntList encodings = new TIntArrayList();

    for (int i = 0; i < bucketInfo.size(); i++) {
        Encoding r = bucketInfo.get(i);
        double actual = (double)r.getValue();
        double expected = expectedList.get(i);
        assertEquals(expected, actual, 4.0);

        encodings.addAll(r.getEncoding());
    }

    assertArrayEquals(expected, encodings.toArray());
}
 
Example 4
Source File: SortedNeighborhoodBlocking.java    From JedAIToolkit with Apache License 2.0 5 votes vote down vote up
protected int[] getSortedEntities(String[] sortedTerms) {
    final TIntList sortedEntityIds = new TIntArrayList();

    for (String blockingKey : sortedTerms) {
        final TIntList sortedIds = invertedIndexD1.get(blockingKey);
        sortedIds.shuffle(random);
        sortedEntityIds.addAll(sortedIds);
    }

    return sortedEntityIds.toArray();
}
 
Example 5
Source File: Encoder.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns an array containing the sub-field bucket indices for
    * each sub-field of the inputData. To get the associated field names for each of
    * the buckets, call getScalarNames().
 * @param  	input 	The data from the source. This is typically a object with members.
 *
 * @return 	array of bucket indices
 */
public int[] getBucketIndices(String input) {
	TIntList l = new TIntArrayList();
	Map<EncoderTuple, List<EncoderTuple>> encoders = getEncoders();
	if(encoders != null && encoders.size() > 0) {
		for(EncoderTuple t : encoders.keySet()) {
			l.addAll(t.getEncoder().getBucketIndices(input));
		}
	}else{
		throw new IllegalStateException("Should be implemented in base classes that are not " +
			"containers for other encoders");
	}
	return l.toArray();
}
 
Example 6
Source File: Encoder.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns an array containing the sub-field bucket indices for
    * each sub-field of the inputData. To get the associated field names for each of
    * the buckets, call getScalarNames().
 * @param  	input 	The data from the source. This is typically a object with members.
 *
 * @return 	array of bucket indices
 */
public int[] getBucketIndices(double input) {
	TIntList l = new TIntArrayList();
	Map<EncoderTuple, List<EncoderTuple>> encoders = getEncoders();
	if(encoders != null && encoders.size() > 0) {
		for(EncoderTuple t : encoders.keySet()) {
			l.addAll(t.getEncoder().getBucketIndices(input));
		}
	}else{
		throw new IllegalStateException("Should be implemented in base classes that are not " +
			"containers for other encoders");
	}
	return l.toArray();
}