Package org.carrot2.core

Examples of org.carrot2.core.Cluster


        .getLexicalData(LanguageCode.MALTESE);

    for (String word : wordsToCheck.split(",")) {
      if (!lexicalData.isCommonWord(new MutableCharArray(word))
          && !lexicalData.isStopLabel(word)) {
        clusters.add(new Cluster(word));
      }
    }
  }
View Full Code Here


   
    private static List<Cluster> sanityCheck(List<Cluster> in, Predicate<Document> docFilter)
    {
        List<Cluster> cloned = Lists.newArrayListWithCapacity(in.size());
        for (Cluster c : in) {
            Cluster c2 = new Cluster();
            c2.addPhrases(c.getPhrases());
            c2.addDocuments(
                Iterables.filter(c.getDocuments(), docFilter));
            c2.addSubclusters(sanityCheck(c.getSubclusters(), docFilter));
            cloned.add(c2);
        }
        return cloned;
    }   
View Full Code Here

        final Document d1 = new Document();
        final Document d2 = documentWithPartitions("test");
        documents.add(d1);

        final Cluster c1 = new Cluster("test", d1);
        clusters.add(c1);

        metric.calculate();
        checkAllMetricsNull(c1);
View Full Code Here

        return document;
    }

    protected Cluster clusterWithPartitions(final String... partitions)
    {
        final Cluster cluster = new Cluster();

        for (String partition : partitions)
        {
            cluster.addDocuments(documentWithPartitions(partition));
        }

        return cluster;
    }
View Full Code Here

        };
    }

    protected Cluster [] hardClustersWithOverlappingPartitions()
    {
        final Cluster c1 = new Cluster("c1", documentWithPartitions("t1"),
            documentWithPartitions("t1"));
        final Cluster c2 = new Cluster("c2", documentWithPartitions("t1", "t2"),
            documentWithPartitions("t2"));
        return new Cluster []
        {
            c1, c2
        };
View Full Code Here

    }

    protected Cluster [] overlappingClustersWithHardPartitions()
    {
        final Document document = documentWithPartitions("t2");
        final Cluster c1 = new Cluster("c1", documentWithPartitions("t1"),
            documentWithPartitions("t1"), document);
        final Cluster c2 = new Cluster("c2", document, documentWithPartitions("t2"));
        return new Cluster []
        {
            c1, c2
        };
    }
View Full Code Here

    }

    protected Cluster [] overlappingClustersWithOverlappingPartitions()
    {
        final Document documentWithTwoPartitions = documentWithPartitions("t1", "t2");
        final Cluster c1 = new Cluster("c1", documentWithPartitions("t1"),
            documentWithPartitions("t1"), documentWithTwoPartitions);
        final Cluster c2 = new Cluster("c2", documentWithTwoPartitions,
            documentWithPartitions("t2"));
        return new Cluster []
        {
            c1, c2
        };
View Full Code Here

    }

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

    }

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

    }

    @Test
    public void testAllDocumentsInOtherTopics()
    {
        final Cluster otherTopics = clusterWithPartitions("t1", "t2", "t3");
        otherTopics.setOtherTopics(true);
        check(otherTopics, null);
    }
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.