rbbt-text 1.5.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80e662635b01507c60638565bb8f00f789b4e6423227b98cee0ac38d8dd4b344
4
- data.tar.gz: 6b9a1be5fdea2bb56a770ca2fe6838528102dfe2d15f27abb5f0e5b1849e6574
3
+ metadata.gz: fe1271c362c3e5f912d1d2236587dfd3f5202c8bef0246b547f3d109d3a321b5
4
+ data.tar.gz: abbd7559a60012f910a7d5c528484bf10950109772c6fd81cffba85efc0541bd
5
5
  SHA512:
6
- metadata.gz: 383affa64fa2b1e6d54817e343b3710d134c01d68867699490c604258324a6806bd829492873e819a5666780e0282ab1a375ae03147691aa64ef78705d7d0097
7
- data.tar.gz: 67a52fca24335775faacf2a68cd101b24ff19d0fbff9560b4468c61546cee62aa02cdf8c5a1d3db39e5784856bd4df4573c9a00f901e8ca368cf169f8a88101d
6
+ metadata.gz: bf1b61c0464eb675861694e21c597f0770b37b241e72008225d49e826ddeb93877c50ceaa63b5a05daee1274d9ce3b433308d32ff71fe9455e14af1c55ac7eca
7
+ data.tar.gz: 532381c12fc4886b2c178252c1a5d2df6cd45921e1725a8dc1a45f4325044710822ab67fe431e361bb7b14159d92058deeb7257c52f0f86e94fd88f851669933
@@ -3,8 +3,8 @@ require 'rbbt/segment/annotation'
3
3
 
4
4
  module Document
5
5
  def self.define(type, &block)
6
- send :property, type do
7
- segments = self.instance_exec &block
6
+ send :property, type do |*args,**kwargs|
7
+ segments = self.instance_exec *args, **kwargs, &block
8
8
 
9
9
  Segment.align(self, segments) unless segments.empty? ||
10
10
  (Segment === segments && segments.offset) ||
@@ -53,6 +53,7 @@ module Document
53
53
 
54
54
  def self.define_multiple(type, &block)
55
55
  send :property, type => :multiple do |list|
56
+ list = self if Array === self
56
57
  doc_segments = self.instance_exec list, &block
57
58
 
58
59
  doc_segments = doc_segments.chunked_values_at(list) if Hash === doc_segments
@@ -1,4 +1,5 @@
1
1
  require 'rbbt-util'
2
+ require 'rbbt/tsv'
2
3
 
3
4
  module Document::Corpus
4
5
 
@@ -12,7 +13,9 @@ module Document::Corpus
12
13
 
13
14
  def add_document(document)
14
15
  docid = document.docid
15
- return self[docid] if self.include?(docid)
16
+ self.read_and_close do
17
+ return self[docid] if self.include?(docid)
18
+ end
16
19
  self.write_and_close do
17
20
  self[docid] = document
18
21
  end
@@ -34,7 +37,7 @@ module Document::Corpus
34
37
  def [](*args)
35
38
  docid, *rest = args
36
39
 
37
- res = self.with_read do
40
+ res = self.read_and_close do
38
41
  super(*args)
39
42
  end
40
43
 
data/lib/rbbt/document.rb CHANGED
@@ -41,7 +41,7 @@ module Document
41
41
  extend Entity
42
42
  self.annotation :namespace, :code, :type, :corpus
43
43
 
44
- property :docid do |corpus=nil|
44
+ def docid(corpus=nil)
45
45
  digest = Misc.digest(self)
46
46
  corpus = self.corpus if corpus.nil?
47
47
 
@@ -1,4 +1,3 @@
1
-
2
1
  require 'rbbt/segment'
3
2
  require 'rbbt/segment/named_entity'
4
3
  require 'rbbt/segment/transformed'
@@ -266,8 +266,8 @@ class TokenTrieNER < NER
266
266
  file = [] if file.nil?
267
267
  file = [file] unless Array === file
268
268
  persist_options = Misc.pull_keys options, :persist
269
- @index = Persist.persist_tsv(file, options, persist_options) do |data|
270
- data.serializer = :marshal if data.respond_to? :serializer and data.serializer == :type
269
+ @index = Persist.persist_tsv(file, nil, options, persist_options) do |data|
270
+ data.serializer = :marshal if data.respond_to?(:serializer) and (data.serializer == :type || data.serializer.nil?)
271
271
 
272
272
  @index = data
273
273
  file.each do |f|
@@ -282,7 +282,7 @@ class TokenTrieNER < NER
282
282
  case
283
283
  when TokenTrieNER === new
284
284
  Log.debug "TokenTrieNER merging other TokenTrieNER"
285
- TokenTrieNER.merge(@index, new.index)
285
+ TokenTrieNER.merge(@index, new.index)
286
286
  when TSV === new
287
287
  Log.debug "TokenTrieNER merging TSV"
288
288
  new.with_unnamed do
@@ -36,7 +36,7 @@ module SegmentAnnotation
36
36
  include Object::Segment
37
37
  self.annotation :type
38
38
 
39
- property :segid do
39
+ def segid
40
40
  case self
41
41
  when SegID
42
42
  self
@@ -12,7 +12,7 @@ class TestPubtator < Test::Unit::TestCase
12
12
  end
13
13
  end
14
14
 
15
- def _test_align
15
+ def test_align
16
16
  pmids = "19522013|20861254|38267746".split("|")
17
17
  alignments = {}
18
18
  with_corpus do |corpus|
@@ -47,7 +47,7 @@ class TestPubtator < Test::Unit::TestCase
47
47
  end
48
48
  end
49
49
 
50
- def _test_greek
50
+ def test_greek
51
51
 
52
52
  pmids = "20861254".split("|")
53
53
  alignments = {}
@@ -45,7 +45,7 @@ S000000376 AAA GENE1 DDD
45
45
  end
46
46
 
47
47
  def test_token_evaluate
48
- iii @norm.token_evaluate("PDGFRA","PDGFRalpha")
48
+ assert @norm.token_evaluate("PDGFRA","PDGFRalpha") > 0
49
49
  end
50
50
 
51
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-text
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-28 00:00:00.000000000 Z
11
+ date: 2024-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.5.0.dev
182
+ rubygems_version: 3.5.10
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: Text mining tools for the Ruby Bioinformatics Toolkit (rbbt)