Search in sources :

Example 1 with ContextPatternWritable

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

the class TwitterCooccurExtractor method getNextPair.

/* (non-Javadoc)
	 * @see edu.isi.mavuno.extract.Extractor#getNextPair(edu.isi.mavuno.util.ContextPatternWritable)
	 */
@Override
public boolean getNextPair(ContextPatternWritable pair) {
    if (mPairsIter != null && mPairsIter.hasNext()) {
        ContextPatternWritable c = mPairsIter.next();
        pair.setContext(c.getContext());
        pair.setPattern(c.getPattern());
        return true;
    }
    return false;
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 2 with ContextPatternWritable

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

the class TwitterGeoTemporalExtractor method getNextPair.

/* (non-Javadoc)
	 * @see edu.isi.mavuno.extract.Extractor#getNextPair(edu.isi.mavuno.util.ContextPatternWritable)
	 */
@Override
public boolean getNextPair(ContextPatternWritable pair) {
    if (mGeoTemporalPairsIter != null && mGeoTemporalPairsIter.hasNext()) {
        ContextPatternWritable c = mGeoTemporalPairsIter.next();
        pair.setContext(c.getContext());
        pair.setPattern(c.getPattern());
        return true;
    }
    return false;
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 3 with ContextPatternWritable

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

the class TwitterGeoTemporalExtractor method loadGeoTemporalPairs.

private void loadGeoTemporalPairs(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(MavunoUtils.createContext(calToText(), mLocation));
                c.setPattern(mPattern);
                mGeoTemporalPairs.add(c);
                updateCalendar(-1);
            }
            // reset calendar
            updateCalendar(mLeftTimeWindow);
            // context for current time
            c = new ContextPatternWritable();
            c.setContext(MavunoUtils.createContext(calToText(), mLocation));
            c.setPattern(mPattern);
            mGeoTemporalPairs.add(c);
            // future contexts
            for (int rightTime = 1; rightTime <= mRightTimeWindow; rightTime++) {
                c = new ContextPatternWritable();
                c.setContext(MavunoUtils.createContext(calToText(), mLocation));
                c.setPattern(mPattern);
                mGeoTemporalPairs.add(c);
                updateCalendar(1);
            }
            // reset calendar
            updateCalendar(-mRightTimeWindow);
        }
    }
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 4 with ContextPatternWritable

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

the class TwitterGeoTemporalExtractor method loadGeoPairs.

private void loadGeoPairs(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;
            }
            c = new ContextPatternWritable();
            c.setPattern(mPattern);
            c.setContext(mLocation);
            mGeoTemporalPairs.add(c);
        }
    }
}
Also used : ContextPatternWritable(edu.isi.mavuno.util.ContextPatternWritable)

Example 5 with ContextPatternWritable

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

the class DIRTExtractor method getNextPair.

@Override
public boolean getNextPair(ContextPatternWritable pair) {
    if (mDependPairsIter != null && mDependPairsIter.hasNext()) {
        ContextPatternWritable c = mDependPairsIter.next();
        pair.setContext(c.getContext());
        pair.setPattern(c.getPattern());
        return true;
    }
    if (mSentIter != null && mSentIter.hasNext()) {
        loadDependPairs();
        return getNextPair(pair);
    }
    return false;
}
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