Nasty.AST.Semantic.Entity (Nasty v0.3.0)

View Source

Entity node representing a named entity (person, organization, location, etc.).

Named Entity Recognition (NER) identifies and classifies entities mentioned in text.

Summary

Types

Entity type classification following common NER standards.

t()

Functions

Returns all supported entity types.

Types

entity_type()

@type entity_type() ::
  :person
  | :org
  | :loc
  | :gpe
  | :date
  | :time
  | :money
  | :percent
  | :quantity
  | :event
  | :product
  | :language
  | :misc

Entity type classification following common NER standards.

People & Organizations

  • :person - Individual person ("Barack Obama")
  • :org - Organization ("Apple Inc.", "United Nations")

Locations

  • :loc - Physical location ("Paris", "Mount Everest")
  • :gpe - Geopolitical entity ("France", "California")

Temporal

  • :date - Specific date ("January 5, 2026")
  • :time - Time of day ("3:00 PM")

Numerical

  • :money - Monetary value ("$100", "€50")
  • :percent - Percentage ("25%")
  • :quantity - Measurement ("5 kg", "10 meters")

Other

  • :event - Named event ("World War II", "Olympics")
  • :product - Product or service ("iPhone", "Windows")
  • :language - Language name ("English", "Spanish")
  • :misc - Miscellaneous entities

t()

@type t() :: %Nasty.AST.Semantic.Entity{
  canonical_form: String.t() | nil,
  confidence: float() | nil,
  span: Nasty.AST.Node.span(),
  text: String.t(),
  tokens: [Nasty.AST.Token.t()],
  type: entity_type()
}

Functions

entity_types()

@spec entity_types() :: [entity_type()]

Returns all supported entity types.

new(type, text, tokens, span, opts \\ [])

Creates a new entity.

Examples

iex> tokens = [%Token{text: "John", ...}]
iex> span = Node.make_span({1, 0}, 0, {1, 4}, 4)
iex> Entity.new(:person, "John", tokens, span)
%Entity{type: :person, text: "John", ...}