Package org.carrot2.core

Examples of org.carrot2.core.ProcessingException


        final boolean hasStartIndex = URLResourceWithParams.containsAttributePlaceholder(
            feedUrlTemplate, START_INDEX_VARIABLE_NAME);

        if (!(hasStartPage ^ hasStartIndex))
        {
            throw new ProcessingException(
                "The feedUrlTemplate must contain either "
                    + URLResourceWithParams
                        .formatAttributePlaceholder(START_INDEX_VARIABLE_NAME)
                    + " or "
                    + URLResourceWithParams
                        .formatAttributePlaceholder(START_PAGE_VARIABLE_NAME)
                    + " variable");
        }

        if (!URLResourceWithParams.containsAttributePlaceholder(feedUrlTemplate,
            SEARCH_TERMS_VARIABLE_NAME))
        {
            throw new ProcessingException(
                "The feedUrlTemplate must contain "
                    + URLResourceWithParams
                        .formatAttributePlaceholder(SEARCH_TERMS_VARIABLE_NAME)
                    + " variable");
        }

        if (resultsPerPage == 0)
        {
            throw new ProcessingException("resultsPerPage must be set");
        }

        this.metadata = new MultipageSearchEngineMetadata(resultsPerPage, maximumResults,
            hasStartPage);
        this.feedFetcher = new HttpURLFeedFetcher();
View Full Code Here


            this.query = "(" + this.query + ") AND ("
                + Joiner.on(" OR ").join(sites) + ")";
            if (this.query.length() > 2048)
            {
                throw new ProcessingException(
                    "Query length must not exceed 2048 characters");
            }
        }
    }
View Full Code Here

     */
    protected SearchEngineResponse fetchSearchResponse() throws Exception
    {
        if (directory == null)
        {
            throw new ProcessingException("Directory attribute must not be empty.");
        }

        if (this.query instanceof String)
        {
            final String [] searchFields = fieldMapper.getSearchFields();
            if (searchFields == null || searchFields.length == 0)
            {
                throw new ProcessingException(
                    "At least one search field must be given for a plain text query. "
                        + "Alternatively, use a Lucene Query object.");
            }

            final String textQuery = (String) query;
            if (StringUtils.isEmpty(textQuery))
            {
                throw new ProcessingException(
                    "An instantiated Lucene Query object or a non-empty "
                        + "plain text query is required.");
            }

            @SuppressWarnings("deprecation")
View Full Code Here

        // Fields to tokenize
        final String [] fieldNames = documentFields.toArray(new String [documentFields.size()]);

        if (fieldNames.length > 8)
        {
            throw new ProcessingException("Maximum number of tokenized fields is 8.");
        }

        // Prepare arrays
        images = Lists.newArrayList();
        tokenTypes = new ShortArrayList();
View Full Code Here

        requestParameters.keySet().removeAll(
            webappConfig.componentInternalAttributeKeys);

        // Perform processing
        ProcessingResult processingResult = null;
        ProcessingException processingException = null;
        try
        {
            if (requestModel.type.requiresProcessing)
            {
                switch (requestModel.type)
                {
                    case CLUSTERS:
                    case FULL:
                    case CARROT2:
                        logQuery(true, requestModel, null);
                        processingResult = controller.process(requestParameters,
                            requestModel.source, requestModel.algorithm);
                        logQuery(false, requestModel, processingResult);
                        break;

                    case DOCUMENTS:
                        processingResult = controller.process(requestParameters,
                            requestModel.source,
                            webappConfig.QUERY_HIGHLIGHTER_ID);
                        break;

                    case CARROT2DOCUMENTS:
                        processingResult = controller.process(requestParameters,
                            requestModel.source);
                        break;

                    default:
                        throw new RuntimeException("Should not reach here.");
                }

                setExpires(response, 5);
            }
        }
        catch (ProcessingException e)
        {
            processingException = e;

            if (e.getCause() instanceof IpBannedException)
            {
                logger.info("Skipping, source IP banned: " + request.getRemoteAddr());
            }
            else
            {
                logger.error("Processing error: " + e.getMessage(), e);
            }
        }

        // Send response, sets encoding of the response writer.
        response.setContentType(MIME_XML_UTF8);

        final Persister persister = new Persister(getPersisterFormat(requestModel));
        final PrintWriter writer = response.getWriter();
        if (RequestType.CARROT2.equals(requestModel.type) ||
            RequestType.CARROT2DOCUMENTS.equals(requestModel.type))
        {
            // Check for an empty processing result.
            if (processingException != null)
            {
                response.sendError(
                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Internal server error: " + processingException.getMessage());
                return;
            }

            persister.write(processingResult, writer);
        }
View Full Code Here

    public void beforeProcessing() throws ProcessingException
    {
        super.beforeProcessing();
        if (toCarrot2Xslt == null)
        {
            throw new ProcessingException("XSLT stylesheet must not be null");
        }
    }
View Full Code Here

    for (int i = 0; i < titles.length; i++) {
      Document doc = new Document(titles[i], snippets[i],
              "file://foo_" + i + ".txt");
      documents.add(doc);
    }
    final ProcessingResult result = controller.process(documents,
            "red fox",
            LingoClusteringAlgorithm.class);//<co id="crt2.process"/>
    displayResults(result);//<co id="crt2.print"/>

    /*
 
View Full Code Here

    requestParams.put(NutchInputComponent.NUTCH_INPUT_SUMMARIES_ARRAY,
      descriptions);

    try {
      // The input component takes Nutch's results so we don't need the query argument.
      final ProcessingResult result =
        controller.query(PROCESS_ID, "no-query", requestParams);

      final ArrayOutputComponent.Result output =
        (ArrayOutputComponent.Result) result.getQueryResult();

      final List outputClusters = output.clusters;
      final HitsCluster [] clusters = new HitsCluster[ outputClusters.size() ];

      int j = 0;
View Full Code Here

            logger.debug("Reloading XML rescheduled: browser not ready.");
            new ReloadXMLJob("delaying").reschedule(BROWSER_REFRESH_DELAY);
            return Status.OK_STATUS;
        }

        ProcessingResult pr = getProcessingResult();
        if (pr == lastProcessingResult)
        {
            logger.debug("Reloading XML aborted: identical processing result.");
            return Status.OK_STATUS;
        }

        try
        {
            StringWriter sw = new StringWriter();
            pr.serializeJson(sw, "updateDataJson", true, false, true, false);

            String json = sw.toString();
            logger.info("Updating view XML: " +
                StringUtils.abbreviate(json, 180));
View Full Code Here

     */
    private ProcessingResult getProcessingResult()
    {
        assert Display.getCurrent() != null;

        final ProcessingResult pr = editor.getSearchResult().getProcessingResult();
        if (pr == null || pr.getClusters() == null)
            return null;
        return pr;
    }
View Full Code Here

TOP

Related Classes of org.carrot2.core.ProcessingException

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.