Class: FactDb::Models::EntityMention
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- FactDb::Models::EntityMention
- Defined in:
- lib/fact_db/models/entity_mention.rb
Overview
Join model linking entities to facts with role information
Represents how an entity is mentioned in a specific fact, including the exact text used and the semantic role (subject, object, etc.).
Constant Summary collapse
- ROLES =
Returns valid mention roles.
%w[subject object location temporal instrument beneficiary].freeze
Instance Method Summary collapse
-
#by_role(role) ⇒ ActiveRecord::Relation
Returns mentions with a specific role.
-
#high_confidence ⇒ ActiveRecord::Relation
Returns mentions with confidence >= 0.9.
-
#object? ⇒ Boolean
Checks if this mention has the object role.
-
#objects ⇒ ActiveRecord::Relation
Returns mentions with object role.
-
#subject? ⇒ Boolean
Checks if this mention has the subject role.
-
#subjects ⇒ ActiveRecord::Relation
Returns mentions with subject role.
Instance Method Details
#by_role(role) ⇒ ActiveRecord::Relation
Returns mentions with a specific role
34 |
# File 'lib/fact_db/models/entity_mention.rb', line 34 scope :by_role, ->(role) { where(mention_role: role) } |
#high_confidence ⇒ ActiveRecord::Relation
Returns mentions with confidence >= 0.9
49 |
# File 'lib/fact_db/models/entity_mention.rb', line 49 scope :high_confidence, -> { where("confidence >= ?", 0.9) } |
#object? ⇒ Boolean
Checks if this mention has the object role
61 62 63 |
# File 'lib/fact_db/models/entity_mention.rb', line 61 def object? mention_role == "object" end |
#objects ⇒ ActiveRecord::Relation
Returns mentions with object role
44 |
# File 'lib/fact_db/models/entity_mention.rb', line 44 scope :objects, -> { by_role("object") } |
#subject? ⇒ Boolean
Checks if this mention has the subject role
54 55 56 |
# File 'lib/fact_db/models/entity_mention.rb', line 54 def subject? mention_role == "subject" end |
#subjects ⇒ ActiveRecord::Relation
Returns mentions with subject role
39 |
# File 'lib/fact_db/models/entity_mention.rb', line 39 scope :subjects, -> { by_role("subject") } |