Sha256: d2057d4a7ba644c9aaf24886278f77ad7ec76b67c59cb3ea669be7509dd0f380
Contents?: true
Size: 988 Bytes
Versions: 11
Compression:
Stored size: 988 Bytes
Contents
require 'rbbt/segment/named_entity' require 'rbbt/relationship' module Brat Rbbt.claim Rbbt.software.opt.Brat, :install, "https://github.com/nlplab/brat.git" def self.load(file) entities = {} relationships = {} entity_ids = {} TSV.traverse file, :type => :array do |line| id, info, literal = line.split("\t") case id[0] when "T" type, start, eend = info.split(" ") entities[id] = NamedEntity.setup(literal, :offset => start.to_i, :type => type) when "#" type, id = info.split(" ") entities[id].code = literal unless entities[id].nil? when "R" type, *args = info.split(" ") tf, tg = args.collect{|e| e.split(":").last } tf = entities[tf] tg = entities[tg] relationship = Relationship.setup([tf,tg] * "~" + "#" + type, :terms => [tf,tg], :type => type) relationships[id] = relationship end end [entities.values, relationships.values] end end
Version data entries
11 entries across 11 versions & 1 rubygems