5월, 2011의 게시물 표시

pylucene - searcher

많은 어려움 끝에 겨우 설치 하고는 테스트 코드 하나 만들어봅니다;; # -*- coding: utf8 -*- ''' Created on 2011. 5. 16. @author: kwangsub ''' import time import os from lucene import * def search():     initVM(CLASSPATH)     analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)     directory = SimpleFSDirectory(File("/home1/irteam/repository/lucene_index_repo/HEALTH_HOSPITAL_CJK/db"))     searcher = IndexSearcher(directory, True)         t = Term("addr", "서울")     query = TermQuery(t)     topDocs = searcher.search(query, 10)     for doc in topDocs.scoreDocs:         print doc     searcher.close()     directory.close()     if __name__ == '__main__':     search()

osx + pylucene 설치

0. JCC 설치 http://lucene.apache.org/pylucene/jcc/documentation/install.html $ svn co http://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc jcc $ cd jcc $ python setup.py build $ sudo python setup.py install 1. pylucene다운로드 http://mirror.khlug.org/apache//lucene/pylucene/ 원하는 버전 다운로드 $ tar xvfz pylucene-3.1.0-1-src.tar.gz $ cd pylucene-3.1.0-1/jcc $ python setup.py build #jcc를 빌드 $ sudo python setup.py install #jcc설치 2. site-packges확인, 두개 있으면 준비 완료 /opt/local/lib/python2.5/site-packages #다를 수 있음. ㄴ JCC -2.8-py2.5-macosx-10.6-i386.egg ㄴ lucene-3.1.0-py2.5-macosx-10.6-i386.egg 3. Makefile수정 $ cd pylucene-3.1.0-1 $ vi Makefile PREFIX _PYTHON=/opt/local # /python설치 위치 변경 해야함. ANT =ant PYTHON =$(PREFIX_PYTHON)/bin/python JCC =$(PYTHON) -m jcc.__main__ --shared --arch x86_64 NUM _FILES=3 4. Make & Install $ make $ sudo make install 5. 설치 확인 site-package위치에 JCC 와 lucene이 설치되어 있어야 하고 lucene 폴더내 jar, pyc등이 있는지 확인 /opt/local/lib/python2.5/site-packages/lu