Class: FactDb::Resolution::ResolvedEntity

Inherits:
Object
  • Object
show all
Defined in:
lib/fact_db/resolution/entity_resolver.rb

Overview

Represents a resolved entity with confidence metadata

Wraps an entity with information about how it was resolved and the confidence level of the match.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, confidence:, match_type:) ⇒ ResolvedEntity

Initializes a new ResolvedEntity

Parameters:

  • entity (FactDb::Models::Entity)

    the resolved entity

  • confidence (Float)

    confidence score (0.0 to 1.0)

  • match_type (Symbol)

    match type (:exact_alias, :name, :fuzzy)



319
320
321
322
323
# File 'lib/fact_db/resolution/entity_resolver.rb', line 319

def initialize(entity, confidence:, match_type:)
  @entity = entity
  @confidence = confidence
  @match_type = match_type
end

Instance Attribute Details

#confidenceFloat (readonly)

Returns confidence score from 0.0 to 1.0.

Returns:

  • (Float)

    confidence score from 0.0 to 1.0



309
310
311
# File 'lib/fact_db/resolution/entity_resolver.rb', line 309

def confidence
  @confidence
end

#entityFactDb::Models::Entity (readonly)

Returns the resolved entity.

Returns:



306
307
308
# File 'lib/fact_db/resolution/entity_resolver.rb', line 306

def entity
  @entity
end

#match_typeSymbol (readonly)

Returns how the entity was matched (:exact_alias, :name, :fuzzy).

Returns:

  • (Symbol)

    how the entity was matched (:exact_alias, :name, :fuzzy)



312
313
314
# File 'lib/fact_db/resolution/entity_resolver.rb', line 312

def match_type
  @match_type
end

Instance Method Details

#exact_match?Boolean

Checks if this was an exact match (confidence == 1.0)

Returns:

  • (Boolean)

    true if confidence is 1.0



328
329
330
# File 'lib/fact_db/resolution/entity_resolver.rb', line 328

def exact_match?
  confidence == 1.0
end

#fuzzy_match?Boolean

Checks if this was a fuzzy match

Returns:

  • (Boolean)

    true if match_type is :fuzzy



335
336
337
# File 'lib/fact_db/resolution/entity_resolver.rb', line 335

def fuzzy_match?
  match_type == :fuzzy
end

#idInteger

Returns the entity ID

Returns:

  • (Integer)

    the entity’s database ID



342
343
344
# File 'lib/fact_db/resolution/entity_resolver.rb', line 342

def id
  entity.id
end

#kindString

Returns the entity kind

Returns:

  • (String)

    the entity’s kind



356
357
358
# File 'lib/fact_db/resolution/entity_resolver.rb', line 356

def kind
  entity.kind
end

#nameString

Returns the entity name

Returns:

  • (String)

    the entity’s canonical name



349
350
351
# File 'lib/fact_db/resolution/entity_resolver.rb', line 349

def name
  entity.name
end