Package com.googlecode.gaal.analysis.api

Examples of com.googlecode.gaal.analysis.api.Context


            String delimiter, int windowSize) {
        Filter<EmbeddedInterval> contextFilter = new SimpleContextFilter(0.5, 1);
        Iterable<EmbeddedInterval> contextExtractor = new EmbeddedContextExtractor(lst, corpus, intervalSetBuilder,
                contextFilter, windowSize);
        for (EmbeddedInterval embeddedInterval : contextExtractor) {
            Context context = new EmbeddedContext(embeddedInterval);
            Interval interval = embeddedInterval.getEmbeddingInterval();
            double leftRightContextRatio = (double) embeddedInterval.size() / interval.size();
            System.out.printf("%s %s %s\n", corpus.toString(context.leftSequence(), delimiter),
                    corpus.toString(embeddedInterval.fillerIterator(), delimiter),
                    corpus.toString(context.rightSequence(), delimiter));
            System.out.printf("ratio:%.2f\n", leftRightContextRatio);
        }
    }
View Full Code Here


                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            Context other = (Context) obj;
            if (left == null) {
                if (other.leftSequence() != null)
                    return false;
            } else if (!left.equals(other.leftSequence()))
                return false;
            if (right == null) {
                if (other.rightSequence() != null)
                    return false;
            } else if (!right.equals(other.rightSequence()))
                return false;
            return true;
        }
View Full Code Here

    @Test
    public void testPrint() throws FileNotFoundException {
        Iterable<EmbeddedInterval> contextExtractor = new EmbeddedContextExtractor(lst, corpus,
                new SupermaximalSetBuilder(), new NoContextFilter<EmbeddedInterval>(), WINDOW_SIZE);
        for (EmbeddedInterval embeddedInterval : contextExtractor) {
            Context context = new EmbeddedContext(embeddedInterval);
            System.out.printf("%s %s %s\n", corpus.toString(context.leftSequence(), " "),
                    corpus.toString(context.fillerSet(), " "), corpus.toString(context.rightSequence(), " "));
        }
    }
View Full Code Here

    @Test
    public void testEmbeddedContexts() {
        System.out.println("Embedded Suffix Tree Test");
        int counter = 0;
        for (EmbeddedInterval embeddedInterval : embeddedExtractor) {
            Context context = new EmbeddedContext(embeddedInterval);
            IntSequence left = context.leftSequence();
            IntSequence right = context.rightSequence();
            Multiset<IntSequence> expectedSet = fillerSet(left, right);
            Multiset<IntSequence> resultSet = context.fillerSet();
            if (!resultSet.equals(expectedSet)) {
                String leftString = corpus.toString(left, " ");
                String rightString = corpus.toString(right, " ");
                String expectedString = corpus.toString(expectedSet, " ");
                String resultString = corpus.toString(resultSet, " ");
                System.out.printf("%s %s %s\n", leftString, expectedString, rightString);
                System.err.printf("%s %s %s\n", leftString, resultString, rightString);
                fail("fill mismatch");
            }
            if (expectedSet.size() != context.fillerSetSize()) {
                System.err.printf("%d != %d\n", expectedSet.size(), context.fillerSetSize());
                fail("filler set size mismatch");
            }
            counter++;
        }
        System.out.printf("total contexts: %d\n", counter);
View Full Code Here

TOP

Related Classes of com.googlecode.gaal.analysis.api.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.