public boolean addAll(TwoDimensionalSet<? extends K1, ? extends K2> set) { boolean result = false; for (Pair<? extends K1, ? extends K2> pair : set) { if (add(pair.first, pair.second)) { result = true; } } return result; }
public void addIncompatible(Mention m1, Mention m2) { int mid1 = Math.min(m1.mentionID, m2.mentionID); int mid2 = Math.max(m1.mentionID, m2.mentionID); incompatibles.add(mid1,mid2); int cid1 = Math.min(m1.corefClusterID, m2.corefClusterID); int cid2 = Math.max(m1.corefClusterID, m2.corefClusterID); incompatibleClusters.add(cid1,cid2); }
/** * Adds all the keys in the given TwoDimensionalMap. Returns true iff at least one key is added. */ public boolean addAllKeys(TwoDimensionalMap<? extends K1, ? extends K2, ?> map) { boolean result = false; for (TwoDimensionalMap.Entry<? extends K1, ? extends K2, ?> entry : map) { if (add(entry.getFirstKey(), entry.getSecondKey())) { result = true; } } return result; }
public static TwoDimensionalSet<String, String> getBinaryMatrixNames(List<TwoDimensionalMap<String, String, SimpleMatrix>> maps) { TwoDimensionalSet<String, String> matrixNames = new TwoDimensionalSet<>(); for (TwoDimensionalMap<String, String, SimpleMatrix> map : maps) { for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> entry : map) { matrixNames.add(entry.getFirstKey(), entry.getSecondKey()); } } return matrixNames; }
public void mergeIncompatibles(CorefCluster to, CorefCluster from) { List<Pair<Pair<Integer,Integer>, Pair<Integer,Integer>>> replacements = new ArrayList<>(); for (Pair<Integer, Integer> p : incompatibleClusters) { Integer other = null; if (p.first == from.clusterID) { other = p.second; } else if (p.second == from.clusterID) { other = p.first; } if (other != null && other != to.clusterID) { int cid1 = Math.min(other, to.clusterID); int cid2 = Math.max(other, to.clusterID); replacements.add(Pair.makePair(p, Pair.makePair(cid1, cid2))); } } for (Pair<Pair<Integer,Integer>, Pair<Integer,Integer>> r:replacements) { incompatibleClusters.remove(r.first.first(), r.first.second()); incompatibleClusters.add(r.second.first(), r.second.second()); } }
public void mergeAcronymCache(CorefCluster to, CorefCluster from) { TwoDimensionalSet<Integer, Integer> replacements = TwoDimensionalSet.hashSet(); for (Integer first : acronymCache.firstKeySet()) { for (Integer second : acronymCache.get(first).keySet()) { if (acronymCache.get(first, second)) { Integer other = null; if (first == from.clusterID) { other = second; } else if (second == from.clusterID) { other = first; } if (other != null && other != to.clusterID) { int cid1 = Math.min(other, to.clusterID); int cid2 = Math.max(other, to.clusterID); replacements.add(cid1, cid2); } } } } for (Integer first : replacements.firstKeySet()) { for (Integer second : replacements.secondKeySet(first)) { acronymCache.put(first, second, true); } } }
private void searchRulesForBatch(TwoDimensionalSet<String, String> binaryRules, Set<String> unaryRules, Set<String> words, Tree tree) { if (tree.isLeaf()) { return; } if (tree.isPreTerminal()) { words.add(getVocabWord(tree.children()[0].value())); return; } Tree[] children = tree.children(); if (children.length == 1) { unaryRules.add(basicCategory(children[0].value())); searchRulesForBatch(binaryRules, unaryRules, words, children[0]); } else if (children.length == 2) { binaryRules.add(basicCategory(children[0].value()), basicCategory(children[1].value())); searchRulesForBatch(binaryRules, unaryRules, words, children[0]); searchRulesForBatch(binaryRules, unaryRules, words, children[1]); } else { throw new AssertionError("Expected a binarized tree"); } }
binaryProductions.add("", ""); } else {
String rightBasic = op.langpack().basicCategory(rightState); binaryRules.add(leftBasic, rightBasic);
public boolean addAll(TwoDimensionalSet<? extends K1, ? extends K2> set) { boolean result = false; for (Pair<? extends K1, ? extends K2> pair : set) { if (add(pair.first, pair.second)) { result = true; } } return result; }
public boolean addAll(TwoDimensionalSet<? extends K1, ? extends K2> set) { boolean result = false; for (Pair<? extends K1, ? extends K2> pair : set) { if (add(pair.first, pair.second)) { result = true; } } return result; }
public boolean addAll(TwoDimensionalSet<? extends K1, ? extends K2> set) { boolean result = false; for (Pair<? extends K1, ? extends K2> pair : set) { if (add(pair.first, pair.second)) { result = true; } } return result; }
public void addIncompatible(Mention m1, Mention m2) { int mid1 = Math.min(m1.mentionID, m2.mentionID); int mid2 = Math.max(m1.mentionID, m2.mentionID); incompatibles.add(mid1,mid2); int cid1 = Math.min(m1.corefClusterID, m2.corefClusterID); int cid2 = Math.max(m1.corefClusterID, m2.corefClusterID); incompatibleClusters.add(cid1,cid2); }
public void addIncompatible(Mention m1, Mention m2) { int mid1 = Math.min(m1.mentionID, m2.mentionID); int mid2 = Math.max(m1.mentionID, m2.mentionID); incompatibles.add(mid1,mid2); int cid1 = Math.min(m1.corefClusterID, m2.corefClusterID); int cid2 = Math.max(m1.corefClusterID, m2.corefClusterID); incompatibleClusters.add(cid1,cid2); }
/** * Adds all the keys in the given TwoDimensionalMap. Returns true iff at least one key is added. */ public boolean addAllKeys(TwoDimensionalMap<? extends K1, ? extends K2, ?> map) { boolean result = false; for (TwoDimensionalMap.Entry<? extends K1, ? extends K2, ?> entry : map) { if (add(entry.getFirstKey(), entry.getSecondKey())) { result = true; } } return result; }
/** * Adds all the keys in the given TwoDimensionalMap. Returns true iff at least one key is added. */ public boolean addAllKeys(TwoDimensionalMap<? extends K1, ? extends K2, ?> map) { boolean result = false; for (TwoDimensionalMap.Entry<? extends K1, ? extends K2, ?> entry : map) { if (add(entry.getFirstKey(), entry.getSecondKey())) { result = true; } } return result; }
/** * Adds all the keys in the given TwoDimensionalMap. Returns true iff at least one key is added. */ public boolean addAllKeys(TwoDimensionalMap<? extends K1, ? extends K2, ?> map) { boolean result = false; for (TwoDimensionalMap.Entry<? extends K1, ? extends K2, ?> entry : map) { if (add(entry.getFirstKey(), entry.getSecondKey())) { result = true; } } return result; }
public void mergeIncompatibles(CorefCluster to, CorefCluster from) { List<Pair<Pair<Integer,Integer>, Pair<Integer,Integer>>> replacements = new ArrayList<>(); for (Pair<Integer, Integer> p : incompatibleClusters) { Integer other = null; if (p.first == from.clusterID) { other = p.second; } else if (p.second == from.clusterID) { other = p.first; } if (other != null && other != to.clusterID) { int cid1 = Math.min(other, to.clusterID); int cid2 = Math.max(other, to.clusterID); replacements.add(Pair.makePair(p, Pair.makePair(cid1, cid2))); } } for (Pair<Pair<Integer,Integer>, Pair<Integer,Integer>> r:replacements) { incompatibleClusters.remove(r.first.first(), r.first.second()); incompatibleClusters.add(r.second.first(), r.second.second()); } }
public void mergeIncompatibles(CorefCluster to, CorefCluster from) { List<Pair<Pair<Integer,Integer>, Pair<Integer,Integer>>> replacements = new ArrayList<Pair<Pair<Integer,Integer>, Pair<Integer,Integer>>>(); for (Pair<Integer, Integer> p : incompatibleClusters) { Integer other = null; if (p.first == from.clusterID) { other = p.second; } else if (p.second == from.clusterID) { other = p.first; } if (other != null && other != to.clusterID) { int cid1 = Math.min(other, to.clusterID); int cid2 = Math.max(other, to.clusterID); replacements.add(Pair.makePair(p, Pair.makePair(cid1, cid2))); } } for (Pair<Pair<Integer,Integer>, Pair<Integer,Integer>> r:replacements) { incompatibleClusters.remove(r.first.first(), r.first.second()); incompatibleClusters.add(r.second.first(), r.second.second()); } }
private void searchRulesForBatch(TwoDimensionalSet<String, String> binaryRules, Set<String> unaryRules, Set<String> words, Tree tree) { if (tree.isLeaf()) { return; } if (tree.isPreTerminal()) { words.add(getVocabWord(tree.children()[0].value())); return; } Tree[] children = tree.children(); if (children.length == 1) { unaryRules.add(basicCategory(children[0].value())); searchRulesForBatch(binaryRules, unaryRules, words, children[0]); } else if (children.length == 2) { binaryRules.add(basicCategory(children[0].value()), basicCategory(children[1].value())); searchRulesForBatch(binaryRules, unaryRules, words, children[0]); searchRulesForBatch(binaryRules, unaryRules, words, children[1]); } else { throw new AssertionError("Expected a binarized tree"); } }