@@ -0,0 +1,1615 @@
+/*%0A * Copyright 2008 Novamente LLC%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage relex.chunk;%0A%0Aimport java.util.ArrayList;%0A%0Aimport relex.stats.TruthValue;%0Aimport relex.stats.SimpleTruthValue;%0A%0A/**%0A * Performs a simple, basic lexical chunk ranking, based on%0A * the frequency of occurance.%0A *%0A * Copyright (C) 2008 Linas Vepstas %3Clinas@linas.org%3E%0A */%0A%0Apublic abstract class ChunkRanker%0A%7B%0A%09private ArrayList%3CLexChunk%3E chunks;%0A%09%0A%09public ChunkRanker()%0A%09%7B%0A%09%09chunks = new ArrayList%3CLexChunk%3E();%0A%09%7D%0A%0A%09public ArrayList%3CLexChunk%3E getChunks()%0A%09%7B%0A%09%09rank();%0A%09%09return chunks;%0A%09%7D%0A%0A%09public void clear()%0A%09%7B%0A%09%09chunks.clear();%0A%09%7D%0A%0A%09/**%0A%09 * Add a chunk. If its already in the list, then increment %0A%09 * its liklihood of being appropriate.%0A%09 */%0A%09public void add(LexChunk ch)%0A%09%7B%0A%09%09for (int i=0; i%3Cchunks.size(); i++)%0A%09%09%7B%0A%09%09%09LexChunk c = chunks.get(i);%0A%0A%09%09%09// Increase the overall truth value if found,%0A%09%09%09if (ch.equals(c))%0A%09%09%09%7B%0A%09%09%09%09TruthValue tv = c.getTruthValue();%0A%09%09%09%09SimpleTruthValue stv = (SimpleTruthValue) tv;%0A%09%09%09%09stv.increment(1.0);%0A%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09chunks.add(ch);%0A%09%7D%0A%0A%09private void rank()%0A%09%7B%0A%09%7D%0A%7D%0A

add a chunk-ranker class.