Package org.carrot2.core

Examples of org.carrot2.core.Cluster


public class PrecisionRecallMetricTest extends IdealPartitioningBasedMetricTest
{
    @Test
    public void testEmptyCluster()
    {
        check(null, null, null, new Cluster());
    }
View Full Code Here


    }

    @Test
    public void testTrivialCluster()
    {
        check(1.0, 1.0, 1.0, new Cluster("test", documentWithPartitions("test")));
    }
View Full Code Here

    }

    @Test
    public void testAllDocumentsInOtherTopics()
    {
        final Cluster otherTopics = clusterWithPartitions("t1", "t2", "t3");
        otherTopics.setOtherTopics(true);
        check(0.0, 0.0, 0.0, otherTopics);
    }
View Full Code Here

        final BitSet all = new BitSet(documents.size());
        final ArrayList<Document> docs = Lists.newArrayListWithCapacity(documents.size());
        final ArrayList<String> phrases = Lists.newArrayListWithCapacity(3);
        for (ClusterCandidate c : clusters)
        {
            final Cluster c2 = new Cluster();
            c2.addPhrases(collectPhrases(phrases, c));
            c2.addDocuments(collectDocuments(docs, c.documents));
            c2.setScore((double) c.score);
            this.clusters.add(c2);

            all.or(c.documents);
            docs.clear();
            phrases.clear();
View Full Code Here

            .generate(new String []
            {
                "cos.pl", "http://cos.pl/cos", "cos.pl/cos"
            });

        final List<Cluster> expectedFacets = Lists.newArrayList(new Cluster("cos.pl",
            docs.get(0), docs.get(1), docs.get(2)));

        final ArrayList<Cluster> actual = Lists.newArrayList(cluster(docs).getClusters());
        assertThatClusters(actual).isEquivalentTo(expectedFacets);
    }
View Full Code Here

            .generate(new String []
            {
                "www.cos.pl", "http://cos.pl/cos", "cos.pl/cos"
            });

        final List<Cluster> expectedFacets = Lists.newArrayList(new Cluster("cos.pl",
            docs.get(0), docs.get(1), docs.get(2)));

        assertThatClusters(cluster(docs).getClusters()).isEquivalentTo(expectedFacets);
    }
View Full Code Here

            {
                "mail.cos.pl", "http://cos.pl/cos", "cos.pl/cos", "mail.cos.pl"
            });

        final List<Cluster> expectedFacets = Lists.newArrayList();
        final Cluster facet11 = new Cluster("mail.cos.pl", docs.get(0), docs.get(3));
        final Cluster facet12 = new Cluster("Other Sites", docs.get(1), docs.get(2))
            .setOtherTopics(true);
        final Cluster facet1 = new Cluster("cos.pl").addSubclusters(facet11, facet12);
        expectedFacets.add(facet1);

        assertThatClusters(cluster(docs).getClusters()).isEquivalentTo(expectedFacets);
    }
View Full Code Here

            .generate(new String []
            {
                "cos.pl", "http://cos.pl/cos", "cos.com/cos", "cos.com", "cos.pl"
            });

        final List<Cluster> expectedFacets = Lists.newArrayList(new Cluster("cos.pl",
            docs.get(0), docs.get(1), docs.get(4)), new Cluster("cos.com", docs.get(2),
            docs.get(3)));

        assertThatClusters(cluster(docs).getClusters()).isEquivalentTo(expectedFacets);
    }
View Full Code Here

        final Document d21 = documentWithField("2");
        final Document d22 = documentWithField("2");
        final Document dn = documentWithField(null);
        final List<Document> documents = Lists.newArrayList(d11, d12, d21, d22, dn);

        check(documents, Lists.<Cluster> newArrayList(new Cluster("1", d11, d12),
            new Cluster("2", d21, d22)), dn);
    }
View Full Code Here

        final Document d21 = documentWithField(Lists.newArrayList("21", "22"));
        final Document d22 = documentWithField(Lists.newArrayList("23"));
        final Document dn = documentWithField(null);
        final List<Document> documents = Lists.newArrayList(d11, d12, d21, d22, dn);

        check(documents, Lists.<Cluster> newArrayList(new Cluster("11", d11, d12),
            new Cluster("12", d11), new Cluster("21", d21), new Cluster("22", d21),
            new Cluster("23", d22)), dn);
    }
View Full Code Here

TOP

Related Classes of org.carrot2.core.Cluster

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.