Java Code Examples for it.unimi.dsi.fastutil.objects.ObjectArrayList#add()
The following examples show how to use
it.unimi.dsi.fastutil.objects.ObjectArrayList#add() .
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 |
private static SemanticGraph getSubgraph(ObjectArrayList<TypedDependency> tds, SemanticGraph sg, IndexedWord parent, SemanticGraphEdge e, int maxPathLength, ObjectArrayList<IndexedWord> words){ Set<IndexedWord> children = sg.getChildren(parent); for (IndexedWord child: children){ if (((sg.getShortestDirectedPathEdges(sg.getFirstRoot(), child)).size() <= maxPathLength) && words.contains(child)){ e = sg.getEdge(parent, child); tds.add(new TypedDependency(e.getRelation(), parent, child)); if (sg.hasChildren(child)) getSubgraph(tds, sg, child, e, maxPathLength, words); } // else break; } TreeGraphNode rootTGN = new TreeGraphNode(new CoreLabel(parent)); EnglishGrammaticalStructure gs = new EnglishGrammaticalStructure(tds, rootTGN); return SemanticGraphFactory.generateUncollapsedDependencies(gs); }
Example 2
Source File: CoreNLPUtils.java From minie with GNU General Public License v3.0 | 6 votes |
/** * 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 3
Source File: MathParser.java From WarpPI with Apache License 2.0 | 6 votes |
public static Function joinFeatures(final MathContext context, ObjectArrayList<Feature> features) throws Error { features = MathParser.fixFeatures(context, features); ObjectArrayList<Function> process = new ObjectArrayList<>(); for (final Feature f : features) { final Function fnc = f.toFunction(context); if (fnc == null) { throw new Error(Errors.SYNTAX_ERROR, "\"" + f.getClass().getSimpleName() + "\" can't be converted into a Function!"); } process.add(fnc); } process = MathParser.fixStack(context, process); if (process.size() > 1) { throw new Error(Errors.UNBALANCED_STACK, "The stack is unbalanced. Not all the functions are nested correctly"); } return process.get(0); }
Example 4
Source File: Equation.java From WarpPI with Apache License 2.0 | 6 votes |
public ObjectArrayList<Equation> solveStep(final char charIncognita) { ObjectArrayList<Equation> result = new ObjectArrayList<>(); result.add(clone()); for (final SolveMethod t : SolveMethod.techniques) { final ObjectArrayList<Equation> newResults = new ObjectArrayList<>(); final int sz = result.size(); for (int n = 0; n < sz; n++) { newResults.addAll(t.solve(result.get(n))); } final Set<Equation> hs = new HashSet<>(); hs.addAll(newResults); newResults.clear(); newResults.addAll(hs); result = newResults; } // TODO: controllare se รจ a posto return result; }
Example 5
Source File: CoreNLPUtils.java From minie with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example 6
Source File: ImplicitExtractions.java From minie with GNU General Public License v3.0 | 5 votes |
/** Generate some extractions from TokenRegex patterns **/ public void generateSequentialPatternExtractions() { // Reusable variables ObjectArrayList<AnnotatedPhrase> tempProp = new ObjectArrayList<>(); IndexedWord subjRoot; IndexedWord objRoot; this.tPattern = TokenSequencePattern.compile(REGEX.T_ORG_IN_LOC); this.tMatcher = this.tPattern.getMatcher(CoreNLPUtils.getCoreLabelListFromIndexedWordList(this.sentence)); while (this.tMatcher.find()){ this.setIsARelation(); for (IndexedWord w: CoreNLPUtils.listOfCoreMapWordsToIndexedWordList(this.tMatcher.groupNodes())) { if (w.ner().equals(NE_TYPE.ORGANIZATION)) { this.subj.addWordToList(w); } else if (w.ner().equals(NE_TYPE.LOCATION)) { this.obj.addWordToList(w); } else if (w.ner().equals(NE_TYPE.NO_NER) && w.tag().equals(POS_TAG.IN)) { this.rel.addWordToList(w); } } subjRoot = CoreNLPUtils.getRootFromWordList(this.sentenceSemGraph, subj.getWordList()); objRoot = CoreNLPUtils.getRootFromWordList(this.sentenceSemGraph, obj.getWordList()); tempProp.add(new AnnotatedPhrase(this.subj.getWordList().clone(), subjRoot)); tempProp.add(new AnnotatedPhrase(this.rel.getWordList().clone(), this.rel.getRoot())); tempProp.add(new AnnotatedPhrase(this.obj.getWordList().clone(), objRoot)); this.propositions.add(new AnnotatedProposition(tempProp.clone(), new Attribution())); // Clean the variables tempProp.clear(); this.subj.clear(); this.rel.clear(); this.obj.clear(); } }
Example 7
Source File: Expression.java From WarpPI with Apache License 2.0 | 5 votes |
@Override public ObjectArrayList<Block> toBlock(final MathContext context) throws Error { final ObjectArrayList<Block> result = new ObjectArrayList<>(); final ObjectArrayList<Block> sub = getParameter(0).toBlock(context); final BlockParenthesis bp = new BlockParenthesis(); final BlockContainer bpc = bp.getNumberContainer(); for (final Block b : sub) { bpc.appendBlockUnsafe(b); } bpc.recomputeDimensions(); bp.recomputeDimensions(); result.add(bp); return result; }
Example 8
Source File: CoreNLPUtils.java From minie with GNU General Public License v3.0 | 5 votes |
private static ObjectArrayList<TypedDependency> getSubgraphTypedDependencies(SemanticGraph sg, IndexedWord parent, ObjectArrayList<TypedDependency> tds){ Set<IndexedWord> children = sg.getChildren(parent); for (IndexedWord child: children){ GrammaticalRelation gRel = sg.getEdge(parent, child).getRelation(); tds.add(new TypedDependency(gRel, parent, child)); if (sg.hasChildren(child)) getSubgraphTypedDependencies(sg, child, tds); } return tds; }
Example 9
Source File: CoreNLPUtils.java From minie with GNU General Public License v3.0 | 5 votes |
public static ObjectArrayList<CoreLabel> getCoreLabelListFromCoreMapList(ObjectArrayList<CoreMap> coreMapList){ ObjectArrayList<CoreLabel> coreLabelList = new ObjectArrayList<>(); for (CoreMap cm: coreMapList){ coreLabelList.add(new CoreLabel(cm)); } return coreLabelList; }
Example 10
Source File: MultiplicationMethod1.java From WarpPI with Apache License 2.0 | 5 votes |
private static ObjectArrayList<Function> getMultiplicationElements(Function mult) throws InterruptedException { final ObjectArrayList<Function> elements = new ObjectArrayList<>(); while (mult instanceof Multiplication) { if (Thread.interrupted()) { throw new InterruptedException(); } elements.add(((Multiplication) mult).getParameter1()); mult = ((Multiplication) mult).getParameter2(); } elements.add(mult); return elements; }
Example 11
Source File: ProcessConjunctions.java From minie with GNU General Public License v3.0 | 5 votes |
/** Generates a set of constituents from a CC for a given constituent */ private static ObjectArrayList<Constituent> generateConstituents(Clause clause, IndexedConstituent constituent, int index) { IndexedConstituent copy = constituent.clone(); copy.setSemanticGraph( copy.createReducedSemanticGraph() ); ObjectArrayList<Constituent> result = new ObjectArrayList<Constituent>(); result.add(copy); generateConstituents(copy.getSemanticGraph(), copy, copy.getRoot(), result, true); return result; }
Example 12
Source File: FunctionSingle.java From WarpPI with Apache License 2.0 | 5 votes |
@Override public final ObjectArrayList<Function> simplify(final Rule rule) throws Error, InterruptedException { final ObjectArrayList<Function> simplifiedParam = parameter.simplify(rule); if (simplifiedParam == null) { return rule.execute(this); } final ObjectArrayList<Function> result = new ObjectArrayList<>(); for (final Function f : simplifiedParam) { result.add(this.setParameter(f)); } return result; }
Example 13
Source File: RootSquare.java From WarpPI with Apache License 2.0 | 5 votes |
@Override public ObjectArrayList<Block> toBlock(final MathContext context) throws Error { final ObjectArrayList<Block> result = new ObjectArrayList<>(); final BlockSquareRoot bsqr = new BlockSquareRoot(); final BlockContainer bsqrc = bsqr.getNumberContainer(); for (final Block b : getParameter().toBlock(context)) { bsqrc.appendBlockUnsafe(b); } bsqrc.recomputeDimensions(); bsqr.recomputeDimensions(); result.add(bsqr); return result; }
Example 14
Source File: TaneAlgorithm.java From metanome-algorithms with Apache License 2.0 | 5 votes |
/** * Get all combinations, which can be built out of the elements of a prefix block * * @param list: List of BitSets, which are in the same prefix block. * @return All combinations of the BitSets. */ private ObjectArrayList<BitSet[]> getListCombinations(ObjectArrayList<BitSet> list) { ObjectArrayList<BitSet[]> combinations = new ObjectArrayList<BitSet[]>(); for (int a = 0; a < list.size(); a++) { for (int b = a + 1; b < list.size(); b++) { BitSet[] combi = new BitSet[2]; combi[0] = list.get(a); combi[1] = list.get(b); combinations.add(combi); } } return combinations; }
Example 15
Source File: MultiplicationMethod1.java From WarpPI with Apache License 2.0 | 5 votes |
public static ObjectArrayList<Function> execute(final Function f) throws Error, InterruptedException { Function result; final MathContext root = f.getMathContext(); final ObjectArrayList<Function> elements = MultiplicationMethod1.getMultiplicationElements(f); final int[] workingElementCouple = MultiplicationMethod1.getFirstWorkingMultiplicationCouple(elements); final Function elem1 = elements.get(workingElementCouple[0]); final Function elem2 = elements.get(workingElementCouple[1]); final int size = elements.size(); Function prec = new Multiplication(root, elem1, elem2); for (int i = size - 1; i >= 0; i--) { if (Thread.interrupted()) { throw new InterruptedException(); } if (i != workingElementCouple[0] & i != workingElementCouple[1]) { final Function a = prec; final Function b = elements.get(i); prec = new Multiplication(root, a, b); } } result = prec; final ObjectArrayList<Function> results = new ObjectArrayList<>(); results.add(result); return results; }
Example 16
Source File: MinIE.java From minie with GNU General Public License v3.0 | 5 votes |
/** * Given a ClausIE object, semantic graph object and a attribution, make new extractions from the object, * add them in the list of propositions and add the attribution as well. * * @param clausieObj: ClausIE object (reusable variable) * @param objSg: semantic graph object of the object * @param s: the attribution */ public void generatePropositionsWithAttribution(ClausIE clausieObj, SemanticGraph objSg, Attribution s){ // New clausie object clausieObj.clear(); clausieObj.setSemanticGraph(objSg); clausieObj.detectClauses(); clausieObj.generatePropositions(clausieObj.getSemanticGraph()); // Reusable variable for annotated phrases AnnotatedPhrase aPhrase = new AnnotatedPhrase(); for (Clause c: clausieObj.getClauses()){ for (Proposition p: c.getPropositions()){ // Add the proposition from ClausIE to the list of propositions of MinIE ObjectArrayList<AnnotatedPhrase> prop = new ObjectArrayList<AnnotatedPhrase>(); for (int i = 0; i < p.getConstituents().size(); i++){ aPhrase = new AnnotatedPhrase(p.getConstituents().get(i)); aPhrase.detectQuantities(this.sentenceSemGraph, i); aPhrase.annotateQuantities(i); prop.add(aPhrase); } if (this.pruneAnnotatedProposition(prop)) continue; AnnotatedProposition aProp = new AnnotatedProposition(prop, new Attribution(s)); this.pushWordsToRelation(aProp); this.propositions.add(aProp); this.propsWithAttribution.add(PhraseUtils.listOfAnnotatedPhrasesToString(prop)); } } }
Example 17
Source File: SumMethod1.java From WarpPI with Apache License 2.0 | 5 votes |
public static ObjectArrayList<Function> execute(final Function f) throws Error, InterruptedException { Function result; final MathContext root = f.getMathContext(); final ObjectArrayList<Function> elements = SumMethod1.getSumElements(f); final int[] workingElementCouple = SumMethod1.getFirstWorkingSumCouple(root, elements); final Function elem1 = elements.get(workingElementCouple[0]); final Function elem2 = elements.get(workingElementCouple[1]); final int size = elements.size(); Function prec = new Sum(root, elem1, elem2); for (int i = size - 1; i >= 0; i--) { if (i != workingElementCouple[0] & i != workingElementCouple[1]) { if (Thread.interrupted()) { throw new InterruptedException(); } final Function a = prec; final Function b = elements.get(i); if (b instanceof Negative) { prec = new Subtraction(root, a, ((Negative) b).getParameter()); ((FunctionOperator) prec).getParameter2(); } else if (b instanceof Number && ((Number) b).getTerm().compareTo(BigDecimal.ZERO) < 0) { prec = new Subtraction(root, a, ((Number) b).multiply(new Number(root, -1))); ((FunctionOperator) prec).getParameter2(); } else { prec = new Sum(root, a, b); } } } result = prec; final ObjectArrayList<Function> results = new ObjectArrayList<>(); results.add(result); return results; }
Example 18
Source File: HyFD.java From winter with Apache License 2.0 | 4 votes |
private ObjectArrayList<ColumnIdentifier> buildColumnIdentifiers() { ObjectArrayList<ColumnIdentifier> columnIdentifiers = new ObjectArrayList<ColumnIdentifier>(this.attributeNames.size()); for (String attributeName : this.attributeNames) columnIdentifiers.add(new ColumnIdentifier(this.tableName, attributeName)); return columnIdentifiers; }
Example 19
Source File: FunctionOperator.java From WarpPI with Apache License 2.0 | 4 votes |
@Override public final ObjectArrayList<Function> simplify(final Rule rule) throws Error, InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } final ObjectArrayList<Function> simplifiedParam1 = parameter1.simplify(rule); final ObjectArrayList<Function> simplifiedParam2 = parameter2.simplify(rule); try { if (simplifiedParam1 == null & simplifiedParam2 == null) { return rule.execute(this); } } catch (final Exception e) { final Error err = new Error(Errors.ERROR, "Error while executing rule '" + rule.getRuleName() + "'!\n" + e.getMessage()); err.initCause(e); throw err; } if (Thread.interrupted()) { throw new InterruptedException(); } final ObjectArrayList<Function> result = new ObjectArrayList<>(); final ObjectArrayList<Function> l1 = new ObjectArrayList<>(); final ObjectArrayList<Function> l2 = new ObjectArrayList<>(); if (Thread.interrupted()) { throw new InterruptedException(); } if (simplifiedParam1 == null) { l1.add(parameter1); } else { if (Thread.interrupted()) { throw new InterruptedException(); } l1.addAll(simplifiedParam1); } if (Thread.interrupted()) { throw new InterruptedException(); } if (simplifiedParam2 == null) { l2.add(parameter2); } else { if (Thread.interrupted()) { throw new InterruptedException(); } l2.addAll(simplifiedParam2); } final Function[][] results = Utils.joinFunctionsResults(l1, l2); for (final Function[] f : results) { result.add(setParameter1(f[0]).setParameter2(f[1])); } return result; }
Example 20
Source File: BlockParenthesisAbstract.java From WarpPI with Apache License 2.0 | 4 votes |
@Override public ObjectArrayList<BlockContainer> getInnerContainers() { ObjectArrayList<BlockContainer> output = new ObjectArrayList<>(); output.add(containerNumber); return output; }