public Constituent getSiblingToLeft(int distance, Constituent c, TreeView parseView) { Constituent leftSibling = c; IQueryable<Constituent> siblings = parseView.where(Queries.isSiblingOf(c)); while (distance-- > 0) { Iterator<Constituent> leftSiblingIt = siblings.where(Queries.adjacentToBefore(leftSibling)).iterator(); if (leftSiblingIt.hasNext()) leftSibling = leftSiblingIt.next(); else return null; } return leftSibling; }
public Constituent getSiblingToRight(int distance, Constituent c, TreeView parseView) { Constituent rightSibling = c; IQueryable<Constituent> siblings = parseView.where(Queries.isSiblingOf(c)); while (distance-- > 0) { Iterator<Constituent> rightSiblingIt = siblings.where(Queries.adjacentToAfter(rightSibling)).iterator(); if (rightSiblingIt.hasNext()) rightSibling = rightSiblingIt.next(); else return null; } return rightSibling; }
public Constituent getSiblingToLeft(int distance, Constituent c, TreeView parseView) { Constituent leftSibling = c; IQueryable<Constituent> siblings = parseView.where(Queries.isSiblingOf(c)); while (distance-- > 0) { Iterator<Constituent> leftSiblingIt = siblings.where(Queries.adjacentToBefore(leftSibling)).iterator(); if (leftSiblingIt.hasNext()) leftSibling = leftSiblingIt.next(); else return null; } return leftSibling; }
public Constituent getSiblingToRight(int distance, Constituent c, TreeView parseView) { Constituent rightSibling = c; IQueryable<Constituent> siblings = parseView.where(Queries.isSiblingOf(c)); while (distance-- > 0) { Iterator<Constituent> rightSiblingIt = siblings.where(Queries.adjacentToAfter(rightSibling)).iterator(); if (rightSiblingIt.hasNext()) rightSibling = rightSiblingIt.next(); else return null; } return rightSibling; }
/** * * @return the list of commas that are children of the parent of the current comma, i.e. * siblings of the current comma. */ public List<Comma> getSiblingCommas() { TreeView parseView; if (GOLD) parseView = (TreeView) s.goldTa.getView(ViewNames.PARSE_GOLD); else parseView = (TreeView) s.ta.getView(CONSTITUENT_PARSER); List<Constituent> commaConstituents = new ArrayList<>(); Map<Constituent, Comma> constituentCommaMap = new HashMap<>(); for (Comma c : s.getCommas()) { Constituent commaConstituent = c.getCommaConstituentFromTree(parseView); commaConstituents.add(commaConstituent); constituentCommaMap.put(commaConstituent, c); } QueryableList<Constituent> qlCommas = new QueryableList<>(commaConstituents); Iterable<Constituent> siblingCommaConstituents = qlCommas.where(Queries.isSiblingOf(this.getCommaConstituentFromTree(parseView))); List<Comma> siblingCommas = new ArrayList<>(); for (Constituent commaConstituent : siblingCommaConstituents) siblingCommas.add(constituentCommaMap.get(commaConstituent)); return siblingCommas; }
/** * * @return the list of commas that are children of the parent of the current comma, i.e. * siblings of the current comma. */ public List<Comma> getSiblingCommas() { TreeView parseView; if (GOLD) parseView = (TreeView) s.goldTa.getView(ViewNames.PARSE_GOLD); else parseView = (TreeView) s.ta.getView(CONSTITUENT_PARSER); List<Constituent> commaConstituents = new ArrayList<>(); Map<Constituent, Comma> constituentCommaMap = new HashMap<>(); for (Comma c : s.getCommas()) { Constituent commaConstituent = c.getCommaConstituentFromTree(parseView); commaConstituents.add(commaConstituent); constituentCommaMap.put(commaConstituent, c); } QueryableList<Constituent> qlCommas = new QueryableList<>(commaConstituents); Iterable<Constituent> siblingCommaConstituents = qlCommas.where(Queries.isSiblingOf(this.getCommaConstituentFromTree(parseView))); List<Comma> siblingCommas = new ArrayList<>(); for (Constituent commaConstituent : siblingCommaConstituents) siblingCommas.add(constituentCommaMap.get(commaConstituent)); return siblingCommas; }