Examples of ProcessingResult


Examples of org.carrot2.core.ProcessingResult

        }

        final Map<String, Object> attributes = Maps.newHashMap();
        CommonAttributesDescriptor.attributeBuilder(attributes)
            .documents(documents);
        final ProcessingResult englishResult = controller.process(
            attributes, LingoClusteringAlgorithm.class);
        ConsoleFormatter.displayResults(englishResult);

        /*
         * In the second call, we will fetch results for a Chinese query from Bing,
         * setting explicitly the Bing's specific language attribute. Based on that
         * attribute, the document source will set the appropriate language for each
         * document.
         */
        attributes.clear();
       
        CommonAttributesDescriptor.attributeBuilder(attributes)
            .query("聚类" /* clustering? */)
            .results(100);

        Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes)
            .market(MarketOption.CHINESE_CHINA);
        Bing3WebDocumentSourceDescriptor
            .attributeBuilder(attributes)
                .appid(BingKeyAccess.getKey()); // use your own ID here!

        final ProcessingResult chineseResult = controller.process(attributes,
            Bing3WebDocumentSource.class, LingoClusteringAlgorithm.class);
        ConsoleFormatter.displayResults(chineseResult);

        /*
         * In the third call, we will fetch results for the same Chinese query from
         * Google. As Google document source does not have its specific attribute for
         * setting the language, it will not set the documents' language for us. To make
         * sure the right lexical resources are used, we will need to set the
         * MultilingualClustering.defaultLanguage attribute to Chinese on our own.
         */
        attributes.clear();
       
        CommonAttributesDescriptor.attributeBuilder(attributes)
            .query("聚类" /* clustering? */)
            .results(100);

        MultilingualClusteringDescriptor.attributeBuilder(attributes)
            .defaultLanguage(LanguageCode.CHINESE_SIMPLIFIED);

        final ProcessingResult chineseResult2 = controller.process(attributes,
            GoogleDocumentSource.class, LingoClusteringAlgorithm.class);
        ConsoleFormatter.displayResults(chineseResult2);
        // [[[end:clustering-non-english-content]]]
    }
View Full Code Here

Examples of org.carrot2.core.ProcessingResult

            sendBadRequest("dcs.c2stream only supported in POST requests.", response, null);
            return;
        }

        // Check for c2stream in a POST/www-url-encoded and decode it... or try to.
        ProcessingResult input = null;
        if (request.getMethod().equalsIgnoreCase("POST") &&
            request.getParameter(DCS_C2STREAM) != null)
        {
            // Deserialize documents from the stream
            try
View Full Code Here

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

Examples of org.carrot2.core.ProcessingResult

        /*
         * 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

Examples of org.carrot2.core.ProcessingResult

                "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

Examples of org.carrot2.core.ProcessingResult

                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

Examples of org.carrot2.core.ProcessingResult

        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

Examples of org.carrot2.core.ProcessingResult

            /*
             * 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

Examples of org.carrot2.core.ProcessingResult

            .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

Examples of org.carrot2.core.ProcessingResult

            /* 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
TOP
Copyright © 2018 www.massapi.com. 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.