LeXtract.Document (lextract v0.1.2)

View Source

Represents an input document for information extraction.

Fields

  • :text - Raw text content of the document
  • :additional_context - Extra context provided to LLM (not part of main text)
  • :document_id - Unique identifier (auto-generated if not provided)
  • :metadata - Optional metadata about the document

Examples

iex> doc = LeXtract.Document.create("The patient has diabetes.")
iex> doc.text
"The patient has diabetes."

Summary

Functions

Creates a new document with the given text.

Creates multiple documents from a list of texts.

Types

example()

@type example() :: %{text: String.t(), extractions: [map()]}

t()

@type t() :: %LeXtract.Document{
  additional_context: String.t() | nil,
  document_id: String.t(),
  metadata: map() | nil,
  text: String.t()
}

Functions

create(text, opts \\ [])

@spec create(
  String.t(),
  keyword()
) :: t()

Creates a new document with the given text.

Automatically generates a UUID if document_id is not provided.

Examples

iex> doc = LeXtract.Document.create("Sample text")
iex> String.length(doc.document_id)
36

from_texts(texts)

@spec from_texts([String.t()]) :: [t()]

Creates multiple documents from a list of texts.

Examples

iex> docs = LeXtract.Document.from_texts(["Text 1", "Text 2"])
iex> length(docs)
2