當前位置: 首頁>>代碼示例>>Java>>正文


Java SolrServerException.printStackTrace方法代碼示例

本文整理匯總了Java中org.apache.solr.client.solrj.SolrServerException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrServerException.printStackTrace方法的具體用法?Java SolrServerException.printStackTrace怎麽用?Java SolrServerException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.client.solrj.SolrServerException的用法示例。


在下文中一共展示了SolrServerException.printStackTrace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: querySolrIndex

import org.apache.solr.client.solrj.SolrServerException; //導入方法依賴的package包/類
/**
 * Returns all patterns from the index and their features for reverb and the
 * wordnet distance and the overall boa-boaScore.
 * 
 * @param propertyUri the property URI
 * @return a list of patterns
 */
private static Set<Pattern> querySolrIndex(String propertyUri) {

    Map<Integer, Pattern> patterns = new HashMap<>();

    try {

        SolrQuery query = new SolrQuery("uri:\"" + propertyUri + "\"");
        query.addField("REVERB");
        query.addField("WORDNET_DISTANCE");
        query.addField("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM");
        query.addField("pos");
        query.addField("boa-score");
        query.addField("nlr-var");
        query.addField("nlr-no-var");
        query.setRows(10000);
        QueryResponse response = server.query(query);
        SolrDocumentList docList = response.getResults();

        // return the first list of types
        for (SolrDocument d : docList) {

            Pattern pattern = new Pattern();
            pattern.naturalLanguageRepresentation = (String) d.get("nlr-var");
            pattern.naturalLanguageRepresentationWithoutVariables = (String) d.get("nlr-no-var");
            pattern.features.put("REVERB", Double.valueOf((String) d.get("REVERB")));
            pattern.features.put("WORDNET_DISTANCE", Double.valueOf((String) d.get("WORDNET_DISTANCE")));
            pattern.features.put("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM", Double.valueOf((String) d.get("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM")));
            pattern.posTags = (String) d.get("pos");
            pattern.boaScore = Double.valueOf((String) d.get("boa-score"));
            pattern.naturalLanguageScore = calculateNaturalLanguageScore(pattern);

            // since ?D? and ?R? are removed so two patterns might look the
            // same
            if (isSuitable(pattern)) {

                // merge the pattern
                if (patterns.containsKey(pattern.hashCode())) {

                    Pattern p = patterns.get(pattern.hashCode());
                    p.features.put("REVERB", pattern.features.get("REVERB") + p.features.get("REVERB"));
                    p.features.put("WORDNET_DISTANCE", pattern.features.get("WORDNET_DISTANCE") + p.features.get("WORDNET_DISTANCE"));
                    p.features.put("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM", pattern.features.get("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM") + p.features.get("SUPPORT_NUMBER_OF_PAIRS_LEARNED_FROM"));
                    p.boaScore += pattern.boaScore;
                    p.naturalLanguageScore += pattern.naturalLanguageScore;
                    patterns.put(pattern.hashCode(), p);
                }
                else {

                    patterns.put(pattern.hashCode(), pattern);
                }
            }
        }
    }
    catch (SolrServerException e) {

        System.out.println("Could not execute query: " + e);
        e.printStackTrace();
    }
    return new HashSet<>(patterns.values());
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:68,代碼來源:BoaPatternSelector.java


注:本文中的org.apache.solr.client.solrj.SolrServerException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。