it.unimi.dsi.fastutil.ints.Int2FloatAVLTreeMap Java Examples

The following examples show how to use it.unimi.dsi.fastutil.ints.Int2FloatAVLTreeMap. 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: DataSelectorTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(0, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #2
Source File: DataSplitterTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(0, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #3
Source File: DataSorterTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(0, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #4
Source File: ReferenceModuleTestCase.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
private DataModule getDataModule() {
    List<KeyValue<KeyValue<String, Boolean>, Integer>> moduleDefinition = new LinkedList<>();
    for (int index = 0; index < order; index++) {
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("quality", true), 1));
        moduleDefinition.add(new KeyValue<>(new KeyValue<>("ontinuous", false), 1));
    }
    DataModule module = new SparseModule(moduleName, moduleDefinition, instanceCapacity);
    Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
    Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
    for (int index = 0; index < instanceCapacity; index++) {
        qualityFeatures.clear();
        qualityFeatures.put(index, index);
        module.associateInstance(qualityFeatures, quantityFeatures);
    }
    return module;
}
 
Example #5
Source File: ReferenceModuleTestCase.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssociateInstance() {
    DataModule module = getDataModule();
    IntegerArray references = new IntegerArray(instanceCapacity, instanceCapacity);
    module = new ReferenceModule(references, module);
    Assert.assertEquals(0, module.getSize());

    try {
        Int2IntSortedMap qualityFeatures = new Int2IntAVLTreeMap();
        Int2FloatSortedMap quantityFeatures = new Int2FloatAVLTreeMap();
        module.associateInstance(qualityFeatures, quantityFeatures);
        Assert.fail();
    } catch (UnsupportedOperationException exception) {
    }
}
 
Example #6
Source File: TFIDFModel.java    From jstarcraft-rns with Apache License 2.0 5 votes vote down vote up
public VectorTermFrequency(MathVector vector) {
    super(new Int2FloatAVLTreeMap(), vector.getElementSize());

    for (VectorScalar scalar : vector) {
        keyValues.put(scalar.getIndex(), scalar.getValue());
    }
}
 
Example #7
Source File: CorrelationTestCase.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    String[][] documents = {

            { "框架", "框架", "框架", "框架", "框架" },

            { "目标", "提供", "通用", "Java", "核心", "编程", "框架", "搭建", "框架", "项目" },

            { "领域", "研发人员", "专注", "高层", "设计", "关注", "底层", "实现" },

            { "涵盖", "编解码", "资源", "脚本", "监控", "通讯", "事件", "事务" },

            {} };

    List<TermFrequency> tfs = new ArrayList<>(documents.length);
    for (String[] document : documents) {
        tfs.add(new CountTermFrequency(new Int2FloatAVLTreeMap(), convert(document)));
    }
    InverseDocumentFrequency idf = new NaturalInverseDocumentFrequency(new Int2FloatAVLTreeMap(), tfs);

    Tfidf tfidf = new Tfidf(idf, tfs.toArray(new TermFrequency[tfs.size()]));
    Bm25 bm25 = new Bm25(1.2F, 0.75F, idf, tfs.toArray(new TermFrequency[tfs.size()]));

    for (int index = 0, size = documents.length; index < size; index++) {
        int[] indexes = convert(new String[] { "框架", "领域", "框架" });
        float left = tfidf.getCorrelation(index, indexes);
        float right = bm25.getCorrelation(index, indexes);

        Assert.assertTrue(left >= right);
    }
}
 
Example #8
Source File: NormalizationTermFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected TermFrequency getTermFrequency(List<Integer> document) {
    return new NormalizationTermFrequency(new Int2FloatAVLTreeMap(), 0.5F, document);
}
 
Example #9
Source File: ProbabilisticInverseDocumentFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected InverseDocumentFrequency getInverseDocumentFrequency(Collection<TermFrequency> documents) {
    return new ProbabilisticInverseDocumentFrequency(new Int2FloatAVLTreeMap(), documents);
}
 
Example #10
Source File: NaturalInverseDocumentFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected InverseDocumentFrequency getInverseDocumentFrequency(Collection<TermFrequency> documents) {
    return new NaturalInverseDocumentFrequency(new Int2FloatAVLTreeMap(), documents);
}
 
Example #11
Source File: UnaryInverseDocumentFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected InverseDocumentFrequency getInverseDocumentFrequency(Collection<TermFrequency> documents) {
    return new UnaryInverseDocumentFrequency(new Int2FloatAVLTreeMap(), documents);
}
 
Example #12
Source File: CountTermFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected TermFrequency getTermFrequency(List<Integer> document) {
    return new CountTermFrequency(new Int2FloatAVLTreeMap(), document);
}
 
Example #13
Source File: SmoothInverseDocumentFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected InverseDocumentFrequency getInverseDocumentFrequency(Collection<TermFrequency> documents) {
    return new SmoothInverseDocumentFrequency(new Int2FloatAVLTreeMap(), documents);
}
 
Example #14
Source File: MaximumInverseDocumentFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected InverseDocumentFrequency getInverseDocumentFrequency(Collection<TermFrequency> documents) {
    return new MaximumInverseDocumentFrequency(new Int2FloatAVLTreeMap(), documents);
}
 
Example #15
Source File: NaturalTermFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected TermFrequency getTermFrequency(List<Integer> document) {
    return new NaturalTermFrequency(new Int2FloatAVLTreeMap(), document);
}
 
Example #16
Source File: BinaryTermFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected TermFrequency getTermFrequency(List<Integer> document) {
    return new BinaryTermFrequency(new Int2FloatAVLTreeMap(), document);
}
 
Example #17
Source File: LogarithmTermFrequencyTestCase.java    From jstarcraft-ai with Apache License 2.0 4 votes vote down vote up
@Override
protected TermFrequency getTermFrequency(List<Integer> document) {
    return new LogarithmTermFrequency(new Int2FloatAVLTreeMap(), document);
}