Unexpected output for summary generator in Java
<p>In reference to this question : <a href="http://stackoverflow.com/questions/9702739/score-each-sentence-in-a-line-based-upon-a-tag-and-summarize-the-text-java">Score each sentence in a line based upon a tag and summarize the text. (Java)</a> , I'm working on a summarizer in Java.
Now, after all that has been done in the question that has been mentioned above, one small problem still persists.
I'm restating what I'm trying to do. From a given text file, I want to fetch individual sentences, and then score them,on the basis of certain tags,and finally,the sentences with high scores are to be written in to the file that will contain the summary.
Here's the relevant part of the code(with much thanks to the answerers in the above mentioned question):</p>

<pre><code>        ArrayList&lt;Integer&gt; scoreTracker = new ArrayList&lt;Integer&gt;();

        Pattern tagFinder = Pattern.compile("/JJ|" + freqWords); // tag for adjective,if you need to add more tags,just use - /JJ|/RB|/NN and so on..every tag separated by | .. tag1|tag2|tag3 and so on 
        while ((line = reader.readLine()) != null) { // scan input file line by line
            BreakIterator bi = BreakIterator.getSentenceInstance(); // one line may contain many sentences,so using BreakIterator to break sentences
            bi.setText(line);
            int end, start = bi.first();
            while ((end = bi.next()) != BreakIterator.DONE) { // for every new sentence in line
                String sentence = line.substring(start, end); // store one sentence
                String tagged = tagger.tagString(sentence); // tag this sentence
                int score = 0; // score for the sentence
                Matcher tag = tagFinder.matcher(tagged); //using a Matcher to find the tag in the tagged sentence
                while (tag.find()) // if tag exists
                    score++; // increment score by one
                scoreTracker.add(score);
                if (score &gt; 5) // for a score greater than 5,write the sentence,not the line,into the summary
                    writerForTempFile.write(sentence);
                start = end; // set start = end to commence to the next sentence in the line

                }
        }

        System.out.println(scoreTracker);
</code></pre>

<p>Now the problem:
I have the following text file for my test purpose :</p>

<pre><code>This is a sample text.
This is a new line in the sample document.This next line is just to test adjacent sentences in the document.Because test runs suggest that immediate sentences are included in the final result due to new line delimiter usage and not sentence terminator usage.

Then we have a paragraph space.
Then there is this long line that has many words ,so it should be important. Should it?

That should be enough for testing. 

test test test test test test.
</code></pre>

<p>It contains 9 sentences. But the program finds only 7. It does score them. But,after that,my condition is to print sentences with <code>score&gt;5</code> . But it also prints certain sentences with a <code>score&lt;5</code>. I have added an <code>ArrayList</code> to keep a track of score of every sentence. That's how I know that only 7 sentences are being scored and sentences with score less that 5 are also being printed.
Kindly help, as after a lot of trials, I'm unable to find where I'm going wrong.</p>
