if (FALSE) {
# Fetch annotations for matches using Tree-Tagger foundry
# Note: Authorization required for copyright-restricted corpora
q <- KorAPConnection() |>
auth() |>
corpusQuery("Ameisenplage", metadataOnly = FALSE) |>
fetchNext(maxFetch = 10) |>
fetchAnnotations()
# Access linguistic annotations for match i:
pos_tags <- q@collectedMatches$pos
# Data frame with left/match/right columns for POS tags
lemmas <- q@collectedMatches$lemma
# Data frame with left/match/right columns for lemmas
morphology <- q@collectedMatches$morph
# Data frame with left/match/right columns for morphological tags
atokens <- q@collectedMatches$atokens
# Data frame with left/match/right columns for annotation token text
# Original XML snippet for match i
raw_snippet <- q@collectedMatches$annotation_snippet[[i]]
# Access specific components:
# POS tags for the matched tokens in match i
match_pos <- q@collectedMatches$pos$match[[i]]
# Lemmas for the left context in match i
left_lemmas <- q@collectedMatches$lemma$left[[i]]
# Token text for the right context in match i
right_tokens <- q@collectedMatches$atokens$right[[i]]
# Use a different foundry (e.g., MarMoT)
q <- KorAPConnection() |>
auth() |>
corpusQuery("Ameisenplage", metadataOnly = FALSE) |>
fetchNext(maxFetch = 10) |>
fetchAnnotations(foundry = "marmot")
q@collectedMatches$pos$left[1] # POS tags for the left context of the first match
}
Run the code above in your browser using DataLab