Package org.carrot2.core

Examples of org.carrot2.core.ProcessingResult


    @SuppressWarnings("unchecked")
    private void handleMultiPart(HttpServletRequest request, HttpServletResponse response)
        throws IOException
    {
        final Map<String, Object> parameters = Maps.newHashMap();
        ProcessingResult input = null;

        final ServletFileUpload upload = new ServletFileUpload(new MemoryFileItemFactory());
        final List<FileItem> items;
        try
        {
View Full Code Here


        /*
         * We need to refer to the Lucene component by its identifier we set during
         * initialization. As we've not assigned any identifier to the
         * LingoClusteringAlgorithm we want to use, we can its fully qualified class name.
         */
        ProcessingResult process = controller.process(
            processingAttributes, "lucene", LingoClusteringAlgorithm.class.getName());

        ConsoleFormatter.displayResults(process);
    }
View Full Code Here

                "Either dcs.source or a non-empty document list in dcs.c2stream must be provided");
            return;
        }

        // Perform processing
        ProcessingResult result = null;
        try
        {
            long start = System.currentTimeMillis();
            final String logMsg;
            if (requestModel.source != null)
            {
                logMsg = "Processed results from " + requestModel.source + " with " + requestModel.algorithm;
                result = controller.process(processingAttributes, requestModel.source,
                    requestModel.algorithm);
            }
            else
            {
                logMsg = "Processed direct results feed with " + requestModel.algorithm;
                result = controller.process(processingAttributes, requestModel.algorithm);
            }

            if (config.logger.isInfoEnabled()) {
                config.logger.info(
                    String.format(Locale.ENGLISH,
                        "%s [%.2fs.]",
                        logMsg,
                        (System.currentTimeMillis() - start) / 1000.0));
            }
        }
        catch (ProcessingException e)
        {
            sendInternalServerError("Could not perform processing", response, e);
            return;
        }

        // Serialize the result
        try
        {
            if (OutputFormat.XML.equals(requestModel.outputFormat))
            {
                transformAndSerializeOutputXml(response, result,
                    !requestModel.clustersOnly, true);
            }
            else if (OutputFormat.JSON.equals(requestModel.outputFormat))
            {
                response.setContentType(MIME_JSON_UTF8);
                result.serializeJson(response.getWriter(), requestModel.jsonCallback,
                    !requestModel.clustersOnly, true);
            }
            else
            {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST,
View Full Code Here

                final Map<String, Object> attributes = Maps.newHashMap();
                CommonAttributesDescriptor.attributeBuilder(attributes)
                    .query("data mining");

                // Pass component ids to the controller to perform processing
                final ProcessingResult result = controller.process(attributes,
                    sourceIds.get(s), algorithmIds.get(a));
                ConsoleFormatter.displayClusters(result.getClusters());
                System.out.println();
            }
        }
    }
View Full Code Here

        CommonAttributesDescriptor.attributeBuilder(processingAttributes)
            .documents(Lists.newArrayList(SampleDocumentData.DOCUMENTS_DATA_MINING))
            .query("data mining");

        final ProcessingResult result = controller.process(processingAttributes,
            clusteringAlgorithm);
        ConsoleFormatter.displayClusters(result.getClusters(), 0);
    }
View Full Code Here

            /*
             * Perform clustering by topic using the Lingo algorithm. Lingo can
             * take advantage of the original query, so we provide it along with the documents.
             */
            final ProcessingResult byTopicClusters = controller.process(documents, "data mining",
                LingoClusteringAlgorithm.class);
            final List<Cluster> clustersByTopic = byTopicClusters.getClusters();
           
            /* Perform clustering by domain. In this case query is not useful, hence it is null. */
            final ProcessingResult byDomainClusters = controller.process(documents, null,
                ByUrlClusteringAlgorithm.class);
            final List<Cluster> clustersByDomain = byDomainClusters.getClusters();
            // [[[end:clustering-document-list]]]
           
            ConsoleFormatter.displayClusters(clustersByTopic);
            ConsoleFormatter.displayClusters(clustersByDomain);
       }
View Full Code Here

            .labelCount(1).partitionCount(3);

        MultilingualClusteringDescriptor.attributeBuilder(processingAttributes)
            .languageAggregationStrategy(LanguageAggregationStrategy.FLATTEN_NONE);

        final ProcessingResult pr = cluster(SampleDocumentData.DOCUMENTS_SALSA_MULTILINGUAL);
        final List<Cluster> clusters = pr.getClusters();
        final Set<String> clusterNames = Sets.newHashSet();
        for (Cluster c : clusters) {
            clusterNames.add(c.getLabel());
        }
View Full Code Here

            /* Put your own API key here or in a system property! */
            Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes)
                .appid(appid)
                .market((MarketOption) null);

            ProcessingResult result = controller.process(attributes, Bing3WebDocumentSource.class);
            Persister p = new Persister();
            p.write(result, new File("result.xml"));
        } finally {
            controller.dispose();
        }       
View Full Code Here

        // Lower base cluster score.
        STCClusteringAlgorithmDescriptor.attributeBuilder(processingAttributes)
            .minBaseClusterScore(0);

        ProcessingResult pr = cluster(documents);
        Set<String> clusterLabels = collectClusterLabels(pr);
        assertThat("Good Programs").isIn(clusterLabels);
        assertThat("Good Programming").isNotIn(clusterLabels);
    }
View Full Code Here

        // Remove values corresponding to internal attributes
        requestParameters.keySet().removeAll(
            webappConfig.componentInternalAttributeKeys);

        // Perform processing
        ProcessingResult processingResult = null;
        ProcessingException processingException = null;
        try
        {
            if (requestModel.type.requiresProcessing)
            {
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.