Example usage for org.apache.commons.lang ArrayUtils add

List of usage examples for org.apache.commons.lang ArrayUtils add

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils add.

Prototype

public static double[] add(double[] array, int index, double element) 

Source Link

Document

Inserts the specified element at the specified position in the array.

Usage

From source file:wordnet.DictionaryFactory.java

@SuppressWarnings("unchecked")
private static ArrayList<String[]> getCompoundTermsList(Dictionary wordnet, POS pos) {
    ArrayList<String[]> compoundTermsList = new ArrayList<String[]>();
    Iterator term_iter = null;/*from  w ww .  j  a v  a2s  . c o m*/

    try {
        term_iter = wordnet.getIndexWordIterator(pos);
    } catch (JWNLException e) {
        AppLogger.error.log(Level.SEVERE, "Cannot get index word set from wordnet dictionary.");
    }

    while (term_iter.hasNext()) {
        IndexWord current_term_obj = (IndexWord) term_iter.next();
        String current_term_string = current_term_obj.getLemma();
        // current_term_string = current_term_string.replace("'s ", " 's ").replace("s' ",
        // "s ' ");
        String[] current_term = current_term_string.split(" ");
        String[] current_term_nodash = current_term.clone();
        for (int i = 0; i < current_term_nodash.length; i++) {
            String[] current_term_nodash_segment = current_term_nodash[i].split("-");
            if (current_term_nodash_segment.length > 1) {
                current_term_nodash[i] = current_term_nodash_segment[0];
                for (int j = 1; j < current_term_nodash_segment.length; j++) {
                    current_term_nodash = (String[]) ArrayUtils.add(current_term_nodash, i + j,
                            current_term_nodash_segment[j]);
                }
            }
        }

        if (current_term.length > 1) {
            compoundTermsList.add(parseCompoundTerm(current_term, pos));
        }
        if (current_term_nodash.length > 1) {
            compoundTermsList.add(parseCompoundTerm(current_term_nodash, pos));
        }
    }
    return compoundTermsList;
}

From source file:wordnet.DictionaryFactory.java

private static String[] parseCompoundTerm(String[] compound_term, POS pos) {
    String[] compound_term_array = compound_term.clone();
    for (int i = 0; i < compound_term_array.length; i++) {

        // Special handling for verb lemmas that contain the possessive placeholder
        // "one's" or "someone's", (e.g. "give_one's_best", "pull_someone's_leg")
        ////w w w . j a v  a 2  s  .  c  o m
        // if (pos == POS.VERB) {
        // if (compound_term_array[i].endsWith("one's")) {
        // compound_term_array[i] = "POS_PHRASE";
        // }
        // }

        // Special handling for noun lemmas that contain a word in possessive case form,
        // (e.g. "adam's_apple", "mind's eye", "Achilles' heel")
        if (pos == POS.NOUN) {
            if (compound_term_array[i].endsWith("'s")) {
                compound_term_array[i] = compound_term_array[i].substring(0,
                        compound_term_array[i].length() - 2);
                compound_term_array = (String[]) ArrayUtils.add(compound_term_array, i + 1, "'s");
                i++;
            } else if (compound_term_array[i].endsWith("s'")) {
                compound_term_array[i] = compound_term_array[i].substring(0,
                        compound_term_array[i].length() - 1);
                compound_term_array = (String[]) ArrayUtils.add(compound_term_array, i + 1, "'");
            }
        }

    }

    return compound_term_array;
}

From source file:wzw.lang.ArraySupport.java

public static Object[] add(Object[] array, int index, Object element) {
    return ArrayUtils.add(array, index, element);

}