KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > fulltext > common > StopWords


1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.common;
2
3 import java.io.*;
4
5 /**
6  * This Class represents list of stopwords that are ignored during parsing
7  * like a,an,the etc.It provides functionality to check whether token is among of
8  * stop word or not.
9   */

10
11 public class StopWords {
12   /**
13    * English_stop_word is byte array which contain all list of stop words
14    * that we have to ignored during parsing.
15    */

16   public static final byte[][] ENGLISH_STOP_WORDS = {
17       {(byte) 39},//"'"
18
{(byte) 97},//"a"
19
{(byte) 97, (byte) 110}, // "an"
20
{(byte) 97, (byte) 110, (byte) 100},//"and"
21
{ (byte) 97, (byte) 114, (byte) 101},// "are"
22
{(byte) 97, (byte) 115},//"as"
23
{(byte) 97, (byte) 116},//"at"
24
{(byte) 98, (byte) 101},// "be"
25
{(byte) 98, (byte) 117, (byte) 116},//"but",
26
{(byte) 98, (byte) 121},//"by"
27
{(byte) 102,(byte) 111,(byte) 114},//"for"
28
{(byte) 105,(byte) 102},//"if"
29
{(byte) 105,(byte) 110},// "in"
30
{(byte) 105,(byte) 110,(byte) 116,(byte) 111},//"into"
31
{(byte) 105,(byte) 115},// "is"
32
{(byte) 105,(byte) 116},// "it"
33
{(byte) 110,(byte) 111},//"no"
34
{(byte) 110,(byte) 111,(byte) 116},//"not"
35
{(byte) 111,(byte) 102},// "of"
36
{(byte) 111,(byte) 110},//"on"
37
{(byte) 111,(byte) 114},// "or"
38
{(byte) 115},//"s"
39
{(byte) 115,(byte)117,(byte)99,(byte)104},// "such"
40
{(byte) 116},//"t"
41
{(byte)116,(byte)104,(byte)97,(byte)116},//"that"
42
{(byte)116,(byte)104,(byte)101},//"the"
43
{(byte)116,(byte)104,(byte)101,(byte)105,(byte)114},//"their"
44
{(byte)116,(byte)104,(byte)101,(byte)110},//"then"
45
{(byte)116,(byte)104,(byte)101,(byte)114,(byte)101},//"there"
46
{(byte)116,(byte)104,(byte)101,(byte)115,(byte)101},//"these"
47
{(byte)116,(byte)104,(byte)101,(byte)121},//"they"
48
{(byte)116,(byte)104,(byte)105,(byte)115},//"this"
49
{(byte)116,(byte)111},// "to"
50
{(byte)119,(byte)97,(byte)115},//"was"
51
{(byte)119,(byte)105,(byte)108,(byte)108},//"will"
52
{(byte)119,(byte)105,(byte)116,(byte)104},//"with"
53
{(byte)10} //\n
54
};
55
56   public StopWords() {
57
58   }
59   /**
60    * It checks whether token passed is stopword or not.if it is stopword return true
61    * else return false.
62    * @param token
63    * @return
64    */

65   public static boolean checkStopWords(byte[] token) {
66     Outer:for (int i = 0; i < ENGLISH_STOP_WORDS.length; i++) {
67       byte[] stopWord = ENGLISH_STOP_WORDS[i];
68       if (token.length == stopWord.length) {
69         for (int j = 0; j < token.length; j++) {
70           if (token[j] != stopWord[j])
71             continue Outer;
72         }
73         return true;
74       }
75     }
76     return false;
77   }
78 }
79
Popular Tags