Examples of ClassifierException


Examples of com.enigmastation.classifier.ClassifierException

     * @param item the item to be classified; needs to have meaningful toString()
     * @return a meaningful classification.
     */
    public String getClassification(Object item) {
        if (getCategories().size() == 0) {
            throw new ClassifierException();
        }
        ClassifierProbability[] probs = getProbabilities(item);
        ClassifierProbability cp = probs[0];

        for (ClassifierProbability p : probs) {
View Full Code Here

Examples of com.enigmastation.classifier.ClassifierException

     * @param item the item to be classified; needs to have meaningful toString()
     * @return a meaningful classification.
     */
    public String getClassification(Object item) {
        if (getCategories().size() == 0) {
            throw new ClassifierException("No categories; please train before classification"
                    + " or provide default category.");
        }
        ClassifierProbability[] probs = getProbabilities(item);
        ClassifierProbability cp = probs[0];

View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

            QueryResponse response = request.process(solrServer);
            SolrDocumentList results = response.getResults();
            for (SolrDocument result : results.toArray(new SolrDocument[0])) {
                String conceptUri = (String) result.getFirstValue(conceptUriField);
                if (conceptUri == null) {
                    throw new ClassifierException(String.format(
                        "Solr Core '%s' is missing required field '%s'.", solrCoreId, conceptUriField));
                }
                Float score = (Float) result.getFirstValue("score");

                // fetch metadata
                SolrQuery metadataQuery = new SolrQuery("*:*");
                // use filter queries to leverage the Solr cache explicitly
                metadataQuery.addFilterQuery(entryTypeField + ":" + METADATA_ENTRY);
                metadataQuery
                        .addFilterQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptUri));
                metadataQuery.setFields(conceptUriField, broaderField, primaryTopicUriField);
                SolrDocument metadata = solrServer.query(metadataQuery).getResults().get(0);
                String primaryTopicUri = (String) metadata.getFirstValue(primaryTopicUriField);
                suggestedTopics.add(new TopicSuggestion(conceptUri, primaryTopicUri, metadata
                        .getFieldValues(broaderField), score));
            }
        } catch (SolrServerException e) {
            if ("unknown handler: /mlt".equals(e.getCause().getMessage())) {
                String message = String.format("SolrServer with id '%s' for topic engine '%s' lacks"
                                               + " configuration for the MoreLikeThisHandler", solrCoreId,
                    engineName);
                throw new ClassifierException(message, e);
            } else {
                throw new ClassifierException(e);
            }
        }
        if (suggestedTopics.size() <= 1) {
            // no need to apply the cutting heuristic
            return suggestedTopics;
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

                narrowerConcepts.add(result.getFirstValue(conceptUriField).toString());
            }
        } catch (SolrServerException e) {
            String msg = String.format("Error while fetching narrower topics of '%s' on Solr Core '%s'.",
                broadTopicId, solrCoreId);
            throw new ClassifierException(msg, e);
        }
        return narrowerConcepts;
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

                }
            }
        } catch (SolrServerException e) {
            String msg = String.format("Error while fetching broader topics of '%s' on Solr Core '%s'.", id,
                solrCoreId);
            throw new ClassifierException(msg, e);
        }
        return broaderConcepts;
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

            for (SolrDocument result : response.getResults()) {
                rootConcepts.add(result.getFirstValue(conceptUriField).toString());
            }
        } catch (SolrServerException e) {
            String msg = String.format("Error while fetching root topics on Solr Core '%s'.", solrCoreId);
            throw new ClassifierException(msg, e);
        }
        return rootConcepts;
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

            solrServer.request(request);
            solrServer.commit();
        } catch (Exception e) {
            String msg = String.format("Error adding topic with id '%s' on Solr Core '%s'", conceptUri,
                solrCoreId);
            throw new ClassifierException(msg, e);
        }
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

                solrServer.request(request);
            }
        } catch (Exception e) {
            String msg = String.format("Error invalidating topics [%s] on Solr Core '%s'",
                StringUtils.join(conceptIds, ", "), solrCoreId);
            throw new ClassifierException(msg, e);
        }
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

        try {
            solrServer.deleteByQuery("*:*");
            solrServer.commit();
        } catch (Exception e) {
            String msg = String.format("Error deleting concepts from Solr Core '%s'", solrCoreId);
            throw new ClassifierException(msg, e);
        }
    }
View Full Code Here

Examples of org.apache.stanbol.enhancer.topic.ClassifierException

    }

    @Override
    public void removeConcept(String conceptId) throws ClassifierException {
        if (conceptId == null || conceptId.isEmpty()) {
            throw new ClassifierException("conceptId must not be null or empty");
        }
        SolrServer solrServer = getActiveSolrServer();
        try {
            solrServer.deleteByQuery(conceptUriField + ":" + ClientUtils.escapeQueryChars(conceptId));
            solrServer.commit();
        } catch (Exception e) {
            String msg = String
                    .format("Error removing concept '%s' on Solr Core '%s'", conceptId, solrCoreId);
            throw new ClassifierException(msg, e);
        }
    }
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.