チェンジセット 54

差分発生行の前後
無視リスト:
更新日時:
2007/06/25 15:11:41 (5 年 前)
更新者:
masa
ログメッセージ:

Autokeyword logging by log4j

パス:
AutoKeyword/trunk
ファイル:
20 変更
1 移動

凡例:

変更なし
追加
削除
  • AutoKeyword/trunk/README

    r6 r54  
    6363Mecab 0.93 
    6464java 1.5.03(おそらく、これ以前のバージョンでもコンパイル/実行可能です) 
     65Jakarta Logging Log4j 1.2.12+ [http://logging.apache.org/log4j/] 
    6566 
    6667■ 環境設定 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Analyzer.java

    r47 r54  
    22 
    33import java.util.*; 
    4 import java.io.*; 
    54 
    65/** 
     
    2019         * �ݒ菉��         * @param properties �ݒ��e 
    2120         * @param out �f�o�b�O�o�� 
    22          * @return 
     21         * @return �������� 
    2322         */ 
    24         public boolean init(Properties properties, PrintWriter out); 
     23        public boolean init(Properties properties); 
    2524 
    2625        /** 
     
    3029         * @param out ��s���f�o�b�O�o�� 
    3130         * @return ��s����ʃf�[�^ Collection<Keyword> 
    32          *  
    33          * @see #exec(String, String, PrintWriter)  
    34          * @see #parse(Collection)  
    3531         */ 
    36         public Collection parse(String filename,  PrintWriter out ); 
     32        public Collection parse(String filename); 
    3733} 
    3834/*  
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Keyword.java

    r47 r54  
    22 
    33/** 
    4  * �`�ԑf��̌��ʂ�������� 
     4 * �`�ԑf��̌��ʂ������an�N���X. 
    55 * 
    66 * <BR><BR>Copyright (C) 2006 Nihon Unisys, Ltd. All Rights Reserved. 
     
    1717         
    1818        /** 
    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] 
    2224         * @param count �o���� 
    2325         */ 
     
    3133         
    3234        /** 
    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) 
    3644         */ 
    3745        public Keyword(String word, String part, String sub) 
     
    4048        } 
    4149 
     50        /** 
     51         * �L�[���[�h�̕�����擾����        * @return �L�[���[�h������ */ 
    4252        public String getWord() 
    4353        { 
     
    4555        } 
    4656 
     57        /** 
     58         * ���̃L�[���[�h�̕i�����������   * @return �i���� 
     59         */ 
    4760        public String getPart() 
    4861        { 
     
    5063        } 
    5164 
     65        /** 
     66         * ���̃L�[���[�h�̕i���ו����������        * @return �i���ו��� 
     67         */ 
    5268        public String getSub() 
    5369        { 
     
    5571        } 
    5672 
     73        /** 
     74         * ���̃L�[���[�h�̏o���񐔂������ 
     75         * @return �o���� 
     76         */ 
    5777        public int getCount() 
    5878        { 
    5979                return count; 
    6080        } 
    61         // 
     81         
     82        /** 
     83         * ���̃L�[���[�h�̏o���񐔂�肷�� 
     84         * @param c �o���� 
     85         */ 
    6286        public void setCount(int c) { 
    6387                count = c; 
    6488        } 
    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() 
    6696        { 
    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(); 
    68102        } 
    69103} 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/KeywordFilter.java

    r47 r54  
    2222        /** ������������߂̃o�b�t�@ */ 
    2323        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> */ 
    2525        private HashMap /* <String, Keyword> */keywordMap = new HashMap(); 
    2626 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Mecab.java

    r47 r54  
    22 
    33import java.util.*; 
    4 import java.io.*; 
     4 
    55import jp.tyzoh.rinza.folksonomy.common.*; 
    66 
     
    2727         * �����̏���     * @param properties �ݒ��e 
    2828         * @param out �f�o�b�O�o�� 
     29         * @return ������ 
     30         * @see Analyzer#init(Properties) 
    2931         */ 
    30         public boolean init(Properties properties, PrintWriter out) 
     32        public boolean init(Properties properties) 
    3133        { 
    3234                command = properties.getProperty(ANALYZER_COMMAND, command); 
     
    3739 
    3840        /** 
    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�� 
    4151         * @return �L�[���[�h�̃R���N�V����Collection<Keyword> 
     52         * @see Analyzer#parse(String) 
     53         * @see AutokeywordUtil#exec(String, String) 
    4254         */ 
    43         public Collection parse(String filename, PrintWriter out) 
     55        public Collection parse(String filename) 
    4456        { 
    45  
    4657                String  command = this.command + " " + filename; 
    47                 Collection      execResults = Util.exec(command, encodeType, out); 
     58                Collection      execResults = AutokeywordUtil.exec(command, encodeType); 
    4859                Collection      parseResults = parse(execResults); 
    49  
    5060                return parseResults; 
    5161        } 
    5262 
    5363        /** 
    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>) 
    5668         */ 
    5769        private Collection parse(Collection collection) 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/analyze/Sen.java

    r47 r54  
    44import java.io.File; 
    55import java.io.IOException; 
    6 import java.io.PrintWriter; 
    76import java.util.Collection; 
    87import java.util.Properties; 
    98 
     9import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 
    1010import jp.tyzoh.rinza.folksonomy.extractor.ContentsExtractorLookuper; 
     11import jp.tyzoh.rinza.folksonomy.extractor.Extractor; 
    1112import net.java.sen.StreamTagger; 
    1213import net.java.sen.StringTagger; 
     
    4445         * ������ 
    4546         * @param properties �ݒ��e 
    46          * @param out �f�o�b�O�o�� 
    4747         * @param �������� 
     48         * @see Analyzer#init(Properties) 
    4849         */ 
    49         public boolean init(Properties properties, PrintWriter out) { 
     50        public boolean init(Properties properties) { 
    5051                command = properties.getProperty(ANALYZER_COMMAND, command); 
    5152 
     
    6061 
    6162        /** 
    62          * �t�@�C����[�X���� 
     63         * �t�@�C����ԑf����� 
    6364         *  
     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> 
    6471         * @param filename 
    6572         *            �t�@�C���� 
     
    6774         *            ��s�G���[�̏o�� 
    6875         * @return �L�[���[�h�̃R���N�V����(Collection<Keyword>) 
     76         * @see Analyzer#parse(String) 
    6977         */ 
    70         public Collection parse(String filename, PrintWriter out) { 
     78        public Collection parse(String filename) { 
    7179                final KeywordFilter kf = new KeywordFilter(); 
    7280                BufferedReader br = null; 
     
    7987                        } 
    8088                } catch (IOException e) { 
    81                         e.printStackTrace(out); 
     89                        AutokeywordUtil.getLogger().warn("Sen�����͒��ɃG���[���������܂���", e); 
    8290                } finally { 
    8391                        if (br != null) { 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/common/AutokeywordUtil.java

    r43 r54  
    11package jp.tyzoh.rinza.folksonomy.common; 
    22 
    3 import java.io.*; 
     3import java.io.BufferedReader; 
     4import java.io.File; 
     5import java.io.IOException; 
     6import java.io.InputStream; 
     7import java.io.InputStreamReader; 
    48import java.lang.reflect.Constructor; 
    59import java.lang.reflect.InvocationTargetException; 
    6 import java.util.*; 
     10import java.util.Collection; 
     11import java.util.Vector; 
    712 
    813import javax.activation.MimetypesFileTypeMap; 
    914 
     15import org.apache.log4j.Logger; 
     16 
    1017/** 
    1118 * 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. 
    1423 */ 
    15 public class Util { 
     24public class AutokeywordUtil { 
    1625        /** MIME�̃t�@�C���^�C�v�}�b�v */ 
    1726        private static final MimetypesFileTypeMap mimeMap = new MimetypesFileTypeMap(); 
    1827 
    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); 
    2343        } 
    2444 
    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(); 
    2855 
    2956                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(" "); 
    3363                                } 
    34                                 out.println("<br>"); 
     64                                log.debug(buf.toString()); 
    3565                        } 
    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; 
    4368                        if (commandArray.length == 1) { 
    4469                                process = Runtime.getRuntime().exec(commandArray[0]); 
     
    4772                        } 
    4873                        InputStream is = process.getInputStream(); 
    49                         InputStreamReader       isr = null; 
    50                         BufferedReader          br = null; 
     74                        InputStreamReader isr = null; 
     75                        BufferedReader br = null; 
    5176                        try { 
    52                                 //int   count = 0; 
     77                                // int count = 0; 
    5378                                if (encodeType.equals("non")) { 
    5479                                        isr = new InputStreamReader(is); 
    5580                                } else { 
    56                                         isr = new InputStreamReader(is, encodeType);  
     81                                        isr = new InputStreamReader(is, encodeType); 
    5782                                } 
    5883                                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; 
    6288                                        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                                        } 
    6592                                } 
    66                         } catch(IOException ioe) { 
     93                        } catch (IOException ioe) { 
    6794                                ioe.printStackTrace(); 
    6895                                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) { 
    73103                                        ioe2.printStackTrace(); 
    74104                                } 
    75105                        } 
    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); 
    79108                } 
    80109 
     
    85114         * �C���X�^���X�쐬����. 
    86115         *  
    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 
    89121         *  
    90          * @throws ClassNotFoundException  
     122         * @throws ClassNotFoundException 
    91123         * @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 
    96128         * @throws InvocationTargetException 
    97129         */ 
    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 { 
    99135                final Class clazz = Class.forName(name); 
    100                 if(argumentClasses==null) { 
     136                if (argumentClasses == null) { 
    101137                        return clazz.newInstance(); 
    102138                } else { 
     
    106142        } 
    107143 
     144        // 
    108145        public static String findType(File file) { 
    109146                return mimeMap.getContentType(file); 
     
    113150                return mimeMap.getContentType(fileName); 
    114151        } 
     152 
     153        // 
     154        public static Logger getLogger() { 
     155                return log; 
     156        } 
    115157} 
    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 file 
    119  * LICENSE, and is available 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: 
    120162 * http://www.tyzoh.jp/rinza/licenses/LICENSE-1.0.txt. 
    121163 *  
    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. 
    128168 */ 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/ContentsExtractorLookuper.java

    r43 r54  
    77import java.util.HashMap; 
    88 
    9 import jp.tyzoh.rinza.folksonomy.common.Util; 
     9import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 
    1010 
    1111/** 
     
    3232         
    3333        /** 
    34          * �e�L�X�g���o�N���X�̕ێ��N���X�̏���     * 
     34         * �e�L�X�g���o�N���X�̕ێ��N���X�̏��� 
     35         * 
    3536         */ 
    3637        public ContentsExtractorLookuper() { 
     
    4041 
    4142        /** 
    42          * ���o�����N���X 
     43         * ���o�����N���X�̉� 
     44         *  
    4345         * @param mimeType MIME�^�C�v 
    4446         * @return ���o�����N���X 
     
    5052 
    5153        /** 
    52          * �t�@�C������ader������� 
     54         * �t�@�C�������L�X�g�ǂݍ��ݗpReader������� 
    5355         * @param file �����ΏۃN���X. 
    5456         * @return Reader 
    5557         * @throws IOException �t�@�C���ǂݍ��݂Ȃǂł�O�G���[ 
     58         * @see AutokeywordUtil#findType(File) MIME�^�C�v�̉� 
    5659         */ 
    5760        public BufferedReader getExtractorReader(File file) throws IOException { 
    58                 final String mimeType = Util.findType(file); 
     61                final String mimeType = AutokeywordUtil.findType(file); 
    5962                return new BufferedReader(getExtractor(mimeType).extract(new FileInputStream(file))); 
    6063        } 
    6164         
    6265        /** 
    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> 
    6471         */ 
    6572        private void initMap() { 
     
    6875                        Object obj = null; 
    6976                        try { 
    70                                 obj = Util.createInstance(name, // 
     77                                obj = AutokeywordUtil.createInstance(name, // 
    7178                                                new Class[] {,}, new Object[] {,}); 
    7279                        } catch (Throwable e) { 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/DefaultExtractor.java

    r43 r54  
    1414 */ 
    1515public class DefaultExtractor implements Extractor { 
     16        /** �t�@�C���̃G���R�[�h */ 
    1617        private final String encode; 
    17  
     18        /** ���̓W�J�����̃R���e���c�^�C�v�萔 */ 
    1819        private static String CONTENT_TYPE = "text/plain"; 
    19          
     20        /** �t�@�C���G���R�[�h�̃f�B�t�H���g�w��/ 
    2021        private static String DEFAULT_ENCODING = "jisautodetect"; 
    2122         
     23        /** 
     24         * �t�@�C���̓W�J�����̏��� 
     25         * 
     26         * �G���R�[�h��{@value #DEFAULT_ENCODING}�ŏ����� 
     27         * @see DefaultExtractor#DefaultExtractor(String) 
     28         */ 
    2229        public DefaultExtractor() { 
    2330                this(null); 
    2431        } 
     32         
     33        /** 
     34         * �t�@�C���̓W�J�����̏��� 
     35         *  
     36         * @param encode �e�L�X�g�̃G���R�[�h 
     37         */ 
    2538        public DefaultExtractor(String encode) { 
    2639                this.encode = encode; 
    2740        } 
     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         */ 
    2849        public Reader extract(InputStream content) throws IOException { 
    2950                return new InputStreamReader(content, encode==null?DEFAULT_ENCODING:encode); 
    3051        } 
    3152         
     53        /** 
     54         * ���̃e�L�X�g���o�N���X�̃R���e���c�^�C�v. 
     55         *  
     56         * @return �R���e���c�^�C�v 
     57         */ 
    3258        public String getContentType() { 
    3359                return CONTENT_TYPE; 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/Extractor.java

    r43 r54  
    1212public interface Extractor { 
    1313        /** 
    14          * �f�[�^�t�@�C���̃X�g���[����[�_�[�֕ϊ��������� 
     14         * �f�[�^�t�@�C���̃X�g���[����L�X�g���o�������[�_�[�֕ϊ��������� 
    1515         * @param content �R���e���c�X�g���[�� 
    1616         * @return �e�L�X�g�����̂ݒ��o����Reader 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/pdfbox/PDFExtractor.java

    r43 r54  
    2929 */ 
    3030public class PDFExtractor implements Extractor { 
    31  
     31        /** PDF�̃R���e���c�^�C�v���� */ 
    3232    private static final String CONTENT_TYPE_PDF_1 = "application/pdf"; 
     33    /** PDF�̃R���e���c�^�C�v���� */ 
    3334    private static final String CONTENT_TYPE_PDF_2 = "application/x-pdf"; 
     35    /** CSV�ŕ����L�q����PDF�t�@�C������R���e���c�^�C�v */ 
    3436    private static final String CONTENT_TYPE_PDF_ALL_CSV = CONTENT_TYPE_PDF_1+","+CONTENT_TYPE_PDF_2; 
    3537 
    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     */ 
    3752        public Reader extract(InputStream content) throws IOException { 
    3853                try { 
    3954                        PDFParser parser = new PDFParser(content); 
    4055                        parser.parse(); 
    41  
    42                          
     56         
    4357                        PDDocument document = parser.getPDDocument(); 
    4458                        CharArrayWriter writer = new CharArrayWriter(); 
     
    5771        } 
    5872 
    59  
     73        /** 
     74         * PDF�t�@�C���̃R���e���c�^�C�v����������        * @return PDF�t�@�C���̃R���e���c�^�C�v 
     75         */ 
    6076        public String getContentType() { 
    6177                return CONTENT_TYPE_PDF_ALL_CSV; 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSExcelExtractor.java

    r43 r54  
    3131 */ 
    3232public class MSExcelExtractor implements Extractor { 
    33  
     33        /** Excel�̃R���e���c�^�C�v���� */ 
    3434        static final String CONTENT_TYPE_EXCEL_1 = "application/msexcel"; 
     35        /** Excel�̃R���e���c�^�C�v���� */ 
    3536        static final String CONTENT_TYPE_EXCEL_2 = "application/vnd.ms-excel"; 
     37        /** CSV�ŕ����L�q����Excel�t�@�C������R���e���c�^�C�v */ 
    3638        static final String CONTENT_TYPE_EXCEL_ALL_CSV = CONTENT_TYPE_EXCEL_1+","+CONTENT_TYPE_EXCEL_2; 
    3739 
     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     */ 
    3851        public Reader extract(InputStream content) throws IOException { 
    3952                try { 
     
    7689        } 
    7790 
     91        /** 
     92         * Excel�t�@�C���̃R���e���c�^�C�v����������      * @return Excel�t�@�C���̃R���e���c�^�C�v 
     93         */ 
    7894        public String getContentType() { 
    7995                return CONTENT_TYPE_EXCEL_ALL_CSV; 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSPowerPointExtractor.java

    r43 r54  
    2727 */ 
    2828public class MSPowerPointExtractor implements Extractor { 
     29        /** PowerPoint�̃R���e���c�^�C�v���� */ 
    2930        static final String CONTENT_TYPE_POWERPOINT_1 = "application/mspowerpoint"; 
    30  
     31        /** PowerPoint�̃R���e���c�^�C�v���� */ 
    3132        static final String CONTENT_TYPE_POWERPOINT_2 = "application/vnd.ms-powerpoint"; 
    32  
     33        /** CSV�ŕ����L�q����PowerPoint�t�@�C������R���e���c�^�C�v */ 
    3334        static final String CONTENT_TYPE_POWERPOINT_ALL_CSV = CONTENT_TYPE_POWERPOINT_1 
    3435                        + "," + CONTENT_TYPE_POWERPOINT_2; 
    3536 
     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     */ 
    3648        public Reader extract(InputStream content) throws IOException { 
    3749                final CharArrayWriter writer = new CharArrayWriter(); 
     
    6981        } 
    7082         
     83        /** 
     84         * PowerPoint�t�@�C���̃R���e���c�^�C�v����������         * @return PowerPoint�t�@�C���̃R���e���c�^�C�v 
     85         */ 
    7186        public String getContentType() { 
    7287                return CONTENT_TYPE_POWERPOINT_ALL_CSV; 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/extractor/poi/MSWordExtractor.java

    r43 r54  
    2222 */ 
    2323public class MSWordExtractor implements Extractor { 
     24        /** MS-Word�̃R���e���c�^�C�v���� */ 
    2425    static final String CONTENT_TYPE_WORD_1 = "application/msword"; 
     26    /** MS-Word�̃R���e���c�^�C�v���� */ 
    2527    static final String CONTENT_TYPE_WORD_2 = "application/vnd.ms-word"; 
     28        /** CSV�ŕ����L�q����MS-Word�t�@�C������R���e���c�^�C�v */ 
    2629    static final String CONTENT_TYPE_WORD_ALL_CSV = CONTENT_TYPE_WORD_1+","+CONTENT_TYPE_WORD_2; 
    2730 
     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     */ 
    2842        public Reader extract(InputStream content) throws IOException { 
    2943                try { 
     
    3650        } 
    3751 
     52        /** 
     53         * MS-Word�t�@�C���̃R���e���c�^�C�v����������    * @return MS-Word�t�@�C���̃R���e���c�^�C�v 
     54         */ 
    3855        public String getContentType() { 
    3956                return CONTENT_TYPE_WORD_ALL_CSV; 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Auto.java

    r15 r54  
    44import java.io.*; 
    55 
     6import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 
     7 
     8import org.apache.log4j.BasicConfigurator; 
     9import org.apache.log4j.ConsoleAppender; 
     10import org.apache.log4j.Level; 
     11import org.apache.log4j.Logger; 
     12 
    613/** 
    7  * �L�[���[�h�������o 
     14 * �Ώۃt�@�C���̃L�[���[�h���o�ƑΉ������������F-IDF�l������� 
    815 * 
    916 * <BR><BR>Copyright (C) 2006 Nihon Unisys, Ltd. All Rights Reserved. 
    1017 */ 
    1118public 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); 
    1423 
     24        /** 
     25         * �R�}���h��s 
     26         * @param args ��s�����‚߂̈��t�@�C������肷�� 
     27         */ 
    1528        public static void main(String args[]) 
    1629        { 
     
    2437                } 
    2538 
     39                BasicConfigurator.resetConfiguration(); 
     40                final Logger log = AutokeywordUtil.getLogger(); 
     41                log.addAppender(new ConsoleAppender()); 
     42                log.setLevel(Level.DEBUG); 
     43                 
    2644                Auto    auto = new Auto(); 
    2745                auto.fire(file.getAbsolutePath()); 
    2846        } 
    2947 
     48        /** 
     49         * ���̃R�}���h�̎g�p���\���ƃR�}���h��s�̏I��. 
     50         * 
     51         */ 
    3052        private static void usageAndExit() 
    3153        { 
     
    3456        } 
    3557 
     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         */ 
    3666        public void init() 
    3767        { 
     
    3969                try { 
    4070                        properties.load(Auto.class.getClassLoader().getResourceAsStream("autokeyword.properties")); 
    41                         engine.init(properties, out); 
     71                        engine.init(properties); 
    4272                } catch (IOException ex) { 
    4373                        ex.printStackTrace(out); 
     
    4575        } 
    4676         
    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         */ 
    4882        public Collection getKeywords(String filename) 
    4983        { 
     
    5286        } 
    5387 
     88        /** 
     89         * ������s�Ǝ�s���ʕ\�� 
     90         * @param filename �L�[���[�h���o�Ώۃt�@�C�� 
     91         */ 
    5492        public void fire(String filename) 
    5593        { 
    5694                init(); 
    57                 Collection      collection = engine.getKeywords(filename, new PrintWriter(System.out)); 
     95                Collection      collection = engine.getKeywords(filename); 
    5896 
    5997                out.println("TFIDF �J�n"); 
     
    6199                while(iterator.hasNext()) { 
    62100                        Result  result = (Result)iterator.next(); 
    63                         out.println(result.info()); 
     101                        out.println(result.toString()); 
    64102                } 
    65103                out.println("TFIDF �I��"); 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Engine.java

    r47 r54  
    44import java.io.*; 
    55 
     6import org.apache.log4j.Logger; 
     7 
    68import jp.tyzoh.rinza.folksonomy.analyze.*; 
     9import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 
    710import jp.tyzoh.rinza.folksonomy.search.*; 
    811 
     
    3336         * @return �������� 
    3437         */ 
    35         public boolean init(Properties properties, PrintWriter out) 
     38        public boolean init(Properties properties) 
    3639        { 
    3740                String  analyzerName =  properties.getProperty(ANALYZER_CLASS_NAME, ANALYZER_CLASS_NAME_DEFAULT); 
    3841                try { 
    3942                        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���܂���"); 
    4245                                return false; 
    4346                        } 
    4447                } catch(Exception ex) { 
    45                         if (out != null) out.println(analyzerName + " is not supported."); 
     48                        AutokeywordUtil.getLogger().fatal("�����̓N���X"+analyzerName+"�̏������s���܂���", ex); 
    4649                        return false; 
    4750                } 
     
    5053                try { 
    5154                        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���܂���"); 
    5657                                return false; 
    5758                        } 
    5859                } 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); 
    6261                        return false; 
    6362                } 
     
    6867        /** 
    6968         * �L�[���[�h�R���N�V�����̈ꗗ�\�� 
    70          * @param out �f�o�b�O�o�� 
    7169         * @param keywords �L�[���[�h�R���N�V���� (Collection<Keyword>) 
    7270         */ 
    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"); 
    7776                        for(Iterator iterator = keywords.iterator(); iterator.hasNext(); ) { 
    7877                                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         
    9684        /** 
    9785         * �L�[���[�h���o��� 
     
    10492         *  
    10593         * @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) 
    11097        { 
    11198                ArrayList results = new ArrayList(); 
     
    115102                File[]  fileArray = file.listFiles(); 
    116103                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); 
    120110                for(Iterator iterator = localKeywords.iterator(); iterator.hasNext();) {         
    121111                        final Keyword keyword = (Keyword)iterator.next(); 
     
    134124 
    135125        /** 
    136          * TI-IDF�l�̌v�Z 
     126         * TF-IDF�l�̌v�Z 
    137127         * @param keyword �L�[���[�h�� 
    138128         * @param fileCount �W�{���c�̐� 
    139          * @return  
     129         * @return TF-IDF�l 
    140130         */ 
    141131        private double calclateTfidf(Keyword keyword, int fileCount) { 
     
    152142                return keyword.getCount()*Math.log((double)fileCount/df); 
    153143        } 
     144         
    154145        /** 
    155146         * �L�[���[�h�̒��o 
     
    159150         * </p> 
    160151         * @param filename �Ώۃt�@�C�� 
    161          * @param out �f�o�b�O�o�� 
    162152         * @return Collection<Keyword> 
    163153         */ 
    164         public Collection getLocalKeywords(String filename, PrintWriter out) 
     154        public Collection getLocalKeywords(String filename) 
    165155        {                
    166156                //Analyzer�ɃL�[���[�h�̐��K��������߂� 
    167                 return analyzer.parse(filename, null); 
     157                return analyzer.parse(filename); 
    168158        } 
    169159 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Hidden.java

    r43 r54  
    11package jp.tyzoh.rinza.folksonomy.keyword; 
    22 
    3 import java.util.*; 
    4 import java.io.*; 
     3import java.io.File; 
     4import java.io.IOException; 
     5import java.io.PrintWriter; 
     6import java.util.Collection; 
     7import java.util.Iterator; 
     8import java.util.Properties; 
     9 
     10import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 
     11 
     12import org.apache.log4j.BasicConfigurator; 
     13import org.apache.log4j.ConsoleAppender; 
     14import org.apache.log4j.Level; 
     15import org.apache.log4j.Logger; 
    516 
    617/** 
    7  * ������ 
     18 *  
    819 * 
    920 * <BR><BR>Copyright (C) 2007 Nihon Unisys, Ltd. All Rights Reserved. 
     
    2334                } 
    2435 
     36                BasicConfigurator.resetConfiguration(); 
     37                final Logger log = AutokeywordUtil.getLogger(); 
     38                log.addAppender(new ConsoleAppender()); 
     39                log.setLevel(Level.DEBUG); 
     40                 
    2541                Hidden  hidden = new Hidden(); 
    2642                hidden.fire(file.getAbsolutePath()); 
     
    3854                try { 
    3955                        properties.load(Auto.class.getClassLoader().getResourceAsStream("autokeyword.properties")); 
    40                         init(properties, out); 
     56                        init(properties); 
    4157                } catch (IOException ex) { 
    42                         ex.printStackTrace(out); 
     58                        ex.printStackTrace(); 
    4359                } 
    4460        } 
     
    4763        { 
    4864                init(); 
    49                 Collection      collection = getKeywords(filename, new PrintWriter(System.out)); 
     65                Collection      collection = getKeywords(filename); 
    5066 
    5167                out.println("TFIDF �J�n"); 
     
    5369                while(iterator.hasNext()) { 
    5470                        Result  result = (Result)iterator.next(); 
    55                         out.println(result.info()); 
     71                        out.println(result.toString()); 
    5672                } 
    5773                out.println("TFIDF �I��"); 
     
    6581        } 
    6682         
    67         public Collection getLocalKeywords(String filename, PrintWriter out) 
     83        public Collection getLocalKeywords(String filename) 
    6884        { 
    69                 return super.getLocalKeywords(filename, out); 
     85                return super.getLocalKeywords(filename); 
    7086        } 
    7187} 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/keyword/Result.java

    r47 r54  
    1717        private final double    tfidf; 
    1818 
    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) 
    2029        { 
    2130                this.keyword = keyword; 
    22                 this.tfidf = tidf; 
     31                this.tfidf = tfidf; 
    2332        } 
    2433         
     34        /** 
     35         * TF-IDF�l�̎擾. 
     36         *  
     37         * @return TF-IDF�l 
     38         */ 
    2539        public double getTFIDF() 
    2640        { 
     
    2842        } 
    2943 
     44        /** 
     45         * �L�[���[�h������擾 
     46         * @return �L�[���[�h������ * @see Keyword#getWord() �����͂ł̃L�[���[�h�� 
     47         */ 
    3048        public String getWord() 
    3149        { 
     
    3452 
    3553        /** 
     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        /** 
    3665         * �\�[�g�̂��߂̎��R�������\�b�h 
    3766         *  
    3867         * <p> 
    39          *      tfidf�l�̑傫�����Ƀ\�[�g����        * </p> 
     68         *      ���̃C���X�^���X�̎��R�����͈ȉ��̂Ƃ���       *      <ol> 
     69         *              <li>tfidf(�~��) 
     70         *              <li>word(������) 
     71         *      </ol> 
     72         * </p> 
    4073         *  
    41          * TODO �\�[�g���ʂɓ���-IDF�l���̃L�[���[�h�ł̃\�[�g�������� 
    4274         *  
    4375         * @param obj ���Ώ� 
     
    5385                        return -1; 
    5486                } else if (result.getTFIDF() == getTFIDF()) { 
    55                         return 0;                
     87                        return getWord().compareTo(result.getWord()); 
     88                        //return 0;              
    5689                } else { 
    5790                        return 1; 
    5891                } 
    59         } 
    60  
    61         public String info() 
    62         { 
    63                 return getTFIDF() + "\t" + keyword.info(); 
    6492        } 
    6593}        
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/search/LuceneJa.java

    r47 r54  
    33import java.io.File; 
    44import java.io.IOException; 
    5 import java.io.PrintWriter; 
    65import java.io.Reader; 
    76import java.util.ArrayList; 
     
    1312import java.util.Properties; 
    1413 
     14import jp.tyzoh.rinza.folksonomy.common.AutokeywordUtil; 
    1515import jp.tyzoh.rinza.folksonomy.extractor.ContentsExtractorLookuper; 
    1616 
     
    3838 */ 
    3939public 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 
    4047        // 
    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�� */ 
    4849        private String indexDirectory = DEFAULT_LUCENE_INDEX_DIRECTORY; 
    49  
     50        /** Lucene�̐ݒ��@�C����(Sen�ݒ�*/ 
    5051        private String command = DEFAULT_COMMAND; 
    51  
     52        /** Lucene�̉�Ώۃt�@�C���f�B���N�g�� */ 
    5253        private String fileDirectory = DEFAULT_FILESTORE_DIRECTORY; 
    53  
     54        /** �����͗p�̃C���^�[�t�F�[�X */ 
    5455        private Analyzer analyzer = null; 
    55  
     56        /** Lucene�̌���}�l�[�W���N���X */ 
    5657        private IndexSearcherManager searcherManager = null; 
    57  
     58        /** �e�L�X�g���o�����p�̎���擾�p�N���X */ 
    5859        private ContentsExtractorLookuper lookuper = null; 
    59  
     60        /** �t�@�C���i�[�f�B���N�g���̋K�� */ 
    6061        private static final String DEFAULT_FILESTORE_DIRECTORY = "/var/lib/tPod/files"; 
    61  
     62        /** Lucene�̐ݒ��@�C�����̋K��(Sen�ݒ�*/ 
    6263        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*/ 
    6465        private static final String DEFAULT_LUCENE_INDEX_DIRECTORY = "/var/lib/tPod/index"; 
    6566 
     
    6768         * ������ 
    6869         *  
    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) { 
    7373                fileDirectory = properties.getProperty(CONTENTS_DIRECTORY, // 
    7474                                properties.getProperty(CONTENTS_DIRECTORY2, fileDirectory)); 
     
    7979                searcherManager = new IndexSearcherManager(indexDirectory); 
    8080                lookuper = new ContentsExtractorLookuper(); 
     81                 
     82                AutokeywordUtil.getLogger().info("Lucene(ja)���������܂���"); 
    8183                return true; 
    8284        } 
    8385 
     86        /** 
     87         * Lucene�̏I�������� 
     88         */ 
    8489        public void destroy() { 
    85  
    86         } 
    87  
     90        } 
     91 
     92        /** 
     93         * Lucene�̉�Ώۃt�@�C���̔z�u�ʒu. 
     94         * @return �Ώۃf�B���N�g�� 
     95         */ 
    8896        public File getTargetDirectory() { 
    8997                return new File(fileDirectory); 
     
    94102         *  
    95103         * @param keywordList �L�[���[�h���X�g(List<String>) 
    96          * @param out �f�o�b�O�o�� 
    97104         * @return ����ʂ̃t�@�C�����̃R���N�V���� Collection<String> 
    98105         */ 
    99         public Collection /* <String> */search(List keywordList, PrintWriter out, int offset, int limit) { 
     106        public Collection /* <String> */search(List keywordList, int offset, int limit) { 
    100107                final ArrayList al = new ArrayList(); 
    101108                IndexSearcherPool isp = null; 
     
    121128                                        } 
    122129                                } catch (ParseException e) { 
    123                                         if (out != null) { 
    124                                                 e.printStackTrace(out); 
    125                                         } 
     130                                        AutokeywordUtil.getLogger().warn("Lucene����ɉ�G���[���������܂���", e); 
    126131                                } catch (IOException e) { 
    127                                         if (out != null) { 
    128                                                 e.printStackTrace(out); 
    129                                         } 
     132                                        AutokeywordUtil.getLogger().warn("Lucene�����O�G���[���������܂���", e); 
    130133                                } 
    131134                        } 
     
    139142         * �S������� 
    140143         *  
    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); 
    145149        } 
    146150 
    147151        /** 
    148152         * �S������s����ꍇ�̊Y������������� 
     153         * @param keywordList �S������̌�������X�g 
     154         * @return �Ή������t�@�C���̑��� 
    149155         */ 
    150156        public int searchCount(List keywordList) { 
     
    177183         * �L�[���[�h������󔒋����‚Ȃ� 
    178184         *  
    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) { 
    183187                final StringBuffer buf = new StringBuffer(); 
    184188                for (int i = 0; i < keywordList.size(); i++) { 
     
    194198         * �S���C���f�b�N�X����. 
    195199         *  
    196          * @param out 
    197          *            �f�o�b�O�o�͗p 
    198          */ 
    199         public Collection indexing(PrintWriter out) { 
     200         */ 
     201        public void indexing() { 
    200202                synchronized (this) { 
    201203                        final boolean isCreate = (!IndexReader.indexExists(indexDirectory)); 
     
    230232                                        reader.close(); 
    231233                                } catch (IOException e) { 
    232                                         e.printStackTrace(); 
     234                                        AutokeywordUtil.getLogger().warn("Lucene�C���f�b�N�X�Đ������ɃG���[���������܂���", e); 
    233235                                } 
    234236                        } 
     
    253255                        searcherManager.updateSearcher(); 
    254256                } 
    255                 return null; 
    256257        } 
    257258         
    258259        /** 
    259          * �t�@�C�������L�X�g�����𒊏o���� 
     260         * �t�@�C�������L�X�g�����𒊏o�����S������t�@�C����������� 
    260261         * @param parent �e�f�B���N�g�� 
    261262         * @param name �t�@�C���� 
    262          * @return 
     263         * @return �e�L�X�g���o�����f�[�^��b�g��������ۃf�[�^ 
    263264         */ 
    264265        private Document createDocument(File parent, String name) { 
     
    282283        } 
    283284 
     285        /** 
     286         * �ŏI�X�V���Ԃ̕�����쐬���� 
     287         * @param file �Ώۃt�@�C�� 
     288         * @return Lucene�̓��`���p�̎����������� * @see DateField#timeToString(long) 
     289         */ 
    284290        private static String findLastModified(File file) { 
    285291                return DateField.timeToString(file.lastModified()); 
     
    305311                private IndexSearcherPool searcherPool = null; 
    306312 
     313                /** 
     314                 * �C���f�b�N�X�ł̌�����}�l�[�W������. 
     315                 *  
     316                 * @param indexDirectory ����ۂ̃C���f�b�N�X�f�B���N�g�� 
     317                 */ 
    307318                public IndexSearcherManager(String indexDirectory) { 
    308319                        this.indexDirectory = indexDirectory; 
     
    310321                } 
    311322 
    312                 // 
     323                /** 
     324                 * ������̎؎�             * @return ������N���X. 
     325                 */ 
    313326                private IndexSearcherPool rentSearcher() { 
    314327                        synchronized (this) { 
     
    319332                } 
    320333 
     334                /** 
     335                 * ������̕ԋp 
     336                 * @param isp �ԋp����@link IndexSearcherPool} 
     337                 */ 
    321338                private void returnSearcher(IndexSearcherPool isp) { 
    322339                        IndexSearcher is = null; 
     
    330347                } 
    331348 
     349                /** 
     350                 * �t�@�C���lj�Ȃǂł̌���������̍X�V����. 
     351                 * 
     352                 */ 
    332353                private void updateSearcher() { 
    333354                        IndexSearcher is = null; 
     
    344365                } 
    345366 
     367                /** 
     368                 * ������̏��� 
     369                 * @param indexDirectory ������f�b�N�X�f�B���N�g�� 
     370                 * @return �������. 
     371                 */ 
    346372                private static IndexSearcherPool openSearcher(String indexDirectory) { 
    347373                        IndexSearcher is = null; 
     
    353379                } 
    354380 
     381                /** 
     382                 * ������̏I�� 
     383                 * @param is ����� 
     384                 */ 
    355385                private static void closeSearcher(IndexSearcher is) { 
    356386                        if (is != null) { 
     
    363393        } 
    364394 
    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         */ 
    366403        private static class IndexSearcherPool { 
    367404                private final IndexSearcher searcher; 
    368  
     405                /** ���̌�����͍X�V�҂����H */ 
    369406                private boolean isUpdated; 
    370  
     407                /** ��s���X���b�h�̏� ��s���̃X���b�h���o�^���� */ 
    371408                private final HashSet /* <Thread> */runningSet = new HashSet(); 
    372  
     409                /** 
     410                 * Lucene�̌������肵�ď����� 
     411                 * @param searcher Lucene�C���f�b�N�X�T�[�` 
     412                 */ 
    373413                public IndexSearcherPool(IndexSearcher searcher) { 
    374414                        this.searcher = searcher; 
    375415                } 
    376416 
    377                 // 
     417                /** 
     418                 * �i�[���Ă��錟����̎擾 
     419                 * @return �i�[���Ă��錟��� 
     420                 */ 
    378421                public IndexSearcher getSearcher() { 
    379422                        return searcher; 
    380423                } 
    381424 
    382                 // 
     425                /** 
     426                 * ���̌�����͍X�V������ꂽ���H 
     427                 * @param isUpdated 
     428                 */ 
    383429                public void setUpdated(boolean isUpdated) { 
    384430                        this.isUpdated = isUpdated; 
    385431                } 
    386432 
     433                /** 
     434                 * ���̌�����̗��p��n���� 
     435                 * 
     436                 */ 
    387437                public void lock() { 
    388438                        runningSet.add(Thread.currentThread()); 
    389439                } 
    390440 
     441                /** 
     442                 * ���̌�����̗��p��߂� 
     443                 * 
     444                 */ 
    391445                public void unlock() { 
    392446                        runningSet.remove(Thread.currentThread()); 
    393447                } 
    394448 
     449                /** 
     450                 * ���̃v�[���͕‚����v������āA���‚����邩�H 
     451                 * @return �‚����v�������g�p�������̂ŕ‚�������trye 
     452                 */ 
    395453                public boolean needClose() { 
    396454                        return isUpdated && runningSet.isEmpty(); 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/search/Namazu.java

    r47 r54  
    3434                return new File(fileDirectory); 
    3535        } 
    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) 
    3843        { 
    3944                encodeType = properties.getProperty(ENCODE_TYPE, // 
     
    4550                index = properties.getProperty(INDEX_COMMAND, "c:\\namazu\\bin\\mknmz.bat \"" + fileDirectory + "\" -O"); 
    4651                indexDirectory = properties.getProperty(INDEX_DIRECTORY, indexDirectory); 
    47  
     52                AutokeywordUtil.getLogger().info("Namazu ���������܂���"); 
    4853                return true; 
    4954        } 
    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); 
    5361        } 
    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) 
    5570        { 
    5671                StringBuffer execBuf = new StringBuffer(); 
     
    6984                execBuf.append(" ").append(indexDirectory); 
    7085 
    71                 return Util.exec(execBuf.toString(), encodeType, out); 
     86                return AutokeywordUtil.exec(execBuf.toString(), encodeType); 
    7287        } 
    7388 
     89        /** 
     90         * ������őΉ����錟��ʐ��̎擾. 
     91         * @param ��������� * @return ����ʏW 
     92         */ 
    7493        public int searchCount(List keywordList) { 
    7594                StringBuffer execBuf = new StringBuffer(); 
     
    83102                execBuf.append(" ").append(indexDirectory); 
    84103 
    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); 
    87106                if(c.size()==1) { 
    88107                        final String s = (String) c.iterator().next(); 
     
    95114        } 
    96115 
    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() 
    98121        { 
    99122                String  command = index + " " + indexDirectory; 
    100123 
    101                 return Util.exec(command, encodeType, out); 
     124                AutokeywordUtil.exec(command, encodeType); 
    102125        } 
    103126                 
  • AutoKeyword/trunk/src/jp/tyzoh/rinza/folksonomy/search/Searcher.java

    r47 r54  
    2929        /** 
    3030         * ����  * @param properties �ݒ�         * @param out �f�o�b�O�o�� 
    31          * @return 
     31         * @return �������̐��� 
    3232         */ 
    33         public boolean init(Properties properties, PrintWriter out); 
     33        public boolean init(Properties properties); 
     34 
    3435        /** 
    35          * �Ώۃf�B���N�g�� 
    36          * @return 
     36         * �Ώۃt�@�C���̂����B���N�g���̎擾 
     37         * @return �f�B���N�g�� 
    3738         */ 
    3839        public File getTargetDirectory(); 
     
    4142         * ����� 
    4243         * @param keywordList �L�[���[�h���X�g 
    43          * @param out �f�o�b�O�o�� 
    4444         * @return Collection<String> 
    4545         */ 
    46         public Collection search(List keywordList, PrintWriter out); 
     46        public Collection search(List keywordList); 
    4747 
    4848        /** 
    4949         * �����(���������) 
    5050         * @param keywordList �L�[���[�h���X�g 
    51          * @param out �f�o�b�O�o�� 
    5251         * @param offset ����ʊJ�n�ʒu 
    5352         * @param limit ����ʍő吔 
    5453         * @return Collection<String> 
    5554         */ 
    56         public Collection search(List keywordList, PrintWriter out, int offset, int limit); 
     55        public Collection search(List keywordList, int offset, int limit); 
    5756 
    5857        /** 
     
    7069         * @param out �f�o�b�O�o�� 
    7170         */ 
    72         public Collection indexing(PrintWriter out); 
     71        public void indexing(); 
    7372         
    7473        /**