summaryrefslogtreecommitdiffstats
path: root/lowercasing_test/src/tests/lowercasing/CasingVariants.java
blob: aa1bf8fcf4da47c490c1ca7cbf5baad0b0d221b8 (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
// Copyright 2016 Yahoo Inc. 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;
        File f = new File("./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)));
    }
}