2017-07-31 2 views
-1

コードの行を分割してスペルチェックを行うコードを作成するのに助けが必要です。結果は私にこれを示すbufferedReaderから単語に分割する方法

public static void main(String [] args) throws IOException { 
    Stem myStem = new Stem(); 

    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\lamrh\\IdeaProjects\\untitled1\\src\\bigON\\data.txt"))); 

    //String currentWord = String.valueOf(bufferedReader.readLine()); 
    Scanner scanner = new Scanner(bufferedReader.readLine()); 
    //byte[] data = new byte [currentWord.length()]; 
    String[] splitLines; 
    //splitLines = splitLines.split(" "); 


    String line; 
    while((line = bufferedReader.readLine()) !=null ){ 
     //splitLines = line.split(" "); 
     String currentWord1 = formatWordGhizou (line); 
     System.out.println(""+ line+""+ ":"+ currentWord1); 

    } 
    bufferedReader.close(); 


} 

:それは言葉ではない言葉のラインで単語のようになります。

سْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم 

سْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم ِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم ِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم ِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم ِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم ِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم ِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ:سماللهالرحمنالرحيم

。 ヘルプ ありがとうございます。

あなたのwhileループにおいて
+0

関数 "formatWordGhizou()"のソースを提供できますか? –

+0

[なぜ誰かが私を助けることができますか?実際の質問ではありませんか?](http://meta.stackoverflow.com/q/284236) – EJoshuaS

+0

問題は、bufferedreaderによって読み取られた行を分割する方法です言葉 –

答えて

-1
// format the word by removing any punctuation, diacritics and non-letter charracters 
private static String formatWordGhizou (String currentWord) 
{ 
    StringBuffer modifiedWord = new StringBuffer (); 


    // remove any diacritics (short vowels) 
    if (removeDiacritics(currentWord, modifiedWord)) 
    { 
     currentWord = modifiedWord.toString (); 
    } 

    // remove any punctuation from the word 
    if (removePunctuation(currentWord, modifiedWord)) 
    { 
     currentWord = modifiedWord.toString () ; 
    } 

    // there could also be characters that aren't letters which should be removed 
    if (removeNonLetter (currentWord, modifiedWord)) 
    { 
     currentWord = modifiedWord.toString (); 
    } 

    // check for stopwords 
    if(!checkStrangeWords (currentWord)) 
     // check for stopwords 
     if(!checkStopwords (currentWord)) 
      currentWord = stemWord (currentWord); 

    return currentWord; 
} 

//----------------- 
0

行に行文字列を連結しようとすると、分割線文字列分割線を設定するために正規表現を使用し、その後、以下のように標準出力に要素を送信するために、アレイ分割線を反復(adapted from helpful tutorial at this link

String lines=""; 

while((line = bufferedReader.readLine()) !=null ){ 

    lines = lines + line; 

} 

String[] splitLines = lines.split("\\s+"); 

for (String words: splitLines) { 

    System.out.println(words); 

    } 
関連する問題