private void addSpansFromTags (LabeledSpans labeled, Tokenization input, Sequence tags, LabelAlphabet dict, Label backgroundTag) { int i = 0; LinkedList openTags = new LinkedList(); String[] lastTagSplit = new String [0]; while (i < tags.size()) { Label thisTag = dict.lookupLabel (tags.get(i).toString()); String[] thisTagSplit = splitTag (thisTag); int numToClose = compareSplitTags (thisTagSplit, lastTagSplit); // close all that need to be closed while (numToClose > 0) { TagStart tagStart = (TagStart) openTags.removeLast (); addLabeledSpan (labeled, input, tagStart, i, backgroundTag); numToClose--; } // open all that need to be opened for (int tidx = openTags.size (); tidx < thisTagSplit.length; tidx++) { openTags.add (new TagStart (i, dict.lookupLabel (thisTagSplit [tidx]))); } lastTagSplit = thisTagSplit; i++; } // Close all remaining tags while (!openTags.isEmpty ()) { TagStart tagStart = (TagStart) openTags.removeLast (); addLabeledSpan (labeled, input, tagStart, i, backgroundTag); } }
private void addSpansFromTags (LabeledSpans labeled, Tokenization input, Sequence tags, LabelAlphabet dict, Label backgroundTag) { int i = 0; LinkedList openTags = new LinkedList(); String[] lastTagSplit = new String [0]; while (i < tags.size()) { Label thisTag = dict.lookupLabel (tags.get(i).toString()); String[] thisTagSplit = splitTag (thisTag); int numToClose = compareSplitTags (thisTagSplit, lastTagSplit); // close all that need to be closed while (numToClose > 0) { TagStart tagStart = (TagStart) openTags.removeLast (); addLabeledSpan (labeled, input, tagStart, i, backgroundTag); numToClose--; } // open all that need to be opened for (int tidx = openTags.size (); tidx < thisTagSplit.length; tidx++) { openTags.add (new TagStart (i, dict.lookupLabel (thisTagSplit [tidx]))); } lastTagSplit = thisTagSplit; i++; } // Close all remaining tags while (!openTags.isEmpty ()) { TagStart tagStart = (TagStart) openTags.removeLast (); addLabeledSpan (labeled, input, tagStart, i, backgroundTag); } }
private void addSpansFromTags (LabeledSpans labeled, Tokenization input, Sequence tags, LabelAlphabet dict, Label backgroundTag) { int i = 0; LinkedList openTags = new LinkedList(); String[] lastTagSplit = new String [0]; while (i < tags.size()) { Label thisTag = dict.lookupLabel (tags.get(i).toString()); String[] thisTagSplit = splitTag (thisTag); int numToClose = compareSplitTags (thisTagSplit, lastTagSplit); // close all that need to be closed while (numToClose > 0) { TagStart tagStart = (TagStart) openTags.removeLast (); addLabeledSpan (labeled, input, tagStart, i, backgroundTag); numToClose--; } // open all that need to be opened for (int tidx = openTags.size (); tidx < thisTagSplit.length; tidx++) { openTags.add (new TagStart (i, dict.lookupLabel (thisTagSplit [tidx]))); } lastTagSplit = thisTagSplit; i++; } // Close all remaining tags while (!openTags.isEmpty ()) { TagStart tagStart = (TagStart) openTags.removeLast (); addLabeledSpan (labeled, input, tagStart, i, backgroundTag); } }