% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lexical_analysis.R
\name{extract_pos_tags}
\alias{extract_pos_tags}
\title{Extract Part-of-Speech Tags from Tokens}
\usage{
extract_pos_tags(
  tokens,
  include_lemma = TRUE,
  include_entity = FALSE,
  include_dependency = FALSE,
  model = "en_core_web_sm"
)
}
\arguments{
\item{tokens}{A quanteda tokens object or character vector of texts.}

\item{include_lemma}{Logical; include lemmatized forms (default: TRUE).}

\item{include_entity}{Logical; include named entity recognition (default: FALSE).}

\item{include_dependency}{Logical; include dependency parsing (default: FALSE).}

\item{model}{Character; spaCy model to use (default: "en_core_web_sm").}
}
\value{
A data frame with columns:
\itemize{
\item \code{doc_id}: Document identifier
\item \code{sentence_id}: Sentence number within document
\item \code{token_id}: Token position within sentence
\item \code{token}: Original token
\item \code{pos}: Universal POS tag (e.g., NOUN, VERB, ADJ)
\item \code{tag}: Detailed POS tag (e.g., NN, VBD, JJ)
\item \code{lemma}: Lemmatized form (if include_lemma = TRUE)
\item \code{entity}: Named entity type (if include_entity = TRUE)
\item \code{head_token_id}: Head token in dependency tree (if include_dependency = TRUE)
\item \code{dep_rel}: Dependency relation type, e.g., nsubj, dobj (if include_dependency = TRUE)
}
}
\description{
Uses spaCy to extract part-of-speech (POS) tags from tokenized text.
Returns a data frame with token-level POS annotations.
}
\details{
This function requires the Python
with spaCy installed. If spaCy is not initialized, this function will
attempt to initialize it with the specified model.
}
\examples{
if (interactive()) {
  tokens <- quanteda::tokens(TextAnalysisR::SpecialEduTech$abstract[1])
  pos_data <- extract_pos_tags(tokens)
  print(pos_data)
}
}
\concept{lexical}
