チェンジセット 54
- 更新日時:
- 2007/06/25 15:11:41 (5 年 前)
- パス:
- AutoKeyword/trunk
- ファイル:
-
- 20 変更
- 1 移動
-
README (変更) (1 diff)
-
src/jp/tyzoh/rinza/folksonomy/analyze/Analyzer.java (変更) (3 diff)
-
src/jp/tyzoh/rinza/folksonomy/analyze/Keyword.java (変更) (7 diff)
-
src/jp/tyzoh/rinza/folksonomy/analyze/KeywordFilter.java (変更) (1 diff)
-
src/jp/tyzoh/rinza/folksonomy/analyze/Mecab.java (変更) (3 diff)
-
src/jp/tyzoh/rinza/folksonomy/analyze/Sen.java (変更) (5 diff)
-
src/jp/tyzoh/rinza/folksonomy/common/AutokeywordUtil.java (移動) (移動元: AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/common/Util.java) (5 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/ContentsExtractorLookuper.java (変更) (5 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/DefaultExtractor.java (変更) (1 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/Extractor.java (変更) (1 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/pdfbox/PDFExtractor.java (変更) (2 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSExcelExtractor.java (変更) (2 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSPowerPointExtractor.java (変更) (2 diff)
-
src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSWordExtractor.java (変更) (2 diff)
-
src/jp/tyzoh/rinza/folksonomy/keyword/Auto.java (変更) (7 diff)
-
src/jp/tyzoh/rinza/folksonomy/keyword/Engine.java (変更) (9 diff)
-
src/jp/tyzoh/rinza/folksonomy/keyword/Hidden.java (変更) (6 diff)
-
src/jp/tyzoh/rinza/folksonomy/keyword/Result.java (変更) (4 diff)
-
src/jp/tyzoh/rinza/folksonomy/search/LuceneJa.java (変更) (20 diff)
-
src/jp/tyzoh/rinza/folksonomy/search/Namazu.java (変更) (5 diff)
-
src/jp/tyzoh/rinza/folksonomy/search/Searcher.java (変更) (3 diff)
凡例:
- 変更なし
- 追加
- 削除
-
AutoKeyword/trunk/README
r6 r54 63 63 Mecab 0.93 64 64 java 1.5.03(おそらく、これ以前のバージョンでもコンパイル/実行可能です) 65 Jakarta Logging Log4j 1.2.12+ [http://logging.apache.org/log4j/] 65 66 66 67 ■ 環境設定 -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Analyzer.java
r47 r54 2 2 3 3 import java.util.*; 4 import java.io.*;5 4 6 5 /** … … 20 19 * �ݒ菉�� * @param properties �ݒ��e 21 20 * @param out �f�o�b�O�o�� 22 * @return 21 * @return �������� 23 22 */ 24 public boolean init(Properties properties , PrintWriter out);23 public boolean init(Properties properties); 25 24 26 25 /** … … 30 29 * @param out ��s���f�o�b�O�o�� 31 30 * @return ��s����ʃf�[�^ Collection<Keyword> 32 *33 * @see #exec(String, String, PrintWriter)34 * @see #parse(Collection)35 31 */ 36 public Collection parse(String filename , PrintWriter out);32 public Collection parse(String filename); 37 33 } 38 34 /* -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Keyword.java
r47 r54 2 2 3 3 /** 4 * �`�ԑf��̌��ʂ������ ��4 * �`�ԑf��̌��ʂ������an�N���X. 5 5 * 6 6 * <BR><BR>Copyright (C) 2006 Nihon Unisys, Ltd. All Rights Reserved. … … 17 17 18 18 /** 19 * �L�[���[�h 20 * @param word �L�[���[�h������ * @param part �i���� 21 * @param sub �ו��i���� 19 * �L�[���[�h���̍쐬. 20 * 21 * @param word �L�[���[�h�������ϒl] 22 * @param part �i����[�s�ϒl] 23 * @param sub �ו��i����[�s�ϒl] 22 24 * @param count �o���� 23 25 */ … … 31 33 32 34 /** 33 * �L�[���[�h 34 * @param word �L�[���[�h������ * @param part �i���� 35 * @param sub �ו��i���� 35 * �L�[���[�h���̍쐬. 36 * 37 * �o�����Ƃ��č쐬���� 38 * 39 * @param word �L�[���[�h�������ϒl] 40 * @param part �i����[�s�ϒl] 41 * @param sub �ו��i����[�s�ϒl] 42 * 43 * @see Keyword#Keyword(String, String, String, int) 36 44 */ 37 45 public Keyword(String word, String part, String sub) … … 40 48 } 41 49 50 /** 51 * �L�[���[�h�̕�����擾���� * @return �L�[���[�h������ */ 42 52 public String getWord() 43 53 { … … 45 55 } 46 56 57 /** 58 * ���̃L�[���[�h�̕i����������� * @return �i���� 59 */ 47 60 public String getPart() 48 61 { … … 50 63 } 51 64 65 /** 66 * ���̃L�[���[�h�̕i���ו���������� * @return �i���ו��� 67 */ 52 68 public String getSub() 53 69 { … … 55 71 } 56 72 73 /** 74 * ���̃L�[���[�h�̏o��������� 75 * @return �o���� 76 */ 57 77 public int getCount() 58 78 { 59 79 return count; 60 80 } 61 // 81 82 /** 83 * ���̃L�[���[�h�̏o����肷�� 84 * @param c �o���� 85 */ 62 86 public void setCount(int c) { 63 87 count = c; 64 88 } 65 public String info() 89 90 /** 91 * ���̃C���X�^���X�̕�����L������� 92 * @return ���̃C���X�^���X�̕�����L 93 * @see Object#toString() 94 */ 95 public String toString() 66 96 { 67 return getCount() + "\t" + getWord() + "\t" + getPart() + "\t" + getSub(); 97 return new StringBuffer().// 98 append(getCount()).append("\t").// 99 append(getWord()).append("\t").// 100 append(getPart()).append("\t").// 101 append(getSub()).toString(); 68 102 } 69 103 } -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/KeywordFilter.java
r47 r54 22 22 /** ������������߂̃o�b�t�@ */ 23 23 private final ArrayList prevKeyword = new ArrayList(32); 24 /** � L�[���[�h�� Map<�L�[���[�h������L�[���[�h> */24 /** �W�v���ꂽ�L�[���[�h�� Map<�L�[���[�h������L�[���[�h> */ 25 25 private HashMap /* <String, Keyword> */keywordMap = new HashMap(); 26 26 -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Mecab.java
r47 r54 2 2 3 3 import java.util.*; 4 import java.io.*; 4 5 5 import jp.tyzoh.rinza.folksonomy.common.*; 6 6 … … 27 27 * �����̏��� * @param properties �ݒ��e 28 28 * @param out �f�o�b�O�o�� 29 * @return ������ 30 * @see Analyzer#init(Properties) 29 31 */ 30 public boolean init(Properties properties , PrintWriter out)32 public boolean init(Properties properties) 31 33 { 32 34 command = properties.getProperty(ANALYZER_COMMAND, command); … … 37 39 38 40 /** 39 * �R�}���h��s�����ʂ�[�X���Ď擾���� * @param filename ��Ώۃt�@�C�� 40 * @param out �f�o�b�O�o�� 41 * �R�}���h��s�����ʂ�[�X���Ď擾���� 42 * 43 * 44 * <p> 45 * <ol>������ * <li> Mecab����ăt�@�C���̓���ԑf����� * <li> {@link KeywordFilter}�ʼn���ꂽ�L�[���[�h��v���� 46 * </ol> 47 * 48 * </p> 49 * 50 * @param filename ��Ώۃt�@�C�� 41 51 * @return �L�[���[�h�̃R���N�V����Collection<Keyword> 52 * @see Analyzer#parse(String) 53 * @see AutokeywordUtil#exec(String, String) 42 54 */ 43 public Collection parse(String filename , PrintWriter out)55 public Collection parse(String filename) 44 56 { 45 46 57 String command = this.command + " " + filename; 47 Collection execResults = Util.exec(command, encodeType, out);58 Collection execResults = AutokeywordUtil.exec(command, encodeType); 48 59 Collection parseResults = parse(execResults); 49 50 60 return parseResults; 51 61 } 52 62 53 63 /** 54 * ��s���ʂ�[�X���āA�L�[���[�h���Ɋi�[���� * @param collection ��s���ʍs�̕�����lection<String> 55 * @return 64 * ��s���ʂ�[�X���āA�L�[���[�h���Ɋi�[���� 65 * 66 * @param collection ��s���ʍs�̕�����lection<String> 67 * @return �p�[�X�����L�[���[�h�̃R���N�V���� (Collection<Keyword>) 56 68 */ 57 69 private Collection parse(Collection collection) -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Sen.java
r47 r54 4 4 import java.io.File; 5 5 import java.io.IOException; 6 import java.io.PrintWriter;7 6 import java.util.Collection; 8 7 import java.util.Properties; 9 8 9 import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 10 10 import jp.tyzoh.rinza.folksonomy.extractor.ContentsExtractorLookuper; 11 import jp.tyzoh.rinza.folksonomy.extractor.Extractor; 11 12 import net.java.sen.StreamTagger; 12 13 import net.java.sen.StringTagger; … … 44 45 * ������ 45 46 * @param properties �ݒ��e 46 * @param out �f�o�b�O�o��47 47 * @param �������� 48 * @see Analyzer#init(Properties) 48 49 */ 49 public boolean init(Properties properties , PrintWriter out) {50 public boolean init(Properties properties) { 50 51 command = properties.getProperty(ANALYZER_COMMAND, command); 51 52 … … 60 61 61 62 /** 62 * �t�@�C���� [�X����63 * �t�@�C����ԑf����� 63 64 * 65 * <p> 66 * <ol>������ * <li> {@link Extractor}�Ńe�L�X�g���o��� 67 * <li> {@link StreamTagger}����ăt�@�C���̓���ԑf����� * <li> {@link KeywordFilter}�ʼn���ꂽ�L�[���[�h��v���� 68 * </ol> 69 * 70 * </p> 64 71 * @param filename 65 72 * �t�@�C���� … … 67 74 * ��s�G���[�̏o�� 68 75 * @return �L�[���[�h�̃R���N�V����(Collection<Keyword>) 76 * @see Analyzer#parse(String) 69 77 */ 70 public Collection parse(String filename , PrintWriter out) {78 public Collection parse(String filename) { 71 79 final KeywordFilter kf = new KeywordFilter(); 72 80 BufferedReader br = null; … … 79 87 } 80 88 } catch (IOException e) { 81 e.printStackTrace(out);89 AutokeywordUtil.getLogger().warn("Sen�����͒��ɃG���[���������܂���", e); 82 90 } finally { 83 91 if (br != null) { -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/common/AutokeywordUtil.java
r43 r54 1 1 package jp.tyzoh.rinza.folksonomy.common; 2 2 3 import java.io.*; 3 import java.io.BufferedReader; 4 import java.io.File; 5 import java.io.IOException; 6 import java.io.InputStream; 7 import java.io.InputStreamReader; 4 8 import java.lang.reflect.Constructor; 5 9 import java.lang.reflect.InvocationTargetException; 6 import java.util.*; 10 import java.util.Collection; 11 import java.util.Vector; 7 12 8 13 import javax.activation.MimetypesFileTypeMap; 9 14 15 import org.apache.log4j.Logger; 16 10 17 /** 11 18 * folksonomy �p�b�P�[�W���ʂŎg���鏈�� 12 * 13 * <BR><BR>Copyright (C) 2006 Nihon Unisys, Ltd. All Rights Reserved. 19 * 20 * <BR> 21 * <BR> 22 * Copyright (C) 2006 Nihon Unisys, Ltd. All Rights Reserved. 14 23 */ 15 public class Util {24 public class AutokeywordUtil { 16 25 /** MIME�̃t�@�C���^�C�v�}�b�v */ 17 26 private static final MimetypesFileTypeMap mimeMap = new MimetypesFileTypeMap(); 18 27 19 20 public static Collection exec(String command, String encodeType, PrintWriter out) 21 { 22 return exec(new String[]{command}, encodeType, out); 28 /** Autokeyword�p�̃��O�o��*/ 29 private static final Logger log = Logger.getLogger("Autokeyword"); 30 31 /** 32 * �R�}���h�̎�s 33 * 34 * @param command 35 * �R�}���h 36 * @param encodeType 37 * �R�}���h���ʏo�̓G���R�[�h 38 * @return ��s���ʂ̏o�͓�(Collection<String) 39 * @see #exec(String[], String) 40 */ 41 public static Collection exec(String command, String encodeType) { 42 return exec(new String[] { command }, encodeType); 23 43 } 24 44 25 public static Collection exec(String[] commandArray, String encodeType, PrintWriter out) 26 { 27 Collection collection = new Vector(); 45 /** 46 * �R�}���h�̎�s 47 * 48 * @param commandArray 49 * �R�}���h�������� * @param encodeType 50 * �R�}���h���ʏo�̓G���R�[�h 51 * @return ��s���ʂ̏o�͓�(Collection<String) 52 */ 53 public static Collection exec(String[] commandArray, String encodeType) { 54 Collection collection = new Vector(); 28 55 29 56 try { 30 if (out != null) { 31 for(int i = 0; i < commandArray.length; i++) { 32 out.print(commandArray[i] + " "); 57 58 if (log.isDebugEnabled()) { 59 final StringBuffer buf = new StringBuffer(); 60 buf.append("Util.exec ��s: ��"); 61 for (int i = 0; i < commandArray.length; i++) { 62 buf.append(commandArray[i]).append(" "); 33 63 } 34 out.println("<br>");64 log.debug(buf.toString()); 35 65 } 36 /* 37 for(int i = 0; i < commandArray.length; i++) { 38 System.out.print(commandArray[i] + " "); 39 } 40 System.out.println("\n"); 41 */ 42 Process process = null; 66 67 Process process = null; 43 68 if (commandArray.length == 1) { 44 69 process = Runtime.getRuntime().exec(commandArray[0]); … … 47 72 } 48 73 InputStream is = process.getInputStream(); 49 InputStreamReader isr = null;50 BufferedReader br = null;74 InputStreamReader isr = null; 75 BufferedReader br = null; 51 76 try { 52 // intcount = 0;77 // int count = 0; 53 78 if (encodeType.equals("non")) { 54 79 isr = new InputStreamReader(is); 55 80 } else { 56 isr = new InputStreamReader(is, encodeType); 81 isr = new InputStreamReader(is, encodeType); 57 82 } 58 83 br = new BufferedReader(isr); 59 while(true) { 60 String line = br.readLine(); 61 if (line == null) break; 84 while (true) { 85 String line = br.readLine(); 86 if (line == null) 87 break; 62 88 collection.add(line); 63 if (out != null) out.println(line+"<br>"); 64 // System.out.println(line); 89 if (log.isDebugEnabled()) { 90 log.debug("Util.exec():[����:" + line); 91 } 65 92 } 66 } catch (IOException ioe) {93 } catch (IOException ioe) { 67 94 ioe.printStackTrace(); 68 95 try { 69 if (br != null) br.close(); 70 if (isr != null) isr.close(); 71 if (is != null) is.close(); 72 } catch(IOException ioe2) { 96 if (br != null) 97 br.close(); 98 if (isr != null) 99 isr.close(); 100 if (is != null) 101 is.close(); 102 } catch (IOException ioe2) { 73 103 ioe2.printStackTrace(); 74 104 } 75 105 } 76 } catch(Exception ex) { 77 ex.printStackTrace(); 78 if (out != null) out.println("error " + ex.getMessage()); 106 } catch (Exception ex) { 107 log.error("Util.exec()�̎�s���ɃG���[���������܂���:" + ex.getMessage(), ex); 79 108 } 80 109 … … 85 114 * �C���X�^���X�쐬����. 86 115 * 87 * @param name �N���X�� 88 * @param argumentClasses ���z�� * @param argumentObjects ���z�� * @return �쐬�����C���X�^���X 116 * @param name 117 * �N���X�� 118 * @param argumentClasses 119 * ���z�� * @param argumentObjects 120 * ���z�� * @return �쐬�����C���X�^���X 89 121 * 90 * @throws ClassNotFoundException 122 * @throws ClassNotFoundException 91 123 * @throws InstantiationException 92 * @throws IllegalAccessException 93 * @throws SecurityException 94 * @throws NoSuchMethodException 95 * @throws IllegalArgumentException 124 * @throws IllegalAccessException 125 * @throws SecurityException 126 * @throws NoSuchMethodException 127 * @throws IllegalArgumentException 96 128 * @throws InvocationTargetException 97 129 */ 98 public static Object createInstance(String name, Class[] argumentClasses, Object[] argumentObjects) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { 130 public static Object createInstance(String name, Class[] argumentClasses, 131 Object[] argumentObjects) throws ClassNotFoundException, 132 InstantiationException, IllegalAccessException, SecurityException, 133 NoSuchMethodException, IllegalArgumentException, 134 InvocationTargetException { 99 135 final Class clazz = Class.forName(name); 100 if (argumentClasses==null) {136 if (argumentClasses == null) { 101 137 return clazz.newInstance(); 102 138 } else { … … 106 142 } 107 143 144 // 108 145 public static String findType(File file) { 109 146 return mimeMap.getContentType(file); … … 113 150 return mimeMap.getContentType(fileName); 114 151 } 152 153 // 154 public static Logger getLogger() { 155 return log; 156 } 115 157 } 116 /* 117 * This Program is distributed under version 1.0 of the Rinza Public 118 * License Agreement, that is bundled with this package in the file119 * LICENSE, and isavailable through the website at the following URL:158 /* 159 * This Program is distributed under version 1.0 of the Rinza Public License 160 * Agreement, that is bundled with this package in the file LICENSE, and is 161 * available through the website at the following URL: 120 162 * http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt. 121 163 * 122 * This is the Original Program. 123 * The Initial Developer of the Original Program is Nihon Unisys, Ltd. 124 * The Original Program is copyrighted (C) 2006 by Nihon Unisys, Ltd. with 125 * all rights reserved. 126 * There is NO WARRANTY OF ANY KIND by the Initial Developer of the 127 * Original Program. 164 * This is the Original Program. The Initial Developer of the Original Program 165 * is Nihon Unisys, Ltd. The Original Program is copyrighted (C) 2006 by Nihon 166 * Unisys, Ltd. with all rights reserved. There is NO WARRANTY OF ANY KIND by 167 * the Initial Developer of the Original Program. 128 168 */ -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/ContentsExtractorLookuper.java
r43 r54 7 7 import java.util.HashMap; 8 8 9 import jp.tyzoh.rinza.folksonomy.common. Util;9 import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 10 10 11 11 /** … … 32 32 33 33 /** 34 * �e�L�X�g���o�N���X�̕ێ��N���X�̏��� * 34 * �e�L�X�g���o�N���X�̕ێ��N���X�̏��� 35 * 35 36 */ 36 37 public ContentsExtractorLookuper() { … … 40 41 41 42 /** 42 * ���o�����N���X 43 * ���o�����N���X�̉� 44 * 43 45 * @param mimeType MIME�^�C�v 44 46 * @return ���o�����N���X … … 50 52 51 53 /** 52 * �t�@�C������ ader�������54 * �t�@�C�������L�X�g�ǂݍ��ݗpReader������� 53 55 * @param file �����ΏۃN���X. 54 56 * @return Reader 55 57 * @throws IOException �t�@�C���ǂݍ��݂Ȃǂł�O�G���[ 58 * @see AutokeywordUtil#findType(File) MIME�^�C�v�̉� 56 59 */ 57 60 public BufferedReader getExtractorReader(File file) throws IOException { 58 final String mimeType = Util.findType(file);61 final String mimeType = AutokeywordUtil.findType(file); 59 62 return new BufferedReader(getExtractor(mimeType).extract(new FileInputStream(file))); 60 63 } 61 64 62 65 /** 63 * �e�L�X�g���o�N���X�ƃR���e���c�^�C�v�̑Ή��\�̏��� * 66 * �e�L�X�g���o�N���X�ƃR���e���c�^�C�v�̑Ή��\�̏��� 67 * 68 * <p> 69 * �W�J�N���X( {@link Extractor}�̎���N���X )�̃C���X�^���X����A 70 * {@link #map}�ɃR���e���c�^�C�v�̕�����L�[�Ɋi�[���� * </p> 64 71 */ 65 72 private void initMap() { … … 68 75 Object obj = null; 69 76 try { 70 obj = Util.createInstance(name, //77 obj = AutokeywordUtil.createInstance(name, // 71 78 new Class[] {,}, new Object[] {,}); 72 79 } catch (Throwable e) { -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/DefaultExtractor.java
r43 r54 14 14 */ 15 15 public class DefaultExtractor implements Extractor { 16 /** �t�@�C���̃G���R�[�h */ 16 17 private final String encode; 17 18 /** ���̓W�J�����̃R���e���c�^�C�v�萔 */ 18 19 private static String CONTENT_TYPE = "text/plain"; 19 20 /** �t�@�C���G���R�[�h�̃f�B�t�H���g�w��/ 20 21 private static String DEFAULT_ENCODING = "jisautodetect"; 21 22 23 /** 24 * �t�@�C���̓W�J�����̏��� 25 * 26 * �G���R�[�h��{@value #DEFAULT_ENCODING}�ŏ����� 27 * @see DefaultExtractor#DefaultExtractor(String) 28 */ 22 29 public DefaultExtractor() { 23 30 this(null); 24 31 } 32 33 /** 34 * �t�@�C���̓W�J�����̏��� 35 * 36 * @param encode �e�L�X�g�̃G���R�[�h 37 */ 25 38 public DefaultExtractor(String encode) { 26 39 this.encode = encode; 27 40 } 41 42 /** 43 * �e�L�X�g�ǂݍ���eader�̎擾. 44 * 45 * @param content ��g���[�� 46 * @return �e�L�X�g�̓Ǎ��p {@link Reader} 47 * @throws IOException �ǂݍ��ݏ�������O�G���[���� 48 */ 28 49 public Reader extract(InputStream content) throws IOException { 29 50 return new InputStreamReader(content, encode==null?DEFAULT_ENCODING:encode); 30 51 } 31 52 53 /** 54 * ���̃e�L�X�g���o�N���X�̃R���e���c�^�C�v. 55 * 56 * @return �R���e���c�^�C�v 57 */ 32 58 public String getContentType() { 33 59 return CONTENT_TYPE; -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/Extractor.java
r43 r54 12 12 public interface Extractor { 13 13 /** 14 * �f�[�^�t�@�C���̃X�g���[���� [�_�[�֕ϊ���������14 * �f�[�^�t�@�C���̃X�g���[����L�X�g���o�������[�_�[�֕ϊ��������� 15 15 * @param content �R���e���c�X�g���[�� 16 16 * @return �e�L�X�g�����̂ݒ��o����Reader -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/pdfbox/PDFExtractor.java
r43 r54 29 29 */ 30 30 public class PDFExtractor implements Extractor { 31 31 /** PDF�̃R���e���c�^�C�v���� */ 32 32 private static final String CONTENT_TYPE_PDF_1 = "application/pdf"; 33 /** PDF�̃R���e���c�^�C�v���� */ 33 34 private static final String CONTENT_TYPE_PDF_2 = "application/x-pdf"; 35 /** CSV�ŕ����L�q����PDF�t�@�C������R���e���c�^�C�v */ 34 36 private static final String CONTENT_TYPE_PDF_ALL_CSV = CONTENT_TYPE_PDF_1+","+CONTENT_TYPE_PDF_2; 35 37 36 38 /** 39 * PDF�t�@�C�������L�X�g�f�[�^�𒊏o����ader������� 40 * 41 * <p> 42 * {@link PDFTextStripper}����ăe�L�X�g���o����B 43 * ������PDFBox�œ���Map������܂������Ȃ��̂� 44 * ��PDF���ǂ߂܂��� 45 * </p> 46 * 47 * @param content PDF�t�@�C���̓��̓�g���[�� 48 * @return �e�L�X�g�f�[�^�̒��o���ꂽReader 49 * @throws IOException �X�g���[���ǂݍ��ݎ��A����PDF����� 50 * @see PDFTextStripper PDFBox�̃e�L�X�g���o�����N���X 51 */ 37 52 public Reader extract(InputStream content) throws IOException { 38 53 try { 39 54 PDFParser parser = new PDFParser(content); 40 55 parser.parse(); 41 42 56 43 57 PDDocument document = parser.getPDDocument(); 44 58 CharArrayWriter writer = new CharArrayWriter(); … … 57 71 } 58 72 59 73 /** 74 * PDF�t�@�C���̃R���e���c�^�C�v���������� * @return PDF�t�@�C���̃R���e���c�^�C�v 75 */ 60 76 public String getContentType() { 61 77 return CONTENT_TYPE_PDF_ALL_CSV; -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSExcelExtractor.java
r43 r54 31 31 */ 32 32 public class MSExcelExtractor implements Extractor { 33 33 /** Excel�̃R���e���c�^�C�v���� */ 34 34 static final String CONTENT_TYPE_EXCEL_1 = "application/msexcel"; 35 /** Excel�̃R���e���c�^�C�v���� */ 35 36 static final String CONTENT_TYPE_EXCEL_2 = "application/vnd.ms-excel"; 37 /** CSV�ŕ����L�q����Excel�t�@�C������R���e���c�^�C�v */ 36 38 static final String CONTENT_TYPE_EXCEL_ALL_CSV = CONTENT_TYPE_EXCEL_1+","+CONTENT_TYPE_EXCEL_2; 37 39 40 /** 41 * Excel�t�@�C�������L�X�g�f�[�^�𒊏o����ader������� 42 * 43 * <p> 44 * POI��SSF�̎���𗘗p����xcel�̃Z�����當�������o���� * </p> 45 * 46 * @param content Excel�t�@�C���̓��̓�g���[�� 47 * @return �e�L�X�g�f�[�^�̒��o���ꂽReader 48 * @throws IOException �X�g���[���ǂݍ��ݎ��A����Excel�t�@�C������� 49 * @see <a href="http://poi.apache.org/">Apache POI</a> 50 */ 38 51 public Reader extract(InputStream content) throws IOException { 39 52 try { … … 76 89 } 77 90 91 /** 92 * Excel�t�@�C���̃R���e���c�^�C�v���������� * @return Excel�t�@�C���̃R���e���c�^�C�v 93 */ 78 94 public String getContentType() { 79 95 return CONTENT_TYPE_EXCEL_ALL_CSV; -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSPowerPointExtractor.java
r43 r54 27 27 */ 28 28 public class MSPowerPointExtractor implements Extractor { 29 /** PowerPoint�̃R���e���c�^�C�v���� */ 29 30 static final String CONTENT_TYPE_POWERPOINT_1 = "application/mspowerpoint"; 30 31 /** PowerPoint�̃R���e���c�^�C�v���� */ 31 32 static final String CONTENT_TYPE_POWERPOINT_2 = "application/vnd.ms-powerpoint"; 32 33 /** CSV�ŕ����L�q����PowerPoint�t�@�C������R���e���c�^�C�v */ 33 34 static final String CONTENT_TYPE_POWERPOINT_ALL_CSV = CONTENT_TYPE_POWERPOINT_1 34 35 + "," + CONTENT_TYPE_POWERPOINT_2; 35 36 37 /** 38 * PowerPoint�t�@�C�������L�X�g�f�[�^�𒊏o����ader������� 39 * 40 * <p> 41 * POI��SLF�̎���𗘗p����owerPoint���當�������o���� * </p> 42 * 43 * @param content PowerPoint�t�@�C���̓��̓�g���[�� 44 * @return �e�L�X�g�f�[�^�̒��o���ꂽReader 45 * @throws IOException �X�g���[���ǂݍ��ݎ��A����PowerPoint�t�@�C������� 46 * @see <a href="http://poi.apache.org/">Apache POI</a> 47 */ 36 48 public Reader extract(InputStream content) throws IOException { 37 49 final CharArrayWriter writer = new CharArrayWriter(); … … 69 81 } 70 82 83 /** 84 * PowerPoint�t�@�C���̃R���e���c�^�C�v���������� * @return PowerPoint�t�@�C���̃R���e���c�^�C�v 85 */ 71 86 public String getContentType() { 72 87 return CONTENT_TYPE_POWERPOINT_ALL_CSV; -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSWordExtractor.java
r43 r54 22 22 */ 23 23 public class MSWordExtractor implements Extractor { 24 /** MS-Word�̃R���e���c�^�C�v���� */ 24 25 static final String CONTENT_TYPE_WORD_1 = "application/msword"; 26 /** MS-Word�̃R���e���c�^�C�v���� */ 25 27 static final String CONTENT_TYPE_WORD_2 = "application/vnd.ms-word"; 28 /** CSV�ŕ����L�q����MS-Word�t�@�C������R���e���c�^�C�v */ 26 29 static final String CONTENT_TYPE_WORD_ALL_CSV = CONTENT_TYPE_WORD_1+","+CONTENT_TYPE_WORD_2; 27 30 31 /** 32 * MS-Word�t�@�C�������L�X�g�f�[�^�𒊏o����ader������� 33 * 34 * <p> 35 * POI��WPF�̎���𗘗p���ĕ��������o���� * </p> 36 * 37 * @param content MS-Word�t�@�C���̓��̓�g���[�� 38 * @return �e�L�X�g�f�[�^�̒��o���ꂽReader 39 * @throws IOException �X�g���[���ǂݍ��ݎ��A����MS-Word�t�@�C������� 40 * @see <a href="http://poi.apache.org/">Apache POI</a> 41 */ 28 42 public Reader extract(InputStream content) throws IOException { 29 43 try { … … 36 50 } 37 51 52 /** 53 * MS-Word�t�@�C���̃R���e���c�^�C�v���������� * @return MS-Word�t�@�C���̃R���e���c�^�C�v 54 */ 38 55 public String getContentType() { 39 56 return CONTENT_TYPE_WORD_ALL_CSV; -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Auto.java
r15 r54 4 4 import java.io.*; 5 5 6 import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 7 8 import org.apache.log4j.BasicConfigurator; 9 import org.apache.log4j.ConsoleAppender; 10 import org.apache.log4j.Level; 11 import org.apache.log4j.Logger; 12 6 13 /** 7 * � L�[���[�h�������o14 * �Ώۃt�@�C���̃L�[���[�h���o�ƑΉ������������F-IDF�l������� 8 15 * 9 16 * <BR><BR>Copyright (C) 2006 Nihon Unisys, Ltd. All Rights Reserved. 10 17 */ 11 18 public class Auto { 12 Engine engine = new Engine(); 13 PrintWriter out = new PrintWriter(System.out); 19 /** �L�[���[�h���o�G���W�� */ 20 private final Engine engine = new Engine(); 21 /** �f�o�b�O�o��*/ 22 private final PrintWriter out = new PrintWriter(System.out); 14 23 24 /** 25 * �R�}���h��s 26 * @param args ��s�����߂̈��t�@�C������肷�� 27 */ 15 28 public static void main(String args[]) 16 29 { … … 24 37 } 25 38 39 BasicConfigurator.resetConfiguration(); 40 final Logger log = AutokeywordUtil.getLogger(); 41 log.addAppender(new ConsoleAppender()); 42 log.setLevel(Level.DEBUG); 43 26 44 Auto auto = new Auto(); 27 45 auto.fire(file.getAbsolutePath()); 28 46 } 29 47 48 /** 49 * ���̃R�}���h�̎g�p���\���ƃR�}���h��s�̏I��. 50 * 51 */ 30 52 private static void usageAndExit() 31 53 { … … 34 56 } 35 57 58 /** 59 * ���̏����̏��� 60 * 61 * <p> 62 * ���̃p�b�P�[�W�Ɠ����f�B���N�g���ɂ������@�C�� 63 * (<code>autokeyword.properties</code>)��ݍ��݁A 64 * {@link Engine}����� * </p> 65 */ 36 66 public void init() 37 67 { … … 39 69 try { 40 70 properties.load(Auto.class.getClassLoader().getResourceAsStream("autokeyword.properties")); 41 engine.init(properties , out);71 engine.init(properties); 42 72 } catch (IOException ex) { 43 73 ex.printStackTrace(out); … … 45 75 } 46 76 47 77 /** 78 * �t�@�C���̃L�[���[�h�Ƃ���F-IDF�l������� * @param filename �L�[���[�h���o�Ώۃt�@�C�� 79 * @return �L�[���[�h��F-IDF����� {@link Result}�̃R���N�V���� 80 * Collection<Result> 81 */ 48 82 public Collection getKeywords(String filename) 49 83 { … … 52 86 } 53 87 88 /** 89 * ������s�Ǝ�s���ʕ\�� 90 * @param filename �L�[���[�h���o�Ώۃt�@�C�� 91 */ 54 92 public void fire(String filename) 55 93 { 56 94 init(); 57 Collection collection = engine.getKeywords(filename , new PrintWriter(System.out));95 Collection collection = engine.getKeywords(filename); 58 96 59 97 out.println("TFIDF �J�n"); … … 61 99 while(iterator.hasNext()) { 62 100 Result result = (Result)iterator.next(); 63 out.println(result. info());101 out.println(result.toString()); 64 102 } 65 103 out.println("TFIDF �I��"); -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Engine.java
r47 r54 4 4 import java.io.*; 5 5 6 import org.apache.log4j.Logger; 7 6 8 import jp.tyzoh.rinza.folksonomy.analyze.*; 9 import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 7 10 import jp.tyzoh.rinza.folksonomy.search.*; 8 11 … … 33 36 * @return �������� 34 37 */ 35 public boolean init(Properties properties , PrintWriter out)38 public boolean init(Properties properties) 36 39 { 37 40 String analyzerName = properties.getProperty(ANALYZER_CLASS_NAME, ANALYZER_CLASS_NAME_DEFAULT); 38 41 try { 39 42 analyzer = (Analyzer)Class.forName(analyzerName).newInstance(); 40 if (!analyzer.init(properties , out)) {41 if (out != null) out.println(analyzerName + " is not initialized");43 if (!analyzer.init(properties)) { 44 AutokeywordUtil.getLogger().fatal("�����̓N���X"+analyzerName+"�̏������s���܂���"); 42 45 return false; 43 46 } 44 47 } catch(Exception ex) { 45 if (out != null) out.println(analyzerName + " is not supported.");48 AutokeywordUtil.getLogger().fatal("�����̓N���X"+analyzerName+"�̏������s���܂���", ex); 46 49 return false; 47 50 } … … 50 53 try { 51 54 searcher = (Searcher)Class.forName(searcherName).newInstance(); 52 if (!searcher.init(properties, out)) { 53 String message = searcherName + " is not initialized"; 54 if (out != null) out.println(message); 55 System.err.println(message); 55 if (!searcher.init(properties)) { 56 AutokeywordUtil.getLogger().fatal("�S��������X"+searcherName+"�̏������s���܂���"); 56 57 return false; 57 58 } 58 59 } catch(Exception ex) { 59 String message = searcherName + " is not initialized"; 60 if (out != null) out.println(message); 61 System.err.println(message); 60 AutokeywordUtil.getLogger().fatal("�S��������X"+searcherName+"�̏������s���܂���", ex); 62 61 return false; 63 62 } … … 68 67 /** 69 68 * �L�[���[�h�R���N�V�����̈ꗗ�\�� 70 * @param out �f�o�b�O�o��71 69 * @param keywords �L�[���[�h�R���N�V���� (Collection<Keyword>) 72 70 */ 73 void debug(PrintWriter out, Collection keywords) 74 { 75 if (out != null) { 76 out.println("�L�[���[�h�ꗗ �J�n"); 71 void debug(Collection keywords) 72 { 73 final Logger log = AutokeywordUtil.getLogger(); 74 if(log.isDebugEnabled()) { 75 log.debug("�L�[���[�h�ꗗ �J�n"); 77 76 for(Iterator iterator = keywords.iterator(); iterator.hasNext(); ) { 78 77 final Keyword keyword = (Keyword)iterator.next(); 79 out.println(keyword.info()); 80 } 81 out.println("�L�[���[�h�ꗗ �I��"); 82 } 83 } 84 85 /** 86 * �L�[���[�h���o���(�f�o�b�O�o�͂Ȃ�) 87 * @param filename �L�[���[�h���o�̑Ώۃt�@�C���� 88 * @return �L�[���[�h�̃R���N�V���� (Collection<Keyword>) 89 * @see #getKeywords(String, PrintWriter) �f�o�b�O�o�͂Ȃ��Ōďo�B 90 */ 91 public Collection getKeywords(String filename) 92 { 93 return getKeywords(filename, null); 94 } 95 78 log.debug(keyword.toString()); 79 } 80 log.debug("�L�[���[�h�ꗗ �I��"); 81 } 82 } 83 96 84 /** 97 85 * �L�[���[�h���o��� … … 104 92 * 105 93 * @param filename �L�[���[�h���o�̑Ώۃt�@�C���� 106 * @param out �f�o�b�O�o�� 107 * @return �L�[���[�h�̃R���N�V���� (Collection<Keyword>) 108 */ 109 public Collection getKeywords(String filename, PrintWriter out) 94 * @return �L�[���[�h�̃R���N�V���� (Collection<Result>) 95 */ 96 public Collection getKeywords(String filename) 110 97 { 111 98 ArrayList results = new ArrayList(); … … 115 102 File[] fileArray = file.listFiles(); 116 103 int fileCount = fileArray.length; 117 if (out != null) out.println("N " + fileCount); 118 119 final Collection localKeywords = getLocalKeywords(filename, out); 104 final Logger log = AutokeywordUtil.getLogger(); 105 if(log.isDebugEnabled()) { 106 log.debug("N " + fileCount); 107 } 108 109 final Collection localKeywords = getLocalKeywords(filename); 120 110 for(Iterator iterator = localKeywords.iterator(); iterator.hasNext();) { 121 111 final Keyword keyword = (Keyword)iterator.next(); … … 134 124 135 125 /** 136 * T I-IDF�l�̌v�Z126 * TF-IDF�l�̌v�Z 137 127 * @param keyword �L�[���[�h�� 138 128 * @param fileCount �W�{���c�̐� 139 * @return 129 * @return TF-IDF�l 140 130 */ 141 131 private double calclateTfidf(Keyword keyword, int fileCount) { … … 152 142 return keyword.getCount()*Math.log((double)fileCount/df); 153 143 } 144 154 145 /** 155 146 * �L�[���[�h�̒��o … … 159 150 * </p> 160 151 * @param filename �Ώۃt�@�C�� 161 * @param out �f�o�b�O�o��162 152 * @return Collection<Keyword> 163 153 */ 164 public Collection getLocalKeywords(String filename , PrintWriter out)154 public Collection getLocalKeywords(String filename) 165 155 { 166 156 //Analyzer�ɃL�[���[�h�̐��K��������߂� 167 return analyzer.parse(filename , null);157 return analyzer.parse(filename); 168 158 } 169 159 -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Hidden.java
r43 r54 1 1 package jp.tyzoh.rinza.folksonomy.keyword; 2 2 3 import java.util.*; 4 import java.io.*; 3 import java.io.File; 4 import java.io.IOException; 5 import java.io.PrintWriter; 6 import java.util.Collection; 7 import java.util.Iterator; 8 import java.util.Properties; 9 10 import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 11 12 import org.apache.log4j.BasicConfigurator; 13 import org.apache.log4j.ConsoleAppender; 14 import org.apache.log4j.Level; 15 import org.apache.log4j.Logger; 5 16 6 17 /** 7 * ������18 * 8 19 * 9 20 * <BR><BR>Copyright (C) 2007 Nihon Unisys, Ltd. All Rights Reserved. … … 23 34 } 24 35 36 BasicConfigurator.resetConfiguration(); 37 final Logger log = AutokeywordUtil.getLogger(); 38 log.addAppender(new ConsoleAppender()); 39 log.setLevel(Level.DEBUG); 40 25 41 Hidden hidden = new Hidden(); 26 42 hidden.fire(file.getAbsolutePath()); … … 38 54 try { 39 55 properties.load(Auto.class.getClassLoader().getResourceAsStream("autokeyword.properties")); 40 init(properties , out);56 init(properties); 41 57 } catch (IOException ex) { 42 ex.printStackTrace( out);58 ex.printStackTrace(); 43 59 } 44 60 } … … 47 63 { 48 64 init(); 49 Collection collection = getKeywords(filename , new PrintWriter(System.out));65 Collection collection = getKeywords(filename); 50 66 51 67 out.println("TFIDF �J�n"); … … 53 69 while(iterator.hasNext()) { 54 70 Result result = (Result)iterator.next(); 55 out.println(result. info());71 out.println(result.toString()); 56 72 } 57 73 out.println("TFIDF �I��"); … … 65 81 } 66 82 67 public Collection getLocalKeywords(String filename , PrintWriter out)83 public Collection getLocalKeywords(String filename) 68 84 { 69 return super.getLocalKeywords(filename , out);85 return super.getLocalKeywords(filename); 70 86 } 71 87 } -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Result.java
r47 r54 17 17 private final double tfidf; 18 18 19 public Result(Keyword keyword, double tidf) 19 /** 20 * �L�[���[�h�{TFIDF�l�̒lBean�̍쐬. 21 * <p> 22 * ���̃C���X�^���X��mmutable�ł��� 23 * 24 * </p> 25 * @param keyword �L�[���[�h 26 * @param tfidf TFIDF�l 27 */ 28 public Result(Keyword keyword, double tfidf) 20 29 { 21 30 this.keyword = keyword; 22 this.tfidf = t idf;31 this.tfidf = tfidf; 23 32 } 24 33 34 /** 35 * TF-IDF�l�̎擾. 36 * 37 * @return TF-IDF�l 38 */ 25 39 public double getTFIDF() 26 40 { … … 28 42 } 29 43 44 /** 45 * �L�[���[�h������擾 46 * @return �L�[���[�h������ * @see Keyword#getWord() �����͂ł̃L�[���[�h�� 47 */ 30 48 public String getWord() 31 49 { … … 34 52 35 53 /** 54 * ���̃C���X�^���X�̕�������̕�����擾���� 55 * 56 * @return ���̃C���X�^���X�̕������ 57 * @see Object#toString() 58 */ 59 public String toString() 60 { 61 return new StringBuffer().append(getTFIDF()).append("\t").append(keyword.toString()).toString(); 62 } 63 64 /** 36 65 * �\�[�g�̂��߂̎��R�������\�b�h 37 66 * 38 67 * <p> 39 * tfidf�l�̑傫�����Ƀ\�[�g���� * </p> 68 * ���̃C���X�^���X�̎��R�����͈ȉ��̂Ƃ��� * <ol> 69 * <li>tfidf(�~��) 70 * <li>word(������) 71 * </ol> 72 * </p> 40 73 * 41 * TODO �\�[�g���ʂɓ���-IDF�l���̃L�[���[�h�ł̃\�[�g��������42 74 * 43 75 * @param obj ���Ώ� … … 53 85 return -1; 54 86 } else if (result.getTFIDF() == getTFIDF()) { 55 return 0; 87 return getWord().compareTo(result.getWord()); 88 //return 0; 56 89 } else { 57 90 return 1; 58 91 } 59 }60 61 public String info()62 {63 return getTFIDF() + "\t" + keyword.info();64 92 } 65 93 } -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/search/LuceneJa.java
r47 r54 3 3 import java.io.File; 4 4 import java.io.IOException; 5 import java.io.PrintWriter;6 5 import java.io.Reader; 7 6 import java.util.ArrayList; … … 13 12 import java.util.Properties; 14 13 14 import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 15 15 import jp.tyzoh.rinza.folksonomy.extractor.ContentsExtractorLookuper; 16 16 … … 38 38 */ 39 39 public class LuceneJa implements Searcher { 40 /** Lucene�̑S����Ώۂ̃f�[�^�i�[�L�[ */ 41 private static final String LUCENE_SEARCH_CONTENTS = "contents"; 42 /** Lucene�̍ŏI�X�V���Ԃ̃f�[�^�i�[�L�[ */ 43 private static final String LUCENE_MODIFIED = "modified"; 44 /** Lucene�̉�Ώۃt�@�C���̃p�X���f�[�^�̊i�[�L�[ */ 45 private static final String LUCENE_PATH_INFO = "path"; 46 40 47 // 41 private static final String LUCENE_SEARCH_CONTENTS = "contents"; 42 43 private static final String LUCENE_MODIFIED = "modified"; 44 45 private static final String LUCENE_PATH_INFO = "path"; 46 47 // 48 /** Lucene�̃C���f�b�N�X���̊i�[�f�B���N�g�� */ 48 49 private String indexDirectory = DEFAULT_LUCENE_INDEX_DIRECTORY; 49 50 /** Lucene�̐ݒ��@�C����(Sen�ݒ�*/ 50 51 private String command = DEFAULT_COMMAND; 51 52 /** Lucene�̉�Ώۃt�@�C���f�B���N�g�� */ 52 53 private String fileDirectory = DEFAULT_FILESTORE_DIRECTORY; 53 54 /** �����͗p�̃C���^�[�t�F�[�X */ 54 55 private Analyzer analyzer = null; 55 56 /** Lucene�̌���}�l�[�W���N���X */ 56 57 private IndexSearcherManager searcherManager = null; 57 58 /** �e�L�X�g���o�����p�̎���擾�p�N���X */ 58 59 private ContentsExtractorLookuper lookuper = null; 59 60 /** �t�@�C���i�[�f�B���N�g���̋K�� */ 60 61 private static final String DEFAULT_FILESTORE_DIRECTORY = "/var/lib/tPod/files"; 61 62 /** Lucene�̐ݒ��@�C�����̋K��(Sen�ݒ�*/ 62 63 private static final String DEFAULT_COMMAND = "/var/lib/tPod/sen/conf/sen.xml"; 63 64 /** Lucene�̃C���f�b�N�X���̊i�[�f�B���N�g���̋K�� s*/ 64 65 private static final String DEFAULT_LUCENE_INDEX_DIRECTORY = "/var/lib/tPod/index"; 65 66 … … 67 68 * ������ 68 69 * 69 * @param properties �ݒ� * @param out �f�o�b�O�o�� 70 * @return ��s�̐��� 71 */ 72 public boolean init(Properties properties, PrintWriter out) { 70 * @param properties �ݒ� * @return ��s�̐��� 71 */ 72 public boolean init(Properties properties) { 73 73 fileDirectory = properties.getProperty(CONTENTS_DIRECTORY, // 74 74 properties.getProperty(CONTENTS_DIRECTORY2, fileDirectory)); … … 79 79 searcherManager = new IndexSearcherManager(indexDirectory); 80 80 lookuper = new ContentsExtractorLookuper(); 81 82 AutokeywordUtil.getLogger().info("Lucene(ja)���������܂���"); 81 83 return true; 82 84 } 83 85 86 /** 87 * Lucene�̏I�������� 88 */ 84 89 public void destroy() { 85 86 } 87 90 } 91 92 /** 93 * Lucene�̉�Ώۃt�@�C���̔z�u�ʒu. 94 * @return �Ώۃf�B���N�g�� 95 */ 88 96 public File getTargetDirectory() { 89 97 return new File(fileDirectory); … … 94 102 * 95 103 * @param keywordList �L�[���[�h���X�g(List<String>) 96 * @param out �f�o�b�O�o��97 104 * @return ����ʂ̃t�@�C�����̃R���N�V���� Collection<String> 98 105 */ 99 public Collection /* <String> */search(List keywordList, PrintWriter out,int offset, int limit) {106 public Collection /* <String> */search(List keywordList, int offset, int limit) { 100 107 final ArrayList al = new ArrayList(); 101 108 IndexSearcherPool isp = null; … … 121 128 } 122 129 } catch (ParseException e) { 123 if (out != null) { 124 e.printStackTrace(out); 125 } 130 AutokeywordUtil.getLogger().warn("Lucene����ɉ�G���[���������܂���", e); 126 131 } catch (IOException e) { 127 if (out != null) { 128 e.printStackTrace(out); 129 } 132 AutokeywordUtil.getLogger().warn("Lucene�����O�G���[���������܂���", e); 130 133 } 131 134 } … … 139 142 * �S������� 140 143 * 141 * @see #search(List, PrintWriter, int, int) �J�n�ʒu/�\����0�Ƃ��đS���\����� 142 */ 143 public Collection search(List keywordList, PrintWriter out) { 144 return search(keywordList, out, 0, 0); 144 * @param keywordList �S������̌�������X�g 145 * @see #search(List, int, int) �J�n�ʒu/�\����0�Ƃ��đS���\����� 146 */ 147 public Collection search(List keywordList) { 148 return search(keywordList, 0, 0); 145 149 } 146 150 147 151 /** 148 152 * �S������s����ꍇ�̊Y������������� 153 * @param keywordList �S������̌�������X�g 154 * @return �Ή������t�@�C���̑��� 149 155 */ 150 156 public int searchCount(List keywordList) { … … 177 183 * �L�[���[�h����������Ȃ� 178 184 * 179 * @param keywordList 180 * @return 181 */ 182 private String parseKeyword(List keywordList) { 185 * @param keywordList �����ΏۃL�[���[�h������ * @return������łȂ��������� */ 186 private static String parseKeyword(List keywordList) { 183 187 final StringBuffer buf = new StringBuffer(); 184 188 for (int i = 0; i < keywordList.size(); i++) { … … 194 198 * �S���C���f�b�N�X����. 195 199 * 196 * @param out 197 * �f�o�b�O�o�͗p 198 */ 199 public Collection indexing(PrintWriter out) { 200 */ 201 public void indexing() { 200 202 synchronized (this) { 201 203 final boolean isCreate = (!IndexReader.indexExists(indexDirectory)); … … 230 232 reader.close(); 231 233 } catch (IOException e) { 232 e.printStackTrace();234 AutokeywordUtil.getLogger().warn("Lucene�C���f�b�N�X�Đ������ɃG���[���������܂���", e); 233 235 } 234 236 } … … 253 255 searcherManager.updateSearcher(); 254 256 } 255 return null;256 257 } 257 258 258 259 /** 259 * �t�@�C�������L�X�g�����𒊏o���� 260 * �t�@�C�������L�X�g�����𒊏o�����S������t�@�C����������� 260 261 * @param parent �e�f�B���N�g�� 261 262 * @param name �t�@�C���� 262 * @return 263 * @return �e�L�X�g���o�����f�[�^��b�g��������ۃf�[�^ 263 264 */ 264 265 private Document createDocument(File parent, String name) { … … 282 283 } 283 284 285 /** 286 * �ŏI�X�V���Ԃ̕�����쐬���� 287 * @param file �Ώۃt�@�C�� 288 * @return Lucene�̓��`���p�̎����������� * @see DateField#timeToString(long) 289 */ 284 290 private static String findLastModified(File file) { 285 291 return DateField.timeToString(file.lastModified()); … … 305 311 private IndexSearcherPool searcherPool = null; 306 312 313 /** 314 * �C���f�b�N�X�ł̌�����}�l�[�W������. 315 * 316 * @param indexDirectory ����ۂ̃C���f�b�N�X�f�B���N�g�� 317 */ 307 318 public IndexSearcherManager(String indexDirectory) { 308 319 this.indexDirectory = indexDirectory; … … 310 321 } 311 322 312 // 323 /** 324 * ������̎؎� * @return ������N���X. 325 */ 313 326 private IndexSearcherPool rentSearcher() { 314 327 synchronized (this) { … … 319 332 } 320 333 334 /** 335 * ������̕ԋp 336 * @param isp �ԋp����@link IndexSearcherPool} 337 */ 321 338 private void returnSearcher(IndexSearcherPool isp) { 322 339 IndexSearcher is = null; … … 330 347 } 331 348 349 /** 350 * �t�@�C���lj�Ȃǂł̌���������̍X�V����. 351 * 352 */ 332 353 private void updateSearcher() { 333 354 IndexSearcher is = null; … … 344 365 } 345 366 367 /** 368 * ������̏��� 369 * @param indexDirectory ������f�b�N�X�f�B���N�g�� 370 * @return �������. 371 */ 346 372 private static IndexSearcherPool openSearcher(String indexDirectory) { 347 373 IndexSearcher is = null; … … 353 379 } 354 380 381 /** 382 * ������̏I�� 383 * @param is ����� 384 */ 355 385 private static void closeSearcher(IndexSearcher is) { 356 386 if (is != null) { … … 363 393 } 364 394 365 // 395 /** 396 * �T�[�`�p�̃I�u�W�F�N�g�̃v�[���N���X. 397 * 398 * 399 * <BR> 400 * <BR> 401 * Copyright (C) 2007 Nihon Unisys, Ltd. All Rights Reserved. 402 */ 366 403 private static class IndexSearcherPool { 367 404 private final IndexSearcher searcher; 368 405 /** ���̌�����͍X�V�҂����H */ 369 406 private boolean isUpdated; 370 407 /** ��s���X���b�h�̏� ��s���̃X���b�h���o�^���� */ 371 408 private final HashSet /* <Thread> */runningSet = new HashSet(); 372 409 /** 410 * Lucene�̌������肵�ď����� 411 * @param searcher Lucene�C���f�b�N�X�T�[�` 412 */ 373 413 public IndexSearcherPool(IndexSearcher searcher) { 374 414 this.searcher = searcher; 375 415 } 376 416 377 // 417 /** 418 * �i�[���Ă��錟����̎擾 419 * @return �i�[���Ă��錟��� 420 */ 378 421 public IndexSearcher getSearcher() { 379 422 return searcher; 380 423 } 381 424 382 // 425 /** 426 * ���̌�����͍X�V������ꂽ���H 427 * @param isUpdated 428 */ 383 429 public void setUpdated(boolean isUpdated) { 384 430 this.isUpdated = isUpdated; 385 431 } 386 432 433 /** 434 * ���̌�����̗��p��n���� 435 * 436 */ 387 437 public void lock() { 388 438 runningSet.add(Thread.currentThread()); 389 439 } 390 440 441 /** 442 * ���̌�����̗��p��߂� 443 * 444 */ 391 445 public void unlock() { 392 446 runningSet.remove(Thread.currentThread()); 393 447 } 394 448 449 /** 450 * ���̃v�[���͕����v������āA�������邩�H 451 * @return �����v�������g�p�������̂ŕ�������trye 452 */ 395 453 public boolean needClose() { 396 454 return isUpdated && runningSet.isEmpty(); -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/search/Namazu.java
r47 r54 34 34 return new File(fileDirectory); 35 35 } 36 37 public boolean init(Properties properties, PrintWriter out) 36 /** 37 * Namazu������� 38 * 39 * @param properties �ݒ��e 40 * @param out �f�o�b�O�o�� 41 */ 42 public boolean init(Properties properties) 38 43 { 39 44 encodeType = properties.getProperty(ENCODE_TYPE, // … … 45 50 index = properties.getProperty(INDEX_COMMAND, "c:\\namazu\\bin\\mknmz.bat \"" + fileDirectory + "\" -O"); 46 51 indexDirectory = properties.getProperty(INDEX_DIRECTORY, indexDirectory); 47 52 AutokeywordUtil.getLogger().info("Namazu ���������܂���"); 48 53 return true; 49 54 } 50 51 public Collection search(List keywordList, PrintWriter out) { 52 return search(keywordList, out, 0,0); 55 /** 56 * Namazu�o�R�ł̌����. 57 * 58 * @param keywordList ����[���[�h������ */ 59 public Collection search(List keywordList) { 60 return search(keywordList, 0,0); 53 61 } 54 public Collection search(List keywordList, PrintWriter out, int offset, int limit) 62 63 /** 64 * Namazu�o�R�ł̌����. 65 * 66 * @param keywordList ����[���[�h������ * @param offset ����ʊJ�n�ʒu 67 * @param limit ����ʏI���� 68 */ 69 public Collection search(List keywordList, int offset, int limit) 55 70 { 56 71 StringBuffer execBuf = new StringBuffer(); … … 69 84 execBuf.append(" ").append(indexDirectory); 70 85 71 return Util.exec(execBuf.toString(), encodeType, out);86 return AutokeywordUtil.exec(execBuf.toString(), encodeType); 72 87 } 73 88 89 /** 90 * ������őΉ����錟��ʐ��̎擾. 91 * @param ��������� * @return ����ʏW 92 */ 74 93 public int searchCount(List keywordList) { 75 94 StringBuffer execBuf = new StringBuffer(); … … 83 102 execBuf.append(" ").append(indexDirectory); 84 103 85 int count = -1;86 final Collection c = Util.exec(execBuf.toString(), encodeType, null);104 int count = 0; 105 final Collection c = AutokeywordUtil.exec(execBuf.toString(), encodeType); 87 106 if(c.size()==1) { 88 107 final String s = (String) c.iterator().next(); … … 95 114 } 96 115 97 public Collection indexing(PrintWriter out) 116 /** 117 * �C���f�b�N�X�쐬���� 118 * @param out �C���f�b�N�X�쐬���̃f�o�b�O�o�� 119 */ 120 public void indexing() 98 121 { 99 122 String command = index + " " + indexDirectory; 100 123 101 return Util.exec(command, encodeType, out);124 AutokeywordUtil.exec(command, encodeType); 102 125 } 103 126 -
AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/search/Searcher.java
r47 r54 29 29 /** 30 30 * ���� * @param properties �ݒ� * @param out �f�o�b�O�o�� 31 * @return 31 * @return �������̐��� 32 32 */ 33 public boolean init(Properties properties, PrintWriter out); 33 public boolean init(Properties properties); 34 34 35 /** 35 * �Ώۃ f�B���N�g��36 * @return 36 * �Ώۃt�@�C���̂����B���N�g���̎擾 37 * @return �f�B���N�g�� 37 38 */ 38 39 public File getTargetDirectory(); … … 41 42 * ����� 42 43 * @param keywordList �L�[���[�h���X�g 43 * @param out �f�o�b�O�o��44 44 * @return Collection<String> 45 45 */ 46 public Collection search(List keywordList , PrintWriter out);46 public Collection search(List keywordList); 47 47 48 48 /** 49 49 * �����(���������) 50 50 * @param keywordList �L�[���[�h���X�g 51 * @param out �f�o�b�O�o��52 51 * @param offset ����ʊJ�n�ʒu 53 52 * @param limit ����ʍő吔 54 53 * @return Collection<String> 55 54 */ 56 public Collection search(List keywordList, PrintWriter out,int offset, int limit);55 public Collection search(List keywordList, int offset, int limit); 57 56 58 57 /** … … 70 69 * @param out �f�o�b�O�o�� 71 70 */ 72 public Collection indexing(PrintWriter out);71 public void indexing(); 73 72 74 73 /**
