code: public static void addNames(final String tag, final Span[] names,
        final Parse[] tokens) {
      for (final Span nameTokenSpan : names) {
        final Parse startToken = tokens[nameTokenSpan.getStart()];
        final Parse endToken = tokens[nameTokenSpan.getEnd() - 1];
        final Parse commonParent = startToken.getCommonParent(endToken);
        // System.err.println("addNames: "+startToken+" .. "+endToken+"
        // commonParent = "+commonParent);
        if (commonParent != null) {
          final Span nameSpan = new Span(startToken.getSpan().getStart(),
              endToken.getSpan().getEnd());
          if (nameSpan.equals(commonParent.getSpan())) {
            commonParent.insert(new Parse(commonParent.getText(), nameSpan, tag,
                1.0, endToken.getHeadIndex()));
          } else {
            final Parse[] kids = commonParent.getChildren();
            boolean crossingKids = false;
            for (final Parse kid : kids) {
              if (nameSpan.crosses(kid.getSpan())) {
                crossingKids = true;
              }
            }
            if (!crossingKids) {
              commonParent.insert(new Parse(commonParent.getText(), nameSpan, tag,
                  1.0, endToken.getHeadIndex()));
            } else {
              if (commonParent.getType().equals("NP")) {
                final Parse[] grandKids = kids[0].getChildren();
                if (grandKids.length > 1 && nameSpan
                    .contains(grandKids[grandKids.length - 1].getSpan())) {
                  commonParent.insert(
                      new Parse(commonParent.getText(), commonParent.getSpan(),
                          tag, 1.0, commonParent.getHeadIndex()));
                }
              }
            }
          }
        }
      }
    }
docs: Utility method to inserts named entities.
  
  @param tag
  the tags
  @param names
  the spans
  @param tokens
  the tokens