blob: cb315a4bbf9641fce6d6aab748bcb5c9ca26c0d3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
import static com.yahoo.language.LinguisticsCase.toLowerCase;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import com.yahoo.text.Utf8;
public class CasingVariants {
public static void main(String[] args) throws FileNotFoundException, IOException {
int read = 0;
char[] buffer = new char[5000];
String raw;
String srcDir = System.getenv("SOURCE_DIRECTORY");
if (srcDir == null) {
srcDir = ".";
}
File f = new File(srcDir + "/letters");
StringBuilder s = new StringBuilder();
InputStream in = new FileInputStream(f);
Reader r = new InputStreamReader(in, Utf8.getCharset());
while (read != -1) {
read = r.read(buffer);
if (read > 0) {
s.append(buffer, 0, read);
}
}
raw = s.toString();
System.out.write(Utf8.toBytes(toLowerCase(raw)));
}
}
|