lib/proiel/cli/converters/conll-u.rb
# TODO: this will leave several root nodes in many cases. For now, raise an error
this will leave several root nodes in many cases. For now, raise an error
this will leave several root nodes in many cases . For now raise an error
def prune_empty_rootnodes!
        unless (empty_roots = roots.select { |r| r.empty_token_sort == 'V' }).empty?
          empty_roots.each do |r|
            new_root = r.dependents.first
            new_root.head_id = 0
            new_root.relation = r.relation
            r.dependents.each { |d| d.head_id = new_root.id }
            remove_token! r
          end
          prune_empty_rootnodes!
        end
      end
def prune_empty_rootnodes! unless ( empty_roots = roots . select { | r | r . empty_token_sort == 'V' } ) . empty? empty_roots . each do | r | new_root = r . dependents . first new_root . head_id = 0 new_root . relation = r . relation r . dependents . each { | d | d . head_id = new_root . id } remove_token! r end prune_empty_rootnodes! end end
TODO: this will leave several root nodes in many cases.
TODO : this will leave several root nodes in many cases .
# promote the first dependent to root