代码改变世界

随笔档案-2012年04月

Lucene中索引的删除,更新与查找以及恢复(lucene3.5)

2012-04-29 19:57 by Lves Li, 193 阅读, 收藏,
摘要: package org.itat.text1; import java.io.File; import java.io.IOException; import javax.management.Query; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.CorruptIndexExcep.. 阅读全文

IKanalyzer 分词器(???)

2012-04-29 13:26 by Lves Li, 234 阅读, 收藏,
摘要: //今天看了看IKanalyzer 扩充词汇看得我一头雾水 分词器的使用还没理解直接搞扩充词汇有点知识脱节//谁能举个例看看怎么扩充????网上提供的方法是:.基于api 我的想法如下 利用一个数据库表保存实时动态添加的词元,如果对应的实体类有更新,就执行添加词元的操作 具体的话就是从数据库读取词元,然后存在List termList,执行 Dictionary.loadExtendWords(termList); 其实就是监听,也可以利用线程池实时扫描,目的是知道系统正在添加词元到数据库表,然后就是加载词典了2.IK的文档这么写道3.1基于 API的词典扩充 IK 分词器支持使用 API 编 阅读全文

线程池小程序(Java)

2012-04-29 10:18 by Lves Li, 166 阅读, 收藏,
摘要: //固定大小的线程池 import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ThreadTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //创建一个可重用固定线程数的线程池 ExecutorService pool=Executors.newFixedThreadPoo... 阅读全文

解析pdf文档 (lucene3.5)

2012-04-28 21:03 by Lves Li, 218 阅读, 收藏,
摘要: //今天根据课本写了个 解析pdf文档的小程序import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import org.pdfbox.pdmodel.PDDocument; import org.pdfbox.util.PDFTextStripper; public class ExtractorPDF { /** * @param args */ public static String getText(String file) //throws Except... 阅读全文

每日一练1.1(Lucene)

2012-04-27 22:56 by Lves Li, 174 阅读, 收藏,
摘要: package org.itat.text1; import java.io.IOException; public class IndexText { /** * @param args */ package org.itat.text1; import java.io.File; import java.io.IOException; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apach... 阅读全文

运算符重载小程序(对Data类的++,<<,>>的重载)

2012-04-27 10:46 by Lves Li, 213 阅读, 收藏,
摘要: // Data.cpp : 定义控制台应用程序的入口点。 //运算符重载 自加运算符和输出输入运算符的重载 自加运算符在日期增加时可以判断平年还是闰年 #include "stdafx.h" #include using namespace std; class MyData //定义一个Data类有三个数据成员 {private : int year; int month; int day; public : MyData (){year=0; month=0; day=0;} MyData(int y,int m,int d) { year=y; month=... 阅读全文

运算符重载(++,<<,>>Data类的重载)

2012-04-27 10:43 by Lves Li, 211 阅读, 收藏,
摘要: // Data.cpp : 定义控制台应用程序的入口点。 //运算符重载 自加运算符和输出输入运算符的重载 自加运算符在日期增加时可以判断平年还是闰年 #include "stdafx.h" #include using namespace std; class MyData //定义一个Data类有三个数据成员 {private : int year; int month; int day; public : MyData (){year=0; month=0; day=0;} MyData(int y,int m,int d) { year=y; month=... 阅读全文

Lucene 搜索(小程序)(Lucene3.5)

2012-04-26 15:31 by Lves Li, 144 阅读, 收藏,
摘要: /*今天看了个搜索的小程序 总结如下Lucene 执行搜索的步骤:1...创建Derectory2...创建IndexReader3...根据IndexReader创建IndexSearcher4...创建搜索的Query(查询字符串)5...根据searcher搜索并且返回TopDocs对象6...根据TopDocs获取ScoreDoc对象7....根据searcher和ScoreDoc对象获取具体的Document对象8...根据Document对象获取需要的值9...关闭reader*/import java.io.File; import java.io.FileReader; imp 阅读全文

创建索引小程序 (Lucene2.1)

2012-04-25 22:39 by Lves Li, 217 阅读, 收藏,
摘要: //按着课本写一个 Indext小程序 不过有点小错误 会出创建失败 不知道为啥??//可能版本过时了那他练练手吧package FirstSearcher; import java.awt.BorderLayout; import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.. 阅读全文

lucene索引的建立昨天的问题已解决

2012-04-25 19:14 by Lves Li, 404 阅读, 收藏,
摘要: //昨天的错误找到了 搜索与创建的目录不应在同一个根目录下。 //全靠队长啊 import java.io.File; import java.io.FileReader; import java.io.IOException; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.Corru... 阅读全文

LUCENE第一个小程序(有错)

2012-04-24 22:43 by Lves Li, 127 阅读, 收藏,
摘要: //照着课本抄的都有错 为什么?、?/???????????import java.io.File;import java.io.FileReader;import java.io.IOException;import org.apache.lucene.analysis.standard.StandardAnalyzer;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;import org.apache.lucene.index.CorruptIndexException;i 阅读全文

双缓冲的小程序

2012-04-23 22:30 by Lves Li, 175 阅读, 收藏,
摘要: //双缓冲的运用 小程序import java.awt.*;import java.applet.*;import java.awt.event.*;public class FanKuai { //主函数public static void main (String [] args){//DiTu.diTu();MyFrame frame=new MyFrame("动起来");frame.addWindowListener(new WindowAdapter()//关闭窗口 { public void windowClosing(WindowEvent e) { Syst 阅读全文

再练

2012-04-22 20:02 by Lves Li, 186 阅读, 收藏,
摘要: import java.util.*;//。import java.util.Map.Entry;class Student implements Comparable /*定义一个Student类覆写hashCode和equals方法使其具有比较性继承Comparable接口实现compaeTo方法使其具有一定的排序性*/{ //定义三个私有成员private String name; private int num; private String addrees;Student (String name,int num,String addrees)//构造函数{this.name=nam 阅读全文

每日一练

2012-04-21 23:13 by Lves Li, 139 阅读, 收藏,
摘要: //多线程小程序 复习class Ticket implements Runnable{Object obj=new Object();Boolean flag=true;private int tick=100;public void run(){if (flag){while (true){synchronized(this){if (tick>0){try{Thread.sleep(10);}catch (Exception e){}System.out.println(Thread.currentThread().getName()+"`````cold ``" 阅读全文

指定目录下的java文件存储到一个Txt文本文件中

2012-04-19 22:17 by Lves Li, 391 阅读, 收藏,
摘要: /*讲一个指定目录下的java文件存储到一个Txt文本文件中,建立一个java文件列表文件* * * 最近在看IO流 今天写了一个小程序 用的不好!*/import java.io.*;import java.util.*;public class JavaFileList {public static void main (String args [])throws IOException//主函数{File dir=new File("D:\\JAVATiKu");List list=new ArrayList();toFileList (dir, list);//Sy 阅读全文

C++运算符重载小程序

2012-04-18 19:56 by Lves Li, 171 阅读, 收藏,
摘要: // chongzai.cpp : 定义控制台应用程序的入口点。//运算符重载+ - 友原函数的运用#include "stdafx.h"#include using namespace std;class Complex{public:Complex( ) {real=0; image=0;}Complex (double r,double i);Complex operator+ (Complex &c5);//重载加法声明(复数与复数相加) 对象friend Complex operator+ (double &,Complex &);//重载 阅读全文

蜗牛在奔跑

2012-04-16 21:50 by Lves Li, 176 阅读, 收藏,
摘要: // 最近一直忙着自学 java没空写博客啦,已经一个月没写了。再写写我最近学的吧!//关于IO流的小知识。用IO流实现一个MP3的复制。import java.io.*;public class CopyMp3 {/** * @param args */public static void main(String[] args) throws IOException {// TODO Auto-generated method stublong start=System.currentTimeMillis();coy_1();long end=System.currentTimeMillis 阅读全文