Search in sources :

Example 11 with ContextPatternWritable

use of edu.isi.mavuno.util.ContextPatternWritable in project mavuno by metzlerd.

the class NAryChunkExtractor method getNextPair.

@Override
public boolean getNextPair(final ContextPatternWritable pair) {
    if (mChunkPairsIter != null && mChunkPairsIter.hasNext()) {
        ContextPatternWritable c = mChunkPairsIter.next();
        pair.setContext(c.getContext());
        pair.setPattern(c.getPattern());
        return true;
    }
    if (mSentIter != null && mSentIter.hasNext()) {
        loadChunkPairs();
        return getNextPair(pair);
    }
    return false;
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 12 with ContextPatternWritable

use of edu.isi.mavuno.util.ContextPatternWritable in project mavuno by metzlerd.

the class ChunkExtractor method getNextPair.

@Override
public boolean getNextPair(final ContextPatternWritable pair) {
    if (mChunkPairsIter != null && mChunkPairsIter.hasNext()) {
        ContextPatternWritable c = mChunkPairsIter.next();
        pair.setContext(c.getContext());
        pair.setPattern(c.getPattern());
        return true;
    }
    if (mSentIter != null && mSentIter.hasNext()) {
        loadChunkPairs();
        return getNextPair(pair);
    }
    return false;
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 13 with ContextPatternWritable

use of edu.isi.mavuno.util.ContextPatternWritable in project mavuno by metzlerd.

the class TwitterCooccurExtractor method loadPairs.

private void loadPairs(Text[] terms, String id) {
    mPairs.clear();
    ContextPatternWritable c;
    for (int i = 0; i < terms.length; i++) {
        for (int gramSize = 1; gramSize <= mMaxGramSize; gramSize++) {
            if (!getPattern(mPattern, terms, i, gramSize)) {
                continue;
            }
            c = new ContextPatternWritable();
            c.setContext(id);
            c.setPattern(mPattern);
            mPairs.add(c);
        }
    }
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 14 with ContextPatternWritable

use of edu.isi.mavuno.util.ContextPatternWritable in project mavuno by metzlerd.

the class TwitterGeoTemporalExtractor method loadTemporalPairs.

private void loadTemporalPairs(Text[] terms) {
    mGeoTemporalPairs.clear();
    ContextPatternWritable c;
    for (int i = 0; i < terms.length; i++) {
        for (int gramSize = 1; gramSize <= mMaxGramSize; gramSize++) {
            if (!getPattern(mPattern, terms, i, gramSize)) {
                continue;
            }
            // past contexts
            for (int leftTime = 1; leftTime <= mLeftTimeWindow; leftTime++) {
                c = new ContextPatternWritable();
                c.setContext(calToText());
                c.setPattern(mPattern);
                mGeoTemporalPairs.add(c);
                updateCalendar(-1);
            }
            // reset calendar
            updateCalendar(mLeftTimeWindow);
            // context for current time
            c = new ContextPatternWritable();
            c.setContext(calToText());
            c.setPattern(mPattern);
            mGeoTemporalPairs.add(c);
            // future contexts
            for (int rightTime = 1; rightTime <= mRightTimeWindow; rightTime++) {
                c = new ContextPatternWritable();
                c.setContext(calToText());
                c.setPattern(mPattern);
                mGeoTemporalPairs.add(c);
                updateCalendar(1);
            }
            // reset calendar
            updateCalendar(-mRightTimeWindow);
        }
    }
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Aggregations

ContextPatternWritable (edu.isi.mavuno.util.ContextPatternWritable)14 TratzParsedTokenWritable (edu.isi.mavuno.util.TratzParsedTokenWritable)2 Text (org.apache.hadoop.io.Text)2 ArrayList (java.util.ArrayList)1