Package org.dbpedia.spotlight.exceptions

Examples of org.dbpedia.spotlight.exceptions.SearchException


    public DBpediaResource getCachedDBpediaResource(int docNo) throws SearchException {
        try {
            String[] uris = FieldCache.DEFAULT.getStrings(mReader, LuceneManager.DBpediaResourceField.URI.toString());
            return new DBpediaResource(uris[docNo]);
        } catch (IOException e) {
            throw new SearchException("Error getting cached DBpediaResource.",e);
        }
    }
View Full Code Here


        FieldSelector fieldSelector = new MapFieldSelector(fieldsToLoad);
        Document document = getDocument(docNo, fieldSelector);
        Field uriField = document.getField(LuceneManager.DBpediaResourceField.URI.toString());
        if (uriField==null)
            throw new SearchException("Cannot find URI for document "+document);

        String uri = uriField.stringValue();
        if (uri==null)
            throw new SearchException("Cannot find URI for document "+document);

        DBpediaResource resource = new DBpediaResource(uri);

        for (String fieldName: fieldsToLoad) {
            Field field = document.getField(fieldName);
View Full Code Here

        String[] onlyUriAndTypes = {LuceneManager.DBpediaResourceField.SURFACE_FORM.toString()};
        FieldSelector fieldSelector = new MapFieldSelector(onlyUriAndTypes);
        Document document = getDocument(docNo,fieldSelector);
        Field sfField = document.getField(LuceneManager.DBpediaResourceField.SURFACE_FORM.toString());
        if (sfField==null)
            throw new SearchException("Cannot find SurfaceForm for document "+document);

        String sf = sfField.stringValue();
        if (sf==null)
            throw new SearchException("Cannot find URI for document "+document);

        //LOG.debug("uri:"+uri);
        return new SurfaceForm(sf);
    }
View Full Code Here

        for (ScoreDoc d: hits) {
            TermFreqVector vector = null;
            try {
                vector = mReader.getTermFreqVector(d.doc, LuceneManager.DBpediaResourceField.CONTEXT.toString());
            } catch (IOException e) {
                throw new SearchException("Error getting term frequency vector. ", e);
            }
            if (vector!=null) {
                int freq = Integer.MAX_VALUE; // set to max value because will be used in Math.min below
                // get min
                for (Term t : qTerms) {
View Full Code Here

        // Will accept multiple docs for a resource and get the overall top terms
        try {
            for (ScoreDoc d: docs) {
                TermFreqVector vector = mReader.getTermFreqVector(d.doc, LuceneManager.DBpediaResourceField.CONTEXT.toString());
                if (vector==null)
                    throw new SearchException("The index you are using does not have term frequencies stored. Cannot run getContextWords(DBpediaResource).");
                int[] freqs = vector.getTermFrequencies();
                String[] terms = vector.getTerms();
                for (int i=0; i < vector.size(); i++) {
                    termFreqMap.put(terms[i],freqs[i]);
                }
View Full Code Here

            try {
                LOG.debug("\tSurface Form Occurrence looks like: "+actuallyFound.toString());
                //Returns an Explanation that describes how doc(actuallyFound) scored against weight/query (shouldHaveFound).
                explanations.add(mSearcher.explain(actuallyFound, shouldHaveFound));
            } catch (IOException e) {
                throw new SearchException("Error generating explanation for occurrence "+goldStandardOccurrence, e);
            }
            i++;
            //if (i >= nExplanations) break;
        //}
        return explanations;
View Full Code Here

            }
            msg.append("\n");
            msg.append(context);
            msg.append("\n");
            e.printStackTrace();
            throw new SearchException(msg.toString(),e);
        }
        return ctxQuery;
    }
View Full Code Here

                }
                msg.append("\n");
                msg.append(sf);
                msg.append("\n");
                e.printStackTrace();
                throw new SearchException(msg.toString(),e);
            }
            return sfQuery;
        }
View Full Code Here

                }
                msg.append("\n");
                msg.append(sf);
                msg.append("\n");
                e.printStackTrace();
                throw new SearchException(msg.toString(),e);
            }
            return sfQuery;
        }
View Full Code Here

            Server.getTokenizer().tokenizeMaybe(spots.get(0).context());

        try {
            resources = disambiguator.disambiguate(Factory.paragraph().fromJ(spots));
        } catch (UnsupportedOperationException e) {
            throw new SearchException(e);
        }
        return resources;
    }
View Full Code Here

TOP

Related Classes of org.dbpedia.spotlight.exceptions.SearchException

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.