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

View Source

Represents a WordNet lemma - a word form with a specific sense in a synset.

A lemma is a specific word form that belongs to a synset. The same word can have multiple lemmas if it appears in different synsets (different senses). Lemmas connect the lexical level (words) to the semantic level (synsets/meanings).

Fields

  • word - The word form/text (e.g., "dog", "run")
  • pos - Part of speech tag
  • synset_id - ID of the synset this lemma belongs to
  • sense_key - Unique identifier for this word-sense pair
  • frequency - Usage frequency (higher = more common), optional
  • language - Language code

Example

%Lemma{
  word: "dog",
  pos: :noun,
  synset_id: "oewn-02084071-n",
  sense_key: "dog%1:05:00::",
  frequency: 10,
  language: :en
}

Summary

Functions

Checks if lemma matches a word and optional POS.

Returns a normalized version of the word for matching.

Checks if two lemmas are for the same word (case-insensitive).

Types

t()

@type t() :: %Nasty.Lexical.WordNet.Lemma{
  frequency: integer() | nil,
  language: Nasty.Lexical.WordNet.Synset.language_code(),
  pos: Nasty.Lexical.WordNet.Synset.pos_tag(),
  sense_key: String.t(),
  synset_id: String.t(),
  word: String.t()
}

Functions

matches?(lemma, word, pos)

@spec matches?(t(), String.t(), Nasty.Lexical.WordNet.Synset.pos_tag() | nil) ::
  boolean()

Checks if lemma matches a word and optional POS.

new(word, pos, synset_id, sense_key, language, opts \\ [])

Creates a new lemma struct.

Examples

iex> Lemma.new("dog", :noun, "oewn-02084071-n", "dog%1:05:00::", :en)
{:ok, %Lemma{word: "dog", pos: :noun, ...}}

normalize(word)

@spec normalize(String.t()) :: String.t()

Returns a normalized version of the word for matching.

Converts to lowercase and removes diacritics/special characters.

same_word?(lemma1, lemma2)

@spec same_word?(t(), t()) :: boolean()

Checks if two lemmas are for the same word (case-insensitive).