Exemplo n.º 1
0
            public bool hasNext()
            {
                if (hasNextCalled)
                {
                    return(actualTerm != null);
                }
                hasNextCalled = true;

                do
                {
                    actualTerm = termEnum.term();
                    actualFreq = termEnum.docFreq();

                    // if there are no words return false
                    if (actualTerm == null)
                    {
                        return(false);
                    }

                    string currentField = actualTerm.field();

                    // if the next word doesn't have the same field return false
                    if (currentField != dict.field) // intern'd comparison
                    {
                        actualTerm = null;
                        return(false);
                    }

                    // got a valid term, does it pass the threshold?
                    if (isFrequent(actualTerm))
                    {
                        return(true);
                    }

                    // term not up to threshold
                    try {
                        termEnum.next();
                    } catch (IOException e) {
                        throw new java.lang.RuntimeException(e);
                    }
                } while (true);
            }