前提・実現したいこと
機械学習のための学習用のデータの作成を作っています。
作成源はwikipedhiaのファイルを使っています。
実際にダウンロードしたファイルは正規化がされておらず、例えば、
Because I've been grading all damn day and am as tired as
a Swearengen of hearing
other about the finished semesters
of pretty much every other academic blogger,
I thought that
it might
be best to avoid
jealously lashing out and scribble a
"Best of Acephalous 2009" post.
のようにバラバラになっています。そこで、「.」が含まれていたら、例文を一行一文の文章に正規化したいのですが方法がわかりません。
発生している問題
コンパイルは上手くいくが、実行結果が上手くいかない(空になる)
該当のソースコード
import java.io.;
import java.util.;
class Checker{
void run(String File) throws IOException{
}//run終わり
void Period(String File) throws IOException{//現在の行番号を数える変数
BufferedReader in = new BufferedReader(new FileReader(File));//Fileを読み込む
String line;
while((line = in.readLine()) != null){//1行ずつ読む
if(line =="."){
String[] splitted = line.split(".");
ArrayList<String> list = new ArrayList<>();
list.add(String.valueOf(splitted));
System.out.println(list);
}
}
in.close();//閉じる
}
public static void main(String[] args) throws IOException{
Checker check = new Checker();
if(args.length != 0) {//引数が与えられなかった時、java.lang.ArrayIndexOutOfBoundsException: 0と出たので、runではなくクラスの中に入れました。
check.Period(args[0]);
}else{
System.out.println("ERROR:");
}
}
}