| 1 |
|
package org.apache.lucene.analysis; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
import java.io.BufferedReader; |
| 20 |
|
import java.io.File; |
| 21 |
|
import java.io.FileReader; |
| 22 |
|
import java.io.IOException; |
| 23 |
|
import java.io.Reader; |
| 24 |
|
import java.util.HashMap; |
| 25 |
|
import java.util.HashSet; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@author |
| 31 |
|
@version |
| 32 |
|
|
|
|
|
| 28.6% |
Uncovered Elements: 40 (56) |
Complexity: 11 |
Complexity Density: 0.3 |
|
| 33 |
|
public class WordlistLoader { |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
@param |
| 42 |
|
@return |
| 43 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 44 |
0
|
public static HashSet getWordSet(File wordfile) throws IOException {... |
| 45 |
0
|
HashSet result = new HashSet(); |
| 46 |
0
|
FileReader reader = null; |
| 47 |
0
|
try { |
| 48 |
0
|
reader = new FileReader(wordfile); |
| 49 |
0
|
result = getWordSet(reader); |
| 50 |
|
} |
| 51 |
|
finally { |
| 52 |
0
|
if (reader != null) |
| 53 |
0
|
reader.close(); |
| 54 |
|
} |
| 55 |
0
|
return result; |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@param |
| 65 |
|
@return |
| 66 |
|
|
|
|
|
| 83.3% |
Uncovered Elements: 3 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 67 |
2
|
public static HashSet getWordSet(Reader reader) throws IOException {... |
| 68 |
2
|
HashSet result = new HashSet(); |
| 69 |
2
|
BufferedReader br = null; |
| 70 |
2
|
try { |
| 71 |
2
|
if (reader instanceof BufferedReader) { |
| 72 |
1
|
br = (BufferedReader) reader; |
| 73 |
|
} else { |
| 74 |
1
|
br = new BufferedReader(reader); |
| 75 |
|
} |
| 76 |
2
|
String word = null; |
| 77 |
?
|
while ((word = br.readLine()) != null) { |
| 78 |
6
|
result.add(word.trim()); |
| 79 |
|
} |
| 80 |
|
} |
| 81 |
|
finally { |
| 82 |
2
|
if (br != null) |
| 83 |
2
|
br.close(); |
| 84 |
|
} |
| 85 |
2
|
return result; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
@return |
| 94 |
|
@throws |
| 95 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 5 |
Complexity Density: 0.29 |
|
| 96 |
0
|
public static HashMap getStemDict(File wordstemfile) throws IOException {... |
| 97 |
0
|
if (wordstemfile == null) |
| 98 |
0
|
throw new NullPointerException("wordstemfile may not be null"); |
| 99 |
0
|
HashMap result = new HashMap(); |
| 100 |
0
|
BufferedReader br = null; |
| 101 |
0
|
FileReader fr = null; |
| 102 |
0
|
try { |
| 103 |
0
|
fr = new FileReader(wordstemfile); |
| 104 |
0
|
br = new BufferedReader(fr); |
| 105 |
0
|
String line; |
| 106 |
0
|
while ((line = br.readLine()) != null) { |
| 107 |
0
|
String[] wordstem = line.split("\t", 2); |
| 108 |
0
|
result.put(wordstem[0], wordstem[1]); |
| 109 |
|
} |
| 110 |
|
} finally { |
| 111 |
0
|
if (fr != null) |
| 112 |
0
|
fr.close(); |
| 113 |
0
|
if (br != null) |
| 114 |
0
|
br.close(); |
| 115 |
|
} |
| 116 |
0
|
return result; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
} |