Class: Spandx::Core::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/spandx/core/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Content

Returns a new instance of Content.



8
9
10
# File 'lib/spandx/core/content.rb', line 8

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/spandx/core/content.rb', line 6

def raw
  @raw
end

Instance Method Details

#similar?(other, threshold: 89.0) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/spandx/core/content.rb', line 16

def similar?(other, threshold: 89.0)
  similarity_score(other) > threshold
end

#similarity_score(other) ⇒ Object



20
21
22
# File 'lib/spandx/core/content.rb', line 20

def similarity_score(other)
  dice_coefficient(other)
end

#tokensObject



12
13
14
# File 'lib/spandx/core/content.rb', line 12

def tokens
  @tokens ||= tokenize(canonicalize(raw)).to_set
end