Sha256: ce2ddf941b7e67de9e44745d327f1f87b2706e71eb640c9fa5d2a1535f385f67
Contents?: true
Size: 515 Bytes
Versions: 2
Compression:
Stored size: 515 Bytes
Contents
require "ruby-spacy" require "terminal-table" nlp = Spacy::Language.new("en_core_web_lg") matcher = nlp.matcher matcher.add("US_PRESIDENT", [[{LOWER: "barack"}, {LOWER: "obama"}]]) doc = nlp.read("Barack Obama was the 44th president of the United States") matches = matcher.match(doc) matches.each do |match| span = Spacy::Span.new(doc, start_index: match[:start_index], end_index: match[:end_index], options: {label: match[:match_id]}) puts span.text + " / " + span.label end # Barack Obama / US_PRESIDENT
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-spacy-0.1.4.1 | examples/rule_based_matching/creating_spans_from_matches.rb |
ruby-spacy-0.1.4 | examples/rule_based_matching/creating_spans_from_matches.rb |