Java Code Examples for it.unimi.dsi.fastutil.ints.IntArrayList#addAll()

The following examples show how to use it.unimi.dsi.fastutil.ints.IntArrayList#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoreNLPUtils.java    From minie with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Given a sequence of words and a pivot-word index, return the chained nouns from the left and from the right
 * of the pivot word.  
 * @param sequence: a sequence of words (list of IndexedWord)
 * @param wordInd: the index of the pivot word
 * @return a list of chained nouns to the left and the right of the pivot word (the pivot word is included)
 */
public static ObjectArrayList<IndexedWord> getChainedNouns(ObjectArrayList<IndexedWord> sequence, int wordInd){
    IntArrayList chainedNounsInd = new IntArrayList();
    
    // Get the chained nouns from left and right
    IntArrayList chainedNounsLeft = getChainedNounsFromLeft(sequence, chainedNounsInd.clone(), wordInd);
    IntArrayList chainedNounsRight = getChainedNounsFromRight(sequence, chainedNounsInd.clone(), wordInd);
    
    // Add all the words to the chained nouns
    chainedNounsInd.addAll(chainedNounsLeft);
    chainedNounsInd.add(wordInd);
    chainedNounsInd.addAll(chainedNounsRight);
    
    // IndexedWord chained nouns
    ObjectArrayList<IndexedWord> iChainedNouns = new ObjectArrayList<IndexedWord>();
    for (int i: FastUtil.sort(chainedNounsInd)){
        iChainedNouns.add(sequence.get(i));
    }
    
    return iChainedNouns;
}
 
Example 2
Source File: CoreNLPUtils.java    From minie with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Given a sequence of words and a pivot-word index, return the chained verbs from the left and from the right
 * of the pivot word.  
 * @param sequence: a sequence of words (list of IndexedWord)
 * @param wordInd: the index of the pivot word
 * @return a list of chained verbs to the left and the right of the pivot word (the pivot word is included)
 */
public static ObjectArrayList<IndexedWord> getChainedVerbs(ObjectArrayList<IndexedWord> sequence, int wordInd){
    IntArrayList chainedVerbsInd = new IntArrayList();
    
    // Get the chained verbs from left and right
    IntArrayList chainedVerbsLeft = getChainedVerbsFromLeft(sequence, chainedVerbsInd.clone(), wordInd);
    IntArrayList chainedVerbsRight = getChainedVerbsFromRight(sequence, chainedVerbsInd.clone(), wordInd);
    
    // Add all the words to the chained verbs
    chainedVerbsInd.addAll(chainedVerbsLeft);
    chainedVerbsInd.add(wordInd);
    chainedVerbsInd.addAll(chainedVerbsRight);
    
    // IndexedWord chained verbs
    ObjectArrayList<IndexedWord> iChainedVerbs = new ObjectArrayList<IndexedWord>();
    for (int i: FastUtil.sort(chainedVerbsInd)){
        iChainedVerbs.add(sequence.get(i));
    }
    
    return iChainedVerbs;
}
 
Example 3
Source File: CoreNLPUtils.java    From minie with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Given a sequence of words and a pivot-word index, return the "chained words" from the left and from the right
 * of the pivot word. "Chained words" are a list of words, which all of them share the same POS tag and have no 
 * NE types.
 * 
 * @param sequence: a sequence of words (list of IndexedWord)
 * @param wordInd: the index of the pivot word
 * @return a list of chained words to the left and the right of the pivot word (the pivot word is included)
 */
public static ObjectArrayList<IndexedWord> getChainedTagNoNER(ObjectArrayList<IndexedWord> sequence, int wordInd){
    IntArrayList chainedPosWordsInd = new IntArrayList();
    
    // Get the chained nouns from left and right
    IntArrayList chainedPosWordsLeft = getChainedTagsFromLeftNoNER(sequence, chainedPosWordsInd.clone(), wordInd);
    IntArrayList chainedPosWordsRight = getChainedTagsFromRightNoNER(sequence, chainedPosWordsInd.clone(), wordInd);
    
    // Add all the words to the chained nouns
    chainedPosWordsInd.addAll(chainedPosWordsLeft);
    chainedPosWordsInd.add(wordInd);
    chainedPosWordsInd.addAll(chainedPosWordsRight);
    
    // IndexedWord chained nouns
    ObjectArrayList<IndexedWord> iChainedNouns = new ObjectArrayList<IndexedWord>();
    for (int i: FastUtil.sort(chainedPosWordsInd)){
        iChainedNouns.add(sequence.get(i));
    }
    
    return iChainedNouns;
}
 
Example 4
Source File: CoreNLPUtils.java    From minie with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Given a sequence of words and a pivot-word index, return the chained words of same NER, both from the left and 
 * from the right of the pivot word (it is assumed that the pivot word is also NER).  
 * @param sequence: a sequence of words (list of IndexedWord)
 * @param wordInd: the index of the pivot word
 * @return a list of chained nouns to the left and the right of the pivot word (the pivot word is included)
 */
public static ObjectArrayList<IndexedWord> getChainedNERs(ObjectArrayList<IndexedWord> sequence, int wordInd){
    IntArrayList chainedNounsInd = new IntArrayList();
    
    // Get the chained nouns from left and right
    IntArrayList chainedNounsLeft = getChainedNERsFromLeft(sequence, chainedNounsInd.clone(), wordInd, 
                                                           sequence.get(wordInd).ner());
    IntArrayList chainedNounsRight = getChainedNERsFromRight(sequence, chainedNounsInd.clone(), wordInd,
                                                             sequence.get(wordInd).ner());
    
    // Add all the words to the chained nouns
    chainedNounsInd.addAll(chainedNounsLeft);
    chainedNounsInd.add(wordInd);
    chainedNounsInd.addAll(chainedNounsRight);
    
    // IndexedWord chained nouns
    ObjectArrayList<IndexedWord> iChainedNouns = new ObjectArrayList<IndexedWord>();
    for (int i: FastUtil.sort(chainedNounsInd)){
        iChainedNouns.add(sequence.get(i));
    }
    
    return iChainedNouns;
}