2012-07-12 2 views
0

아래 코드 줄이 어떤 것인지 누군가가 설명 할 수 있는지 궁금합니다.Java : While 루프의 임베디드 동등 문

while((sample = samples.read()) != null)

는 먼저 samples의 다음 행에 동일한 sample을 설정 한 다음 확인 비어 있지의 확인하십시오 있습니까?

이것은 더 일반적인 질문이지만, 누구나 OpenNLP에 대한 좋은 자습서를 가지고 있다면, 정말 고맙게 생각합니다. 여기

은 그 전체에있어서이다

public static Dictionary buildNGramDictionary(ObjectStream samples, int cutoff) throws IOException {

NGramModel ngramModel = new NGramModel(); 
    POSSample sample; 

    while((sample = samples.read()) != null) { 
     String[] words = sample.getSentence(); 
     if (words.length > 0) 
      ngramModel.add(new StringList(words), 1, 1); 
    } 

    ngramModel.cutoff(cutoff, Integer.MAX_VALUE); 
    return ngramModel.toDictionary(true); 
} 

+1

보다 더 높은 우선 순위를 가지고 있기 때문에 괄호 (sample = samples.read()) 내부
표현은 예, 그것은 않습니다 정확히 무엇을 먼저 평가됩니다. LHS 설정과는 별도로'= '연산은 RHS의 값으로 평가됩니다. – biziclop

답변

3
  1. 그것으로 samples.read()의 반환 값을 할당 sample 변수
  2. sample 않은 널 만 그 본체를 실행 여부를 확인 while 루프의 번호
+0

알았어. 고맙습니다! –