~ubuntu-branches/ubuntu/precise/weka/precise

« back to all changes in this revision

Viewing changes to weka/core/Stopwords.java

  • Committer: Bazaar Package Importer
  • Author(s): Soeren Sonnenburg
  • Date: 2008-02-24 09:18:45 UTC
  • Revision ID: james.westby@ubuntu.com-20080224091845-1l8zy6fm6xipbzsr
Tags: upstream-3.5.7+tut1
ImportĀ upstreamĀ versionĀ 3.5.7+tut1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *    This program is free software; you can redistribute it and/or modify
 
3
 *    it under the terms of the GNU General Public License as published by
 
4
 *    the Free Software Foundation; either version 2 of the License, or
 
5
 *    (at your option) any later version.
 
6
 *
 
7
 *    This program is distributed in the hope that it will be useful,
 
8
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
 *    GNU General Public License for more details.
 
11
 *
 
12
 *    You should have received a copy of the GNU General Public License
 
13
 *    along with this program; if not, write to the Free Software
 
14
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
15
 */
 
16
 
 
17
/*
 
18
 *    Stopwords.java
 
19
 *    Copyright (C) 2001 University of Waikato, Hamilton, New Zealand
 
20
 */
 
21
 
 
22
package weka.core;
 
23
 
 
24
import java.io.BufferedReader;
 
25
import java.io.BufferedWriter;
 
26
import java.io.File;
 
27
import java.io.FileReader;
 
28
import java.io.FileWriter;
 
29
import java.util.Collections;
 
30
import java.util.Date;
 
31
import java.util.Enumeration;
 
32
import java.util.HashSet;
 
33
import java.util.Iterator;
 
34
import java.util.Vector;
 
35
 
 
36
/**
 
37
 * Class that can test whether a given string is a stop word.
 
38
 * Lowercases all words before the test. <p/>
 
39
 * The format for reading and writing is one word per line, lines starting
 
40
 * with '#' are interpreted as comments and therefore skipped. <p/>
 
41
 * The default stopwords are based on <a href="http://www.cs.cmu.edu/~mccallum/bow/rainbow/" target="_blank">Rainbow</a>. <p/>
 
42
 *
 
43
 * Accepts the following parameter: <p/>
 
44
 *
 
45
 * -i file <br/>
 
46
 * loads the stopwords from the given file <p/>
 
47
 *
 
48
 * -o file <br/>
 
49
 * saves the stopwords to the given file <p/>
 
50
 *
 
51
 * -p <br/>
 
52
 * outputs the current stopwords on stdout <p/>
 
53
 *
 
54
 * Any additional parameters are interpreted as words to test as stopwords.
 
55
 * 
 
56
 * @author Eibe Frank (eibe@cs.waikato.ac.nz)
 
57
 * @author Ashraf M. Kibriya (amk14@cs.waikato.ac.nz)
 
58
 * @author FracPete (fracpete at waikato dot ac dot nz)
 
59
 * @version $Revision: 1.5 $
 
60
 */
 
61
public class Stopwords {
 
62
  
 
63
  /** The hash set containing the list of stopwords */
 
64
  protected HashSet m_Words = null;
 
65
 
 
66
  /** The default stopwords object (stoplist based on Rainbow) */
 
67
  protected static Stopwords m_Stopwords;
 
68
 
 
69
  static {
 
70
    if (m_Stopwords == null) {
 
71
      m_Stopwords = new Stopwords();
 
72
    }
 
73
  }
 
74
 
 
75
  /**
 
76
   * initializes the stopwords (based on <a href="http://www.cs.cmu.edu/~mccallum/bow/rainbow/" target="_blank">Rainbow</a>).
 
77
   */
 
78
  public Stopwords() {
 
79
    m_Words = new HashSet();
 
80
 
 
81
    //Stopwords list from Rainbow
 
82
    add("a");
 
83
    add("able");
 
84
    add("about");
 
85
    add("above");
 
86
    add("according");
 
87
    add("accordingly");
 
88
    add("across");
 
89
    add("actually");
 
90
    add("after");
 
91
    add("afterwards");
 
92
    add("again");
 
93
    add("against");
 
94
    add("all");
 
95
    add("allow");
 
96
    add("allows");
 
97
    add("almost");
 
98
    add("alone");
 
99
    add("along");
 
100
    add("already");
 
101
    add("also");
 
102
    add("although");
 
103
    add("always");
 
104
    add("am");
 
105
    add("among");
 
106
    add("amongst");
 
107
    add("an");
 
108
    add("and");
 
109
    add("another");
 
110
    add("any");
 
111
    add("anybody");
 
112
    add("anyhow");
 
113
    add("anyone");
 
114
    add("anything");
 
115
    add("anyway");
 
116
    add("anyways");
 
117
    add("anywhere");
 
118
    add("apart");
 
119
    add("appear");
 
120
    add("appreciate");
 
121
    add("appropriate");
 
122
    add("are");
 
123
    add("around");
 
124
    add("as");
 
125
    add("aside");
 
126
    add("ask");
 
127
    add("asking");
 
128
    add("associated");
 
129
    add("at");
 
130
    add("available");
 
131
    add("away");
 
132
    add("awfully");
 
133
    add("b");
 
134
    add("be");
 
135
    add("became");
 
136
    add("because");
 
137
    add("become");
 
138
    add("becomes");
 
139
    add("becoming");
 
140
    add("been");
 
141
    add("before");
 
142
    add("beforehand");
 
143
    add("behind");
 
144
    add("being");
 
145
    add("believe");
 
146
    add("below");
 
147
    add("beside");
 
148
    add("besides");
 
149
    add("best");
 
150
    add("better");
 
151
    add("between");
 
152
    add("beyond");
 
153
    add("both");
 
154
    add("brief");
 
155
    add("but");
 
156
    add("by");
 
157
    add("c");
 
158
    add("came");
 
159
    add("can");
 
160
    add("cannot");
 
161
    add("cant");
 
162
    add("cause");
 
163
    add("causes");
 
164
    add("certain");
 
165
    add("certainly");
 
166
    add("changes");
 
167
    add("clearly");
 
168
    add("co");
 
169
    add("com");
 
170
    add("come");
 
171
    add("comes");
 
172
    add("concerning");
 
173
    add("consequently");
 
174
    add("consider");
 
175
    add("considering");
 
176
    add("contain");
 
177
    add("containing");
 
178
    add("contains");
 
179
    add("corresponding");
 
180
    add("could");
 
181
    add("course");
 
182
    add("currently");
 
183
    add("d");
 
184
    add("definitely");
 
185
    add("described");
 
186
    add("despite");
 
187
    add("did");
 
188
    add("different");
 
189
    add("do");
 
190
    add("does");
 
191
    add("doing");
 
192
    add("done");
 
193
    add("down");
 
194
    add("downwards");
 
195
    add("during");
 
196
    add("e");
 
197
    add("each");
 
198
    add("edu");
 
199
    add("eg");
 
200
    add("eight");
 
201
    add("either");
 
202
    add("else");
 
203
    add("elsewhere");
 
204
    add("enough");
 
205
    add("entirely");
 
206
    add("especially");
 
207
    add("et");
 
208
    add("etc");
 
209
    add("even");
 
210
    add("ever");
 
211
    add("every");
 
212
    add("everybody");
 
213
    add("everyone");
 
214
    add("everything");
 
215
    add("everywhere");
 
216
    add("ex");
 
217
    add("exactly");
 
218
    add("example");
 
219
    add("except");
 
220
    add("f");
 
221
    add("far");
 
222
    add("few");
 
223
    add("fifth");
 
224
    add("first");
 
225
    add("five");
 
226
    add("followed");
 
227
    add("following");
 
228
    add("follows");
 
229
    add("for");
 
230
    add("former");
 
231
    add("formerly");
 
232
    add("forth");
 
233
    add("four");
 
234
    add("from");
 
235
    add("further");
 
236
    add("furthermore");
 
237
    add("g");
 
238
    add("get");
 
239
    add("gets");
 
240
    add("getting");
 
241
    add("given");
 
242
    add("gives");
 
243
    add("go");
 
244
    add("goes");
 
245
    add("going");
 
246
    add("gone");
 
247
    add("got");
 
248
    add("gotten");
 
249
    add("greetings");
 
250
    add("h");
 
251
    add("had");
 
252
    add("happens");
 
253
    add("hardly");
 
254
    add("has");
 
255
    add("have");
 
256
    add("having");
 
257
    add("he");
 
258
    add("hello");
 
259
    add("help");
 
260
    add("hence");
 
261
    add("her");
 
262
    add("here");
 
263
    add("hereafter");
 
264
    add("hereby");
 
265
    add("herein");
 
266
    add("hereupon");
 
267
    add("hers");
 
268
    add("herself");
 
269
    add("hi");
 
270
    add("him");
 
271
    add("himself");
 
272
    add("his");
 
273
    add("hither");
 
274
    add("hopefully");
 
275
    add("how");
 
276
    add("howbeit");
 
277
    add("however");
 
278
    add("i");
 
279
    add("ie");
 
280
    add("if");
 
281
    add("ignored");
 
282
    add("immediate");
 
283
    add("in");
 
284
    add("inasmuch");
 
285
    add("inc");
 
286
    add("indeed");
 
287
    add("indicate");
 
288
    add("indicated");
 
289
    add("indicates");
 
290
    add("inner");
 
291
    add("insofar");
 
292
    add("instead");
 
293
    add("into");
 
294
    add("inward");
 
295
    add("is");
 
296
    add("it");
 
297
    add("its");
 
298
    add("itself");
 
299
    add("j");
 
300
    add("just");
 
301
    add("k");
 
302
    add("keep");
 
303
    add("keeps");
 
304
    add("kept");
 
305
    add("know");
 
306
    add("knows");
 
307
    add("known");
 
308
    add("l");
 
309
    add("last");
 
310
    add("lately");
 
311
    add("later");
 
312
    add("latter");
 
313
    add("latterly");
 
314
    add("least");
 
315
    add("less");
 
316
    add("lest");
 
317
    add("let");
 
318
    add("like");
 
319
    add("liked");
 
320
    add("likely");
 
321
    add("little");
 
322
    add("ll"); //added to avoid words like you'll,I'll etc.
 
323
    add("look");
 
324
    add("looking");
 
325
    add("looks");
 
326
    add("ltd");
 
327
    add("m");
 
328
    add("mainly");
 
329
    add("many");
 
330
    add("may");
 
331
    add("maybe");
 
332
    add("me");
 
333
    add("mean");
 
334
    add("meanwhile");
 
335
    add("merely");
 
336
    add("might");
 
337
    add("more");
 
338
    add("moreover");
 
339
    add("most");
 
340
    add("mostly");
 
341
    add("much");
 
342
    add("must");
 
343
    add("my");
 
344
    add("myself");
 
345
    add("n");
 
346
    add("name");
 
347
    add("namely");
 
348
    add("nd");
 
349
    add("near");
 
350
    add("nearly");
 
351
    add("necessary");
 
352
    add("need");
 
353
    add("needs");
 
354
    add("neither");
 
355
    add("never");
 
356
    add("nevertheless");
 
357
    add("new");
 
358
    add("next");
 
359
    add("nine");
 
360
    add("no");
 
361
    add("nobody");
 
362
    add("non");
 
363
    add("none");
 
364
    add("noone");
 
365
    add("nor");
 
366
    add("normally");
 
367
    add("not");
 
368
    add("nothing");
 
369
    add("novel");
 
370
    add("now");
 
371
    add("nowhere");
 
372
    add("o");
 
373
    add("obviously");
 
374
    add("of");
 
375
    add("off");
 
376
    add("often");
 
377
    add("oh");
 
378
    add("ok");
 
379
    add("okay");
 
380
    add("old");
 
381
    add("on");
 
382
    add("once");
 
383
    add("one");
 
384
    add("ones");
 
385
    add("only");
 
386
    add("onto");
 
387
    add("or");
 
388
    add("other");
 
389
    add("others");
 
390
    add("otherwise");
 
391
    add("ought");
 
392
    add("our");
 
393
    add("ours");
 
394
    add("ourselves");
 
395
    add("out");
 
396
    add("outside");
 
397
    add("over");
 
398
    add("overall");
 
399
    add("own");
 
400
    add("p");
 
401
    add("particular");
 
402
    add("particularly");
 
403
    add("per");
 
404
    add("perhaps");
 
405
    add("placed");
 
406
    add("please");
 
407
    add("plus");
 
408
    add("possible");
 
409
    add("presumably");
 
410
    add("probably");
 
411
    add("provides");
 
412
    add("q");
 
413
    add("que");
 
414
    add("quite");
 
415
    add("qv");
 
416
    add("r");
 
417
    add("rather");
 
418
    add("rd");
 
419
    add("re");
 
420
    add("really");
 
421
    add("reasonably");
 
422
    add("regarding");
 
423
    add("regardless");
 
424
    add("regards");
 
425
    add("relatively");
 
426
    add("respectively");
 
427
    add("right");
 
428
    add("s");
 
429
    add("said");
 
430
    add("same");
 
431
    add("saw");
 
432
    add("say");
 
433
    add("saying");
 
434
    add("says");
 
435
    add("second");
 
436
    add("secondly");
 
437
    add("see");
 
438
    add("seeing");
 
439
    add("seem");
 
440
    add("seemed");
 
441
    add("seeming");
 
442
    add("seems");
 
443
    add("seen");
 
444
    add("self");
 
445
    add("selves");
 
446
    add("sensible");
 
447
    add("sent");
 
448
    add("serious");
 
449
    add("seriously");
 
450
    add("seven");
 
451
    add("several");
 
452
    add("shall");
 
453
    add("she");
 
454
    add("should");
 
455
    add("since");
 
456
    add("six");
 
457
    add("so");
 
458
    add("some");
 
459
    add("somebody");
 
460
    add("somehow");
 
461
    add("someone");
 
462
    add("something");
 
463
    add("sometime");
 
464
    add("sometimes");
 
465
    add("somewhat");
 
466
    add("somewhere");
 
467
    add("soon");
 
468
    add("sorry");
 
469
    add("specified");
 
470
    add("specify");
 
471
    add("specifying");
 
472
    add("still");
 
473
    add("sub");
 
474
    add("such");
 
475
    add("sup");
 
476
    add("sure");
 
477
    add("t");
 
478
    add("take");
 
479
    add("taken");
 
480
    add("tell");
 
481
    add("tends");
 
482
    add("th");
 
483
    add("than");
 
484
    add("thank");
 
485
    add("thanks");
 
486
    add("thanx");
 
487
    add("that");
 
488
    add("thats");
 
489
    add("the");
 
490
    add("their");
 
491
    add("theirs");
 
492
    add("them");
 
493
    add("themselves");
 
494
    add("then");
 
495
    add("thence");
 
496
    add("there");
 
497
    add("thereafter");
 
498
    add("thereby");
 
499
    add("therefore");
 
500
    add("therein");
 
501
    add("theres");
 
502
    add("thereupon");
 
503
    add("these");
 
504
    add("they");
 
505
    add("think");
 
506
    add("third");
 
507
    add("this");
 
508
    add("thorough");
 
509
    add("thoroughly");
 
510
    add("those");
 
511
    add("though");
 
512
    add("three");
 
513
    add("through");
 
514
    add("throughout");
 
515
    add("thru");
 
516
    add("thus");
 
517
    add("to");
 
518
    add("together");
 
519
    add("too");
 
520
    add("took");
 
521
    add("toward");
 
522
    add("towards");
 
523
    add("tried");
 
524
    add("tries");
 
525
    add("truly");
 
526
    add("try");
 
527
    add("trying");
 
528
    add("twice");
 
529
    add("two");
 
530
    add("u");
 
531
    add("un");
 
532
    add("under");
 
533
    add("unfortunately");
 
534
    add("unless");
 
535
    add("unlikely");
 
536
    add("until");
 
537
    add("unto");
 
538
    add("up");
 
539
    add("upon");
 
540
    add("us");
 
541
    add("use");
 
542
    add("used");
 
543
    add("useful");
 
544
    add("uses");
 
545
    add("using");
 
546
    add("usually");
 
547
    add("uucp");
 
548
    add("v");
 
549
    add("value");
 
550
    add("various");
 
551
    add("ve"); //added to avoid words like I've,you've etc.
 
552
    add("very");
 
553
    add("via");
 
554
    add("viz");
 
555
    add("vs");
 
556
    add("w");
 
557
    add("want");
 
558
    add("wants");
 
559
    add("was");
 
560
    add("way");
 
561
    add("we");
 
562
    add("welcome");
 
563
    add("well");
 
564
    add("went");
 
565
    add("were");
 
566
    add("what");
 
567
    add("whatever");
 
568
    add("when");
 
569
    add("whence");
 
570
    add("whenever");
 
571
    add("where");
 
572
    add("whereafter");
 
573
    add("whereas");
 
574
    add("whereby");
 
575
    add("wherein");
 
576
    add("whereupon");
 
577
    add("wherever");
 
578
    add("whether");
 
579
    add("which");
 
580
    add("while");
 
581
    add("whither");
 
582
    add("who");
 
583
    add("whoever");
 
584
    add("whole");
 
585
    add("whom");
 
586
    add("whose");
 
587
    add("why");
 
588
    add("will");
 
589
    add("willing");
 
590
    add("wish");
 
591
    add("with");
 
592
    add("within");
 
593
    add("without");
 
594
    add("wonder");
 
595
    add("would");
 
596
    add("would");
 
597
    add("x");
 
598
    add("y");
 
599
    add("yes");
 
600
    add("yet");
 
601
    add("you");
 
602
    add("your");
 
603
    add("yours");
 
604
    add("yourself");
 
605
    add("yourselves");
 
606
    add("z");
 
607
    add("zero");
 
608
  }
 
609
 
 
610
  /**
 
611
   * removes all stopwords
 
612
   */
 
613
  public void clear() {
 
614
    m_Words.clear();
 
615
  }
 
616
 
 
617
  /**
 
618
   * adds the given word to the stopword list (is automatically converted to
 
619
   * lower case and trimmed)
 
620
   *
 
621
   * @param word the word to add
 
622
   */
 
623
  public void add(String word) {
 
624
    if (word.trim().length() > 0)
 
625
      m_Words.add(word.trim().toLowerCase());
 
626
  }
 
627
 
 
628
  /**
 
629
   * removes the word from the stopword list
 
630
   *
 
631
   * @param word the word to remove
 
632
   * @return true if the word was found in the list and then removed
 
633
   */
 
634
  public boolean remove(String word) {
 
635
    return m_Words.remove(word);
 
636
  }
 
637
  
 
638
  /** 
 
639
   * Returns true if the given string is a stop word.
 
640
   * 
 
641
   * @param word the word to test
 
642
   * @return true if the word is a stopword
 
643
   */
 
644
  public boolean is(String word) {
 
645
    return m_Words.contains(word.toLowerCase());
 
646
  }
 
647
 
 
648
  /**
 
649
   * Returns a sorted enumeration over all stored stopwords
 
650
   *
 
651
   * @return the enumeration over all stopwords
 
652
   */
 
653
  public Enumeration elements() {
 
654
    Iterator    iter;
 
655
    Vector      list;
 
656
 
 
657
    iter = m_Words.iterator();
 
658
    list = new Vector();
 
659
 
 
660
    while (iter.hasNext())
 
661
      list.add(iter.next());
 
662
 
 
663
    // sort list
 
664
    Collections.sort(list);
 
665
 
 
666
    return list.elements();
 
667
  }
 
668
 
 
669
  /**
 
670
   * Generates a new Stopwords object from the given file
 
671
   *
 
672
   * @param filename the file to read the stopwords from
 
673
   * @throws Exception if reading fails
 
674
   */
 
675
  public void read(String filename) throws Exception {
 
676
    read(new File(filename));
 
677
  }
 
678
 
 
679
  /**
 
680
   * Generates a new Stopwords object from the given file
 
681
   *
 
682
   * @param file the file to read the stopwords from
 
683
   * @throws Exception if reading fails
 
684
   */
 
685
  public void read(File file) throws Exception {
 
686
    read(new BufferedReader(new FileReader(file)));
 
687
  }
 
688
 
 
689
  /**
 
690
   * Generates a new Stopwords object from the reader. The reader is
 
691
   * closed automatically.
 
692
   *
 
693
   * @param reader the reader to get the stopwords from
 
694
   * @throws Exception if reading fails
 
695
   */
 
696
  public void read(BufferedReader reader) throws Exception {
 
697
    String      line;
 
698
 
 
699
    clear();
 
700
    
 
701
    while ((line = reader.readLine()) != null) {
 
702
      line = line.trim();
 
703
      // comment?
 
704
      if (line.startsWith("#"))
 
705
        continue;
 
706
      add(line);
 
707
    }
 
708
 
 
709
    reader.close();
 
710
  }
 
711
 
 
712
  /**
 
713
   * Writes the current stopwords to the given file
 
714
   *
 
715
   * @param filename the file to write the stopwords to
 
716
   * @throws Exception if writing fails
 
717
   */
 
718
  public void write(String filename) throws Exception {
 
719
    write(new File(filename));
 
720
  }
 
721
 
 
722
  /**
 
723
   * Writes the current stopwords to the given file
 
724
   *
 
725
   * @param file the file to write the stopwords to
 
726
   * @throws Exception if writing fails
 
727
   */
 
728
  public void write(File file) throws Exception {
 
729
    write(new BufferedWriter(new FileWriter(file)));
 
730
  }
 
731
 
 
732
  /**
 
733
   * Writes the current stopwords to the given writer. The writer is closed
 
734
   * automatically.
 
735
   *
 
736
   * @param writer the writer to get the stopwords from
 
737
   * @throws Exception if writing fails
 
738
   */
 
739
  public void write(BufferedWriter writer) throws Exception {
 
740
    Enumeration   enm;
 
741
 
 
742
    // header
 
743
    writer.write("# generated " + new Date());
 
744
    writer.newLine();
 
745
 
 
746
    enm = elements();
 
747
 
 
748
    while (enm.hasMoreElements()) {
 
749
      writer.write(enm.nextElement().toString());
 
750
      writer.newLine();
 
751
    }
 
752
 
 
753
    writer.flush();
 
754
    writer.close();
 
755
  }
 
756
 
 
757
  /**
 
758
   * returns the current stopwords in a string
 
759
   *
 
760
   * @return the current stopwords
 
761
   */
 
762
  public String toString() {
 
763
    Enumeration   enm;
 
764
    StringBuffer  result;
 
765
 
 
766
    result = new StringBuffer();
 
767
    enm    = elements();
 
768
    while (enm.hasMoreElements()) {
 
769
      result.append(enm.nextElement().toString());
 
770
      if (enm.hasMoreElements())
 
771
        result.append(",");
 
772
    }
 
773
 
 
774
    return result.toString();
 
775
  }
 
776
  
 
777
  /** 
 
778
   * Returns true if the given string is a stop word.
 
779
   * 
 
780
   * @param str the word to test
 
781
   * @return true if the word is a stopword
 
782
   */
 
783
  public static boolean isStopword(String str) {
 
784
    return m_Stopwords.is(str.toLowerCase());
 
785
  }
 
786
  
 
787
  /**
 
788
   * Accepts the following parameter: <p/>
 
789
   *
 
790
   * -i file <br/>
 
791
   * loads the stopwords from the given file <p/>
 
792
   *
 
793
   * -o file <br/>
 
794
   * saves the stopwords to the given file <p/>
 
795
   *
 
796
   * -p <br/>
 
797
   * outputs the current stopwords on stdout <p/>
 
798
   *
 
799
   * Any additional parameters are interpreted as words to test as stopwords.
 
800
   * 
 
801
   * @param args commandline parameters
 
802
   * @throws Exception if something goes wrong
 
803
   */
 
804
  public static void main(String[] args) throws Exception {
 
805
    String input = Utils.getOption('i', args);
 
806
    String output = Utils.getOption('o', args);
 
807
    boolean print = Utils.getFlag('p', args);
 
808
 
 
809
    // words to process?
 
810
    Vector words = new Vector();
 
811
    for (int i = 0; i < args.length; i++) {
 
812
      if (args[i].trim().length() > 0)
 
813
        words.add(args[i].trim());
 
814
    }
 
815
    
 
816
    Stopwords stopwords = new Stopwords();
 
817
 
 
818
    // load from file?
 
819
    if (input.length() != 0)
 
820
      stopwords.read(input);
 
821
 
 
822
    // write to file?
 
823
    if (output.length() != 0)
 
824
      stopwords.write(output);
 
825
    
 
826
    // output to stdout?
 
827
    if (print) {
 
828
      System.out.println("\nStopwords:");
 
829
      Enumeration enm = stopwords.elements();
 
830
      int i = 0;
 
831
      while (enm.hasMoreElements()) {
 
832
        System.out.println((i+1) + ". " + enm.nextElement());
 
833
        i++;
 
834
      }
 
835
    }
 
836
 
 
837
    // check words for being a stopword
 
838
    if (words.size() > 0) {
 
839
      System.out.println("\nChecking for stopwords:");
 
840
      for (int i = 0; i < words.size(); i++) {
 
841
        System.out.println(
 
842
            (i+1) + ". " + words.get(i) + ": " 
 
843
            + stopwords.is(words.get(i).toString()));
 
844
      }
 
845
    }
 
846
  }
 
847
}