rb/lib/twitter-text/extractor.rb
# Remove overlapping entities.
# This returns a new array with no overlapping entities.
Remove overlapping entities.
This returns a new array with no overlapping entities.
Remove overlapping entities . This returns a new array with no overlapping entities .
def remove_overlapping_entities(entities)
        entities = entities.sort_by{|entity| entity[:indices].first}
        prev = nil
        entities.reject!{|entity| (prev && prev[:indices].last > entity[:indices].first) || (prev = entity) && false}
        entities
      end
def remove_overlapping_entities ( entities ) entities = entities . sort_by { | entity | entity [ :indices ] . first } prev = nil entities . reject! { | entity | ( prev && prev [ :indices ] . last > entity [ :indices ] . first ) || ( prev = entity ) && false } entities end
Remove overlapping entities.
Remove overlapping entities .
# sort by start index # remove duplicates
entities
<not_specific>