'Concatenates the two spans in whichever way possible.  This
includes rightward concatenation (from the leftmost word of the
leftmost span to the rightmost word of the rightmost span) and
leftward concatenation (vice-versa) between adjacent spans.  Unlike
Eisner\'s presentation of span concatenation, these spans do not
share or pivot on a particular word/word-index.
:return: A list of new spans formed through concatenation.
:rtype: list(DependencySpan)'

def concatenate(self, span1, span2):

    spans = []
    if (span1._start_index == span2._start_index):
        print(u'Error:    Mismatched    spans    -    replace    this    with    thrown    error')
    if (span1._start_index > span2._start_index):
        temp_span = span1
        span1 = span2
        span2 = temp_span
    new_arcs = (span1._arcs + span2._arcs)
    new_tags = (span1._tags + span2._tags)
    if self._grammar.contains(self._tokens[span1._head_index], self._tokens[span2._head_index]):
        new_arcs[(span2._head_index - span1._start_index)] = span1._head_index
        spans.append(DependencySpan(span1._start_index, span2._end_index, span1._head_index, new_arcs, new_tags))
    new_arcs = (span1._arcs + span2._arcs)
    if self._grammar.contains(self._tokens[span2._head_index], self._tokens[span1._head_index]):
        new_arcs[(span1._head_index - span1._start_index)] = span2._head_index
        spans.append(DependencySpan(span1._start_index, span2._end_index, span2._head_index, new_arcs, new_tags))
    return spans
