/** * Clones the right frontier of this root parse up to and including the specified node. * * @param node The last node in the right frontier of the parse tree which should be cloned. * @param parseIndex The child index of the parse for this root node. * @return A clone of this root parse and its right frontier up to and including the specified node. */ public Parse cloneRoot(Parse node, int parseIndex) { Parse c = (Parse) this.clone(); Parse fc = c.parts.get(parseIndex); c.parts.set(parseIndex,fc.clone(node)); return c; }
String tag = buildModel.getOutcome(max); if (!tag.equals(DONE)) { Parse newParse1 = (Parse) p.clone(); Parse newNode = new Parse(p.getText(),advanceNode.getSpan(),tag,bprob,advanceNode.getHead()); newParse1.insert(newNode); newParse1.addProb(Math.log(cprobs[completeIndex])); Parse newParse2 = (Parse) p.clone(); Parse newNode2 = new Parse(p.getText(),advanceNode.getSpan(),tag,bprob,advanceNode.getHead()); newParse2.insert(newNode2); Parse newParse1 = (Parse) p.clone(); //clone parse
/** * Clones the right frontier of parse up to the specified node. * * @param node The last node in the right frontier of the parse tree which should be cloned. * @return A clone of this parse and its right frontier up to and including the specified node. */ public Parse clone(Parse node) { if (this == node) { return (Parse) this.clone(); } else { Parse c = (Parse) this.clone(); Parse lc = c.parts.get(parts.size() - 1); c.parts.set(parts.size() - 1,lc.clone(node)); return c; } }
/** * Replaces the child at the specified index with a new child with the specified label. * * @param index The index of the child to be replaced. * @param label The label to be assigned to the new child. */ public void setChild(int index, String label) { Parse newChild = (Parse) (parts.get(index)).clone(); newChild.setLabel(label); parts.set(index,newChild); }
/** * Advances the parse by assigning it POS tags and returns multiple tag sequences. * @param p The parse to be tagged. * @return Parses with different POS-tag sequence assignments. */ protected Parse[] advanceTags(final Parse p) { Parse[] children = p.getChildren(); String[] words = new String[children.length]; double[] probs = new double[words.length]; for (int i = 0,il = children.length; i < il; i++) { words[i] = children[i].getCoveredText(); } Sequence[] ts = tagger.topKSequences(words); Parse[] newParses = new Parse[ts.length]; for (int i = 0; i < ts.length; i++) { String[] tags = ts[i].getOutcomes().toArray(new String[words.length]); ts[i].getProbs(probs); newParses[i] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[i].getDerivation().append(i).append("."); for (int j = 0; j < words.length; j++) { Parse word = children[j]; //System.err.println("inserting tag "+tags[j]); double prob = probs[j]; newParses[i].insert(new Parse(word.getText(), word.getSpan(), tags[j], prob,j)); newParses[i].addProb(Math.log(prob)); } } return newParses; }
currentChunks[ci] = (Parse) chunks[ci].clone(); currentChunks[ci].setPrevPunctuation(chunks[ci].getPreviousPunctuationSet()); currentChunks[ci].setNextPunctuation(chunks[ci].getNextPunctuationSet());
Parse[] newParses = new Parse[cs.length]; for (int si = 0, sl = cs.length; si < sl; si++) { newParses[si] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[si].getDerivation().append(si).append("."); String[] tags = cs[si].getOutcomes().toArray(new String[words.length]);
@Test public void testParseClone() { Parse p1 = Parse.parseParse(PARSE_STRING); Parse p2 = (Parse) p1.clone(); Assert.assertTrue(p1.equals(p2)); Assert.assertTrue(p2.equals(p1)); }
/** * Clones the right frontier of this root parse up to and including the specified node. * * @param node The last node in the right frontier of the parse tree which should be cloned. * @param parseIndex The child index of the parse for this root node. * @return A clone of this root parse and its right frontier up to and including the specified node. */ public Parse cloneRoot(Parse node, int parseIndex) { Parse c = (Parse) this.clone(); Parse fc = c.parts.get(parseIndex); c.parts.set(parseIndex,fc.clone(node)); return c; }
/** * Clones the right frontier of this root parse up to and including the specified node. * * @param node The last node in the right frontier of the parse tree which should be cloned. * @param parseIndex The child index of the parse for this root node. * @return A clone of this root parse and its right frontier up to and including the specified node. */ public Parse cloneRoot(Parse node, int parseIndex) { Parse c = (Parse) this.clone(); Parse fc = c.parts.get(parseIndex); c.parts.set(parseIndex,fc.clone(node)); return c; }
/** * Clones the right frontier of parse up to the specified node. * * @param node The last node in the right frontier of the parse tree which should be cloned. * @return A clone of this parse and its right frontier up to and including the specified node. */ public Parse clone(Parse node) { if (this == node) { return (Parse) this.clone(); } else { Parse c = (Parse) this.clone(); Parse lc = c.parts.get(parts.size() - 1); c.parts.set(parts.size() - 1,lc.clone(node)); return c; } }
/** * Clones the right frontier of parse up to the specified node. * * @param node The last node in the right frontier of the parse tree which should be cloned. * @return A clone of this parse and its right frontier up to and including the specified node. */ public Parse clone(Parse node) { if (this == node) { return (Parse) this.clone(); } else { Parse c = (Parse) this.clone(); Parse lc = c.parts.get(parts.size() - 1); c.parts.set(parts.size() - 1,lc.clone(node)); return c; } }
/** * Replaces the child at the specified index with a new child with the specified label. * * @param index The index of the child to be replaced. * @param label The label to be assigned to the new child. */ public void setChild(int index, String label) { Parse newChild = (Parse) (parts.get(index)).clone(); newChild.setLabel(label); parts.set(index,newChild); }
/** * Replaces the child at the specified index with a new child with the specified label. * * @param index The index of the child to be replaced. * @param label The label to be assigned to the new child. */ public void setChild(int index, String label) { Parse newChild = (Parse) (parts.get(index)).clone(); newChild.setLabel(label); parts.set(index,newChild); }
/** * Advances the parse by assigning it POS tags and returns multiple tag sequences. * @param p The parse to be tagged. * @return Parses with different POS-tag sequence assignments. */ protected Parse[] advanceTags(final Parse p) { Parse[] children = p.getChildren(); String[] words = new String[children.length]; double[] probs = new double[words.length]; for (int i = 0,il = children.length; i < il; i++) { words[i] = children[i].getCoveredText(); } Sequence[] ts = tagger.topKSequences(words); Parse[] newParses = new Parse[ts.length]; for (int i = 0; i < ts.length; i++) { String[] tags = ts[i].getOutcomes().toArray(new String[words.length]); ts[i].getProbs(probs); newParses[i] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[i].getDerivation().append(i).append("."); for (int j = 0; j < words.length; j++) { Parse word = children[j]; //System.err.println("inserting tag "+tags[j]); double prob = probs[j]; newParses[i].insert(new Parse(word.getText(), word.getSpan(), tags[j], prob,j)); newParses[i].addProb(Math.log(prob)); } } return newParses; }
/** * Advances the parse by assigning it POS tags and returns multiple tag sequences. * @param p The parse to be tagged. * @return Parses with different POS-tag sequence assignments. */ protected Parse[] advanceTags(final Parse p) { Parse[] children = p.getChildren(); String[] words = new String[children.length]; double[] probs = new double[words.length]; for (int i = 0,il = children.length; i < il; i++) { words[i] = children[i].getCoveredText(); } Sequence[] ts = tagger.topKSequences(words); Parse[] newParses = new Parse[ts.length]; for (int i = 0; i < ts.length; i++) { String[] tags = ts[i].getOutcomes().toArray(new String[words.length]); ts[i].getProbs(probs); newParses[i] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[i].getDerivation().append(i).append("."); for (int j = 0; j < words.length; j++) { Parse word = children[j]; //System.err.println("inserting tag "+tags[j]); double prob = probs[j]; newParses[i].insert(new Parse(word.getText(), word.getSpan(), tags[j], prob,j)); newParses[i].addProb(Math.log(prob)); } } return newParses; }
Parse[] newParses = new Parse[cs.length]; for (int si = 0, sl = cs.length; si < sl; si++) { newParses[si] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[si].getDerivation().append(si).append("."); String[] tags = cs[si].getOutcomes().toArray(new String[words.length]);
Parse[] newParses = new Parse[cs.length]; for (int si = 0, sl = cs.length; si < sl; si++) { newParses[si] = (Parse) p.clone(); //copies top level if (createDerivationString) newParses[si].getDerivation().append(si).append("."); String[] tags = cs[si].getOutcomes().toArray(new String[words.length]);