Class: Spandx::Core::Content
- Inherits:
-
Object
- Object
- Spandx::Core::Content
- Defined in:
- lib/spandx/core/content.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(raw) ⇒ Content
constructor
A new instance of Content.
- #similar?(other, threshold: 89.0) ⇒ Boolean
- #similarity_score(other) ⇒ Object
- #tokens ⇒ Object
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
#raw ⇒ Object (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
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 |
#tokens ⇒ Object
12 13 14 |
# File 'lib/spandx/core/content.rb', line 12 def tokens @tokens ||= tokenize(canonicalize(raw)).to_set end |