Nasty.Lexical.WordNet.Relation (Nasty v0.3.0)

View Source

Represents a semantic relation between two WordNet synsets.

Relations define how synsets are connected semantically. Common relations include hypernymy (is-a), meronymy (part-of), antonymy (opposite), and many others.

Relation Types

Taxonomic Relations

  • :hypernym - More general concept (dog → canine)
  • :hyponym - More specific concept (canine → dog)
  • :instance_hypernym - Instance to class (Einstein → physicist)
  • :instance_hyponym - Class to instance (physicist → Einstein)

Part-Whole Relations

  • :meronym - Part-of (wheel → car)
  • :holonym - Whole-of (car → wheel)
  • :member_meronym - Member-of (player → team)
  • :member_holonym - Has-member (team → player)
  • :substance_meronym - Made-of (wood → tree)
  • :substance_holonym - Has-substance (tree → wood)

Similarity/Difference

  • :similar_to - Similar meaning (big → large)
  • :antonym - Opposite meaning (hot → cold)
  • :also_see - Related concept

Verb Relations

  • :entailment - Logical entailment (snore → sleep)
  • :cause - Causation (kill → die)
  • :verb_group - Semantically related verbs

Adjective Relations

  • :attribute - Noun attribute (heavy → weight)
  • :pertainym - Pertains to (atomic → atom)

Derivational Relations

  • :derivationally_related - Morphologically related words

Fields

  • type - Relation type (see above)
  • source_id - Source synset ID
  • target_id - Target synset ID

Example

%Relation{
  type: :hypernym,
  source_id: "oewn-02084071-n",  # dog
  target_id: "oewn-02083346-n"   # canine
}

Summary

Functions

Returns the inverse relation type if it exists.

Creates a new relation.

Checks if this is a symmetric relation (same in both directions).

Checks if this is a taxonomic relation (hypernym/hyponym).

Checks if a relation type is valid.

Types

relation_type()

@type relation_type() ::
  :hypernym
  | :hyponym
  | :instance_hypernym
  | :instance_hyponym
  | :meronym
  | :holonym
  | :member_meronym
  | :member_holonym
  | :substance_meronym
  | :substance_holonym
  | :similar_to
  | :antonym
  | :also_see
  | :entailment
  | :cause
  | :verb_group
  | :attribute
  | :pertainym
  | :derivationally_related

t()

@type t() :: %Nasty.Lexical.WordNet.Relation{
  source_id: String.t(),
  target_id: String.t(),
  type: relation_type()
}

Functions

inverse(type)

@spec inverse(relation_type()) :: {:ok, relation_type()} | {:error, :no_inverse}

Returns the inverse relation type if it exists.

Examples

iex> Relation.inverse(:hypernym)
{:ok, :hyponym}

iex> Relation.inverse(:antonym)
{:ok, :antonym}

iex> Relation.inverse(:also_see)
{:error, :no_inverse}

new(type, source_id, target_id)

@spec new(relation_type(), String.t(), String.t()) :: {:ok, t()} | {:error, term()}

Creates a new relation.

Examples

iex> Relation.new(:hypernym, "oewn-02084071-n", "oewn-02083346-n")
{:ok, %Relation{type: :hypernym, ...}}

symmetric?(type)

@spec symmetric?(relation_type()) :: boolean()

Checks if this is a symmetric relation (same in both directions).

taxonomic?(relation)

@spec taxonomic?(t()) :: boolean()

Checks if this is a taxonomic relation (hypernym/hyponym).

valid_type?(type)

@spec valid_type?(atom()) :: boolean()

Checks if a relation type is valid.