当前位置: 首页>>代码示例>>Java>>正文


Java ParseException.printStackTrace方法代码示例

本文整理汇总了Java中org.apache.lucene.queryparser.classic.ParseException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ParseException.printStackTrace方法的具体用法?Java ParseException.printStackTrace怎么用?Java ParseException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.queryparser.classic.ParseException的用法示例。


在下文中一共展示了ParseException.printStackTrace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runQuery

import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
public ScoreDoc[] runQuery(String qno, String queryTerms){
    ScoreDoc[] hits = null;

    System.out.println("Query No.: " + qno + " " + queryTerms);
    try {
        Query query = parser.parse(QueryParser.escape(queryTerms));

        try {
            TopDocs results = searcher.search(query, p.maxResults);
            hits = results.scoreDocs;
        }
        catch (IOException ioe){
            ioe.printStackTrace();
            System.exit(1);
        }
    } catch (ParseException pe){
        pe.printStackTrace();
        System.exit(1);
    }
    return hits;
}
 
开发者ID:lucene4ir,项目名称:lucene4ir,代码行数:22,代码来源:RetrievalApp.java

示例2: queryIndex

import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
public static LuceneSearchResult queryIndex(String keyword, int offset, int pagesize){
	// 查询
	List<Query> querys = new ArrayList<>();
	if (keyword!=null && keyword.trim().length()>0) {
		try {
			//Analyzer analyzer = new SmartChineseAnalyzer();
			Analyzer analyzer = new IKAnalyzer();
			QueryParser parser = new QueryParser(ExcelUtil.KEYWORDS, analyzer);
			Query shopNameQuery = parser.parse(keyword);
			querys.add(shopNameQuery);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	LuceneSearchResult result = search(querys, offset, pagesize);
	return result;
}
 
开发者ID:xuxueli,项目名称:xxl-search,代码行数:18,代码来源:LuceneUtil.java

示例3: getHits

import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
private ScoreDoc[] getHits(String question) throws IOException {
 try {
  Query luceneQuery = queryParser.parse(question);
  ScoreDoc[] hits = indexSearcher.search(luceneQuery, numOfDocs).scoreDocs;
  return hits;
 } 
 catch (ParseException e) {
  System.out.println("ParseException question = " + question);
  e.printStackTrace();
  return new ScoreDoc[0];
 }
  
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:14,代码来源:FbEntitySearcher.java

示例4: main

import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
/**
 * @decription:测试
 * @parm:@param args
 * @return:void
 * @throws:IOException
 */
public static void main(String[] args) throws IOException {
	SearchDao test = new SearchDao();
	try {
		System.out.println(test.searcher("虎溪校区举行辅导员座谈会"));
	} catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:FrankXiong,项目名称:cqunews-web,代码行数:16,代码来源:SearchDao.java

示例5: search

import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
@Override
public List<String> search(String text) {
	if (src != null && src.isSupported(TermDataSourceFeature.SEARCH)) return src.search(text);
	try {
		return search(this.parser.parse(text));
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:11,代码来源:LuceneSearchDataSource.java

示例6: load

import org.apache.lucene.queryparser.classic.ParseException; //导入方法依赖的package包/类
public void load(String filename) throws Exception {
    BufferedReader in = new BufferedReader(new FileReader(filename));
    String line = null;
    QueryParser qps = new QueryParser(FreebaseTools.FIELD_NAME_TEXT, tools.getIndexAnalyzer());
    IndexSearcher searcher = tools.getIndexSearcher();
    IndexReader reader = tools.getIndexReader();

    while ((line = in.readLine()) != null) {
        String[] fields = line.split("\t");
        System.out.println("[Query: " + fields[0] + "] [KBid: " + fields[1] + "] [type: " + fields[2] + "]");

        try {
            // execute a Lucene query for the entity, get back 10 docs
            Query q = qps.parse(fields[0]);
            TopDocs results = searcher.search(q, 10);
            ScoreDoc[] hits = results.scoreDocs;
            boolean found = false;
            long Ndocs = reader.numDocs();

            for (ScoreDoc sd : hits) {
                //   - if d is the relevant doc, then found=true, this one's relevant.
                boolean rel = false;
                Document d = tools.getDocumentInMode(sd.doc);
                String kbid = d.get("subject");
                if (kbid.equals(fields[1])) {
                    found = true;
                    rel = true;
                }
                //   - get its termvector
                Fields docfields = reader.getTermVectors(sd.doc);
                //   - make it into what jforests wants
                for (String f : docfields) {
                    TermsEnum t = docfields.terms(f).iterator();
                    BytesRef tstring;
                    while ((tstring = t.next()) != null) {
                        PostingsEnum pe = t.postings(null);
                        int i;
                        int df = t.docFreq();
                        while ((i = pe.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
                            int freq = pe.freq();
                            double idf = Math.log(Ndocs / df);
                            double tf = 1 + Math.log(freq);
                            double tfidf = tf * idf;
                            // and that's the weight.
                        }
                    }
                }

            }

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:isoboroff,项目名称:basekb-search,代码行数:56,代码来源:LoadTrainingData.java


注:本文中的org.apache.lucene.queryparser.classic.ParseException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。