Package org.carrot2.core

Examples of org.carrot2.core.ProcessingResult


        /*
         * The controller is now ready to perform queries. To show that the documents from
         * the document input are cached, we will perform the same query twice and measure
         * the time for each query.
         */
        ProcessingResult result;
        long start, duration;

        final Map<String, Object> attributes;
        attributes = new HashMap<String, Object>();
        CommonAttributesDescriptor.attributeBuilder(attributes).query("data mining");
View Full Code Here


                .caseSensitive(false);

            /*
             * Invoke processing on the controller and display the result.
             */
            final ProcessingResult result = controller.process(params,
                ModuloDocumentSource.class,
                ByFirstTitleLetterClusteringAlgorithm.class);

            ConsoleFormatter.displayResults(result);
        } finally {
View Full Code Here

     * CARROT-1008: STC is not using term stems.
     */
    @Test
    public void testCarrot1008() throws Exception
    {
        ProcessingResult pr = ProcessingResult.deserialize(
            Resources.newInputStreamSupplier(
                Resources.getResource(this.getClass(), "CARROT-1008.xml")).getInput());

        STCClusteringAlgorithmDescriptor.attributeBuilder(processingAttributes)
            .maxClusters(30);

        pr = cluster(pr.getDocuments());

        dumpClusterLabels(pr);
        Set<String> clusterLabels = ClusteringAlgorithmTestBase.collectClusterLabels(pr);
        assertThat(
            clusterLabels.contains("Guns") &&
View Full Code Here

    /*
     *
     */
    private void emptySelection()
    {
        final ProcessingResult processingResult =
            this.editor.getSearchResult().getProcessingResult();

        if (processingResult == null)
        {
            target.clear();
View Full Code Here

        final Controller controller = ControllerFactory.createSimple();
        try
        {
            controller.init(attrs);
            ProcessingResult result = controller.process(
                Lists.newArrayList(document),
                query,
                QueryWordHighlighter.class);
           
            final Document highlightedDocument = result.getDocuments().get(0);
            assertThat(highlightedDocument.getField(Document.SUMMARY + QueryWordHighlighter.HIGHLIGHTED_FIELD_NAME_SUFFIX))
                .isEqualTo(expectedSnippet);
        }
        finally
        {
View Full Code Here

        final ILexicalData lexicalData2;

        // Use ctrl1
        {
            final Controller ctrl = ControllerFactory.createPooling();
            final ProcessingResult result = ctrl.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);

            lexicalData1 = result.getAttribute("english");
        }

        // Use ctrl1
        {
            final Controller ctrl = ControllerFactory.createPooling();
            final ProcessingResult result = ctrl.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);

            lexicalData2 = result.getAttribute("english");
        }

        assertSame(lexicalData1, lexicalData2);
    }
View Full Code Here

        {
            ctrl1.init(ImmutableMap.<String, Object> of(
                resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir1), classpathLocator)));

            final ProcessingResult result = ctrl1.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);

            data1 = result.getAttribute("english");
            assertTrue(data1.isCommonWord(new MutableCharArray("uniquea")));
        }

        // Create another pooling controller, same folder, but different resource lookup.
        final Controller ctrl2 = ControllerFactory.createPooling();
        final ILexicalData data2;
        {
            ctrl2.init(ImmutableMap.<String, Object> of(
                resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir1), classpathLocator)));

            final ProcessingResult result = ctrl2.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);

            data2 = result.getAttribute("english");
            assertTrue(data2.isCommonWord(new MutableCharArray("uniquea")));

            assertSame(data1, data2);
        }
View Full Code Here

                resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir1.getPath()), classpathLocator),
                resourceReloadKey,
                true));
   
            final ProcessingResult result = ctrl1.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);
            final ILexicalData data = result.getAttribute("english");

            assertTrue(data.isCommonWord(new MutableCharArray("uniquea")));
            assertFalse(data.isCommonWord(new MutableCharArray("uniqueb")));
        }

        // Create pooling controller, use tempDir2
        final Controller ctrl2 = ControllerFactory.createPooling();
        {
            ctrl2.init(ImmutableMap.<String, Object> of(resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir2.getPath()), classpathLocator)));
   
            final ProcessingResult result = ctrl2.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);
            final ILexicalData data = result.getAttribute("english");

            assertFalse(data.isCommonWord(new MutableCharArray("uniquea")));
            assertTrue(data.isCommonWord(new MutableCharArray("uniqueb")));
        }

        // Now, reuse the first controller, nothing should change.
        {
            final ProcessingResult result = ctrl1.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);
            final ILexicalData data = result.getAttribute("english");

            assertTrue(data.isCommonWord(new MutableCharArray("uniquea")));
            assertFalse(data.isCommonWord(new MutableCharArray("uniqueb")));
        }       
    }
View Full Code Here

        {
            filesClusteredTotal++;

            final Map<String, Object> attributes = Maps.newHashMap();
            attributes.put("XmlDocumentSource.xml", new FileResource(fileOrDirectory));
            final ProcessingResult result = controller.process(attributes,
                XmlDocumentSource.class.getName(), algorithm);

            // Stick to UTF-8 encoding on the output.
            final String outputFileName =
                Format.JSON.equals(outputFormat) && fileName.endsWith(".xml")
                ? fileName.substring(0, fileName .length() - 4) + ".json" : fileName;

            final OutputStream stream = new FileOutputStream(
                new File(currentOutputDir, outputFileName));
            try
            {
                if (Format.JSON.equals(outputFormat))
                {
                    Writer w = new OutputStreamWriter(stream, "UTF-8");
                    result.serializeJson(w, null, outputDocuments, true, outputAttributes);
                    w.flush();
                }
                else
                {
                    result.serialize(stream, outputDocuments, true, outputAttributes);
                }
            }
            finally
            {
                CloseableUtils.close(stream);
            }

            log.info("Clustering " + fileOrDirectory.getAbsolutePath() + " ["
                + result.getAttribute(AttributeNames.PROCESSING_TIME_TOTAL) + "ms]");
        }
    }
View Full Code Here

        setTitleToolTip(full);

        /*
         * Add the number of documents and clusters to the root form's title.
         */
        final ProcessingResult result = searchResult.getProcessingResult();
        if (result != null)
        {
            final int documents = result.getDocuments().size();
            final int clusters = result.getClusters().size();

            rootForm.setText(abbreviated + " (" + pluralize(documents, "document")
                + " from " + componentName(input.getSourceId()) + ", "
                + pluralize(clusters, "cluster") + " from "
                + componentName(input.getAlgorithmId()) + ")");
View Full Code Here

TOP

Related Classes of org.carrot2.core.ProcessingResult

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.