Text Preprocessing and Entity Extraction

Text Preprocessing and Entity Extraction

This vignette explains the text preprocessing and entity extraction capabilities of the LBDiscover package, which are fundamental steps in the literature-based discovery process.

Introduction

Before applying discovery models, we need to preprocess the text data and extract the entities of interest. These steps transform raw text into structured information that can be used for discovering relationships between biomedical concepts.

Loading the Package

library(LBDiscover)

Data Retrieval

First, let’s retrieve some sample articles:

# Search for articles about migraines
migraine_articles <- pubmed_search(
  query = "migraine pathophysiology",
  max_results = 100
)
#> Created pubmed_cache environment for result caching
#> Searching PubMed for: migraine pathophysiology
#> Found 12475 results, retrieving 100 records
#> Fetching batch 1 of 1 (records 1-100)
#> Processing 99 articles
#> Cached search results for future use

# View the first article
head(migraine_articles[, c("pmid", "title")], 3)
#>       pmid
#> 1 42808696
#> 2 42806968
#> 3 42806627
#>                                                                                                                                    title
#> 1                                                                      Redefining Disease Classification and Teaching in Otolaryngology.
#> 2        Caloric canal paresis thresholds in relation to vHIT-defined acute unilateral vestibular dysfunction: a retrospective analysis.
#> 3 Orofacial pain disorder or trigeminal autonomic cephalalgia? Insights into pathophysiology and implications in medicine and dentistry.

Basic Text Preprocessing

The first step is to preprocess the text data to extract meaningful terms:

# Preprocess the abstracts
preprocessed_data <- preprocess_text(
  migraine_articles,
  text_column = "abstract",
  remove_stopwords = TRUE,
  custom_stopwords = c("study", "patient", "result", "conclusion"),
  min_word_length = 3,
  max_word_length = 25
)
#> Tokenizing text...

# View terms extracted from the first document
head(preprocessed_data$terms[[1]], 10)
#>            word count
#> 1          18th     1
#> 2          19th     1
#> 3      accuracy     1
#> 4      aligning     1
#> 5         alone     1
#> 6       already     1
#> 7    anatomical     3
#> 8  anatomically     1
#> 9       anatomy     1
#> 10     approach     2

Optimized Preprocessing for Large Datasets

For larger datasets, we can use the optimized vectorized preprocessing function:

# Use optimized vectorized preprocessing
opt_preprocessed_data <- vec_preprocess(
  migraine_articles,
  text_column = "abstract",
  remove_stopwords = TRUE,
  min_word_length = 3,
  chunk_size = 50  # Process in chunks of 50 documents
)
#> Processing text in 2 chunks...
#>   |                                                                              |                                                                      |   0%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================================================| 100%

# Compare processing times
system.time({
  preprocess_text(
    migraine_articles,
    text_column = "abstract",
    remove_stopwords = TRUE
  )
})
#> Tokenizing text...
#>    user  system elapsed 
#>   0.049   0.000   0.049

system.time({
  vec_preprocess(
    migraine_articles,
    text_column = "abstract",
    remove_stopwords = TRUE,
    chunk_size = 50
  )
})
#> Processing text in 2 chunks...
#>   |                                                                              |                                                                      |   0%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================================================| 100%
#>    user  system elapsed 
#>    0.05    0.00    0.05

Advanced Text Analysis

N-gram Extraction

We can extract n-grams (sequences of n words) to capture multi-word concepts:

# Extract bigrams (2-word sequences)
bigrams <- extract_ngrams(
  migraine_articles$abstract,
  n = 2,
  min_freq = 2
)

# View the most frequent bigrams
head(bigrams, 10)
#>                 ngram frequency
#> 8200           in the       123
#> 11501             p 0       102
#> 2884  associated with        80
#> 11818   patients with        79
#> 11062          of the        68
#> 8120      in migraine        57
#> 17336   with migraine        49
#> 2495          and the        45
#> 10951     of migraine        44
#> 2752             as a        39

Sentence Segmentation

Segmenting text into sentences can be useful for more granular analysis:

# Extract sentences from the first abstract
abstracts <- migraine_articles$abstract
first_abstract <- abstracts[1]

# Make sure we have a valid abstract
if(is.na(first_abstract) || length(first_abstract) == 0 || nchar(first_abstract) == 0) {
  # Find the first non-empty abstract
  valid_idx <- which(!is.na(abstracts) & nchar(abstracts) > 0)
  if(length(valid_idx) > 0) {
    first_abstract <- abstracts[valid_idx[1]]
    cat("First abstract was empty, using abstract #", valid_idx[1], "instead.\n")
  } else {
    # Create a sample abstract for demonstration
    first_abstract <- "This is a sample abstract for demonstration. It contains multiple sentences. Each sentence will be extracted separately."
    cat("No valid abstracts found. Using a sample abstract for demonstration.\n")
  }
}

# Now segment the valid abstract
sentences <- segment_sentences(first_abstract)

# Check if sentences list has elements before trying to access them
if(length(sentences) > 0 && length(sentences[[1]]) > 0) {
  # View the first few sentences
  head(sentences[[1]], min(3, length(sentences[[1]])))
} else {
  cat("No sentences could be extracted. The abstract might be too short or formatted incorrectly.\n")
}
#> [1] "Di.e.se classification in otolaryngology remains rooted in anatomical frameworks from the 18th and 19th centuries, predating modern histopathology and pathophysiology."                                                                         
#> [2] "This anatomically dri.e. approach may inadequately capture disorders that transcend anatomical boundaries, such as laryngopharyngeal reflux di.e.se, vestibular migrai.e. neurosensory hearing, disorders, and granulomatosis with polyangiitis."
#> [3] "The transanatomical presentations of some disorders contribute therefore to documented underdiagnosis, diagnostic delays, and substantial healthcare costs."

# View the first few sentences
head(sentences[[1]], 3)
#> [1] "Di.e.se classification in otolaryngology remains rooted in anatomical frameworks from the 18th and 19th centuries, predating modern histopathology and pathophysiology."                                                                         
#> [2] "This anatomically dri.e. approach may inadequately capture disorders that transcend anatomical boundaries, such as laryngopharyngeal reflux di.e.se, vestibular migrai.e. neurosensory hearing, disorders, and granulomatosis with polyangiitis."
#> [3] "The transanatomical presentations of some disorders contribute therefore to documented underdiagnosis, diagnostic delays, and substantial healthcare costs."

Language Detection

For dealing with multilingual corpora, we can detect the language of each document:

# Filter out NA values from abstracts and detect language
abstracts <- migraine_articles$abstract[1:5]
valid_abstracts <- abstracts[!is.na(abstracts)]

# Apply language detection to valid abstracts
if (length(valid_abstracts) > 0) {
  languages <- sapply(valid_abstracts, detect_lang)
  
  # View results
  data.frame(
    abstract_id = which(!is.na(abstracts)),
    language = languages
  )
} else {
  message("No valid abstracts found for language detection")
}
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   abstract_id
#> Disease classification in otolaryngology remains rooted in anatomical frameworks from the 18th and 19th centuries, predating modern histopathology and pathophysiology. This anatomically driven approach may inadequately capture disorders that transcend anatomical boundaries, such as laryngopharyngeal reflux disease, vestibular migraine, neurosensory hearing, disorders, and granulomatosis with polyangiitis. The transanatomical presentations of some disorders contribute therefore to documented underdiagnosis, diagnostic delays, and substantial healthcare costs. This commentary proposes a paradigm shift toward a histophysiological classification system organized by tissue type, cellular mechanisms, and pathophysiological dysfunction rather than anatomical compartments alone. Such a framework would reframe currently labeled "non-specific symptoms" as tissue-specific presentations. That may improve recognition of transanatomical disease patterns, aligning otolaryngology with precision medicine trends already transforming oncology, gastroenterology, and pulmonology. This complementary classification layer does not replace anatomy but enhances diagnostic reasoning. Prospective multicenter studies comparing diagnostic accuracy and outcomes between frameworks are needed to validate this approach.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1
#> BACKGROUND: Caloric testing and the video head impulse test (vHIT) assess vestibular function at different frequency ranges and provide complementary information in patients with acute vertigo. Although a canal paresis (CP) threshold of 25% is commonly used to define caloric abnormality, interpreting CP values in relation to vHIT-defined unilateral high-frequency vestibular dysfunction remains clinically challenging. OBJECTIVE: We evaluated how conventional and alternative caloric CP thresholds align with vHIT-defined acute unilateral vestibular dysfunction and sought an interpretive CP threshold best corresponding to vHIT-defined findings. METHODS: This retrospective analysis included patients presenting with acute vertigo within 72 h of symptom onset who underwent both caloric testing and vHIT at a tertiary referral center. Patients with clinically suspected benign paroxysmal positional vertigo, Ménière's disease, vestibular migraine, sudden sensorineural hearing loss or labyrinthitis with acute auditory symptoms, central vestibular disorders, bilateral vestibulopathy, or bilateral caloric weakness were excluded. vHIT-defined unilateral dysfunction was based on compatible clinical features and abnormal horizontal-canal vHIT findings indicating unilateral high-frequency vestibulo-ocular reflex dysfunction. Receiver operating characteristic (ROC) analysis examined how caloric CP values corresponded to this classification. RESULTS: Of 1,634 eligible patients, 145 met criteria for vHIT-defined unilateral dysfunction. The symptomatic vHIT-normal comparison group comprised 1,489 patients without a final diagnosis of definite peripheral or central vestibular disease, although some had isolated caloric abnormalities. The conventional 25% CP threshold showed high sensitivity for the vHIT-based classification but classified a larger number of symptomatic vHIT-normal patients as CP abnormal. ROC analysis identified an approximately 30% CP threshold (Youden's index) with sensitivity 0.945 and specificity 0.867. This threshold reduced vHIT-discordant caloric abnormal classifications compared with 25% while maintaining close correspondence with the vHIT-defined classification. CONCLUSION: In patients evaluated within 72 h of acute vertigo onset, a CP threshold of approximately 30% showed the closest correspondence with vHIT-defined unilateral high-frequency vestibular dysfunction. It should be interpreted as a practical benchmark for interpreting caloric CP in relation to vHIT findings, not as an independent diagnostic criterion for AUVP.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                2
#> OBJECTIVE: This narrative review highlights the importance of orofacial pain considerations in the differential diagnosis of trigeminal autonomic cephalalgias (TACs)/trigeminal autonomic orofacial pains (TAOPs). In addition, we provide novel insights into the pathophysiology of the presentation of TACs in the maxillary (V2) and mandibular (V3) trigeminal distributions (TAOPs). BACKGROUND: TACs are lifelong disorders characterized by severe unilateral head pain accompanied by cranial autonomic phenomena. However, the head pain experienced may refer to the face, be present solely in the orofacial region as TAOPs, or even be experienced as a toothache. These presentations, involving V2/V3, may resemble disorders of diverse etiology and pathophysiology that may share some similarities with TACs, confusing the patient while relating symptoms, and creating a diagnostic dilemma for the clinician potentially leading to misdiagnosis. Moreover, TACs pathophysiology has not been discussed in relation to V2/V3 presentations (TAOPs). METHODS: A literature search was performed on PubMed/Scopus to find relevant literature about TACs and TAOPs, and case reports of orofacial presentations. Deep reanalysis of several of our published articles on preclinical models of TACs was conducted to assess potential of V2-V3 components. RESULTS: TACs orofacial presentations are not as common but if present can lead to misdiagnosis with significant consequences. Patients presenting TACs involving the midface as TAOPs experience an important delay for a correct diagnosis including multiple and diverse health provider visits, with a risk of having well-intended but misguided procedures. Differential diagnosis considerations need to include dental/odontogenic causes, sinusitis, temporomandibular disorders, Eagle syndrome, trigeminal neuralgia, and migraine (orofacial migraine, neurovascular orofacial pain). A reanalysis of preclinical data provides novel insights into this orofacial involvement. In two TAC-specific preclinical neuronal populations, recording either trigeminal or superior salivatory nucleus neurons, it was observed that ~20% and 37.5% of neurons, respectively, had cutaneous receptive fields that included or were exclusively within the V2-V3 trigeminal division. Whereas the numbers are not large, these demonstrate that even in rodent models in neuronal populations that could be considered TAC-like, they can extend to, or exclusively involve, the facial region, similar to TAOPs. CONCLUSION: The potential presence of TACs in the orofacial region can be observed from preclinical models to the clinical setting. The International Classification of Headache Disorders (ICHD) needs to recognize this additional localization, as well as the intraoral one, including dental structures. Education about TACs/TAOPs in the medical and dental setting is vital. Evidence has shown that dentists are one of the first providers that are seen by this patient population due to similarities with dental pain. The dentist specialized in orofacial pain is a key ally in the identification of TACs/TAOPs. The medical/neurology and dental/orofacial pain settings have a great opportunity and responsibility to work together to stop years of pain in this patient population.           3
#> OBJECTIVES/BACKGROUND: This narrative review summarizes novel applications for the use of calcitonin gene-related peptide (CGRP)-targeted therapies that go beyond migraine, the latest updates with respect to targeting pituitary adenylate cyclase-activating peptide (PACAP) as therapeutic in migraine, as well as exploring other more recently discovered targets that are undergoing preclinical through advanced clinical development, for the prevention and treatment of headache disorders. Headache disorders affect over one billion individuals worldwide and represent a major public health burden. Although CGRP-targeted therapies have transformed migraine care, a substantial proportion of patients do not achieve adequate relief or remain untreated. Therefore, there is the need to identify and validate novel mechanistic targets across the full spectrum of headache disorders. METHODS: This narrative review reports preclinical and clinical evidence for emerging therapeutic targets in headache, with a focus on those presented at the 2025 Scottsdale meeting of the American Headache Society, during the Advanced Science session. Literature searches were performed on specific topic areas using PubMed/Scopus to find relevant peer-reviewed literature, as well as studies in ongoing clinical trial registries. RESULTS: In addition to their established efficacy in migraine, CGRP-targeted therapies are increasingly being explored across other headache disorders, reflecting their broader relevance to headache pathophysiology. Beyond CGRP, several promising targets have emerged. PACAP has been identified as a CGRP-independent headache mediator, supported by robust preclinical data and two phase 2 trials demonstrating preventive efficacy with a PACAP monoclonal antibody in migraine. The endocannabinoid system shows antinociceptive potential, particularly through multitarget modulation of cannabinoid receptors and endocannabinoid-degrading enzymes. Several therapeutic targets in earlier stages of development are also gaining attention. Among these, prolactin signaling and orexin-2 receptor pathways represent sex-specific mechanisms, demonstrating female-specific and male-specific relevance in headache-related nociception, respectively. Additionally, protease-activated receptor-2 is implicated in dural-trigeminovascular nociceptive sensitization and advancing through early clinical development. Finally, modulation of reactive nitroxidative species with peroxynitrite has emerged as an early-stage strategy given its role in trigeminovascular sensitization and central pain maintenance. CONCLUSION: Altogether, these emerging targets expand the therapeutic landscape for headache disorders beyond CGRP and support a shift toward alternative, sex-informed, and potentially combinatorial approaches for headache prevention and treatment, with the potential to benefit the untreated portion of patients.                                                                                                                                                                                                                                                                                                                                                                                         4
#> BACKGROUND: Migraine is increasingly recognized as a disorder associated with widespread neuroanatomical and white-matter alterations rather than a purely episodic pain condition. The corpus callosum, the largest interhemispheric commissural tract, plays a critical role in sensory integration, pain modulation, and interhemispheric connectivity. Structural alterations of the corpus callosum may therefore reflect cumulative neurobiological effects of chronic migraine. OBJECTIVES: To compare corpus callosum morphometric characteristics between adult patients with migraine and controls without migraine and to investigate the associations between callosal morphology and clinical disease burden, including migraine duration, age at onset, attack frequency, and migraine-related disability. STUDY DESIGN: Single-center, cross-sectional observational study. SETTING: Tertiary referral neurology center with retrospective magnetic resonance imaging evaluation and prospective clinical assessment. METHODS: A total of 101 adult patients diagnosed with migraine according to ICHD-3 criteria and 101 age- and gender-matched controls without migraine were included in our study. Morphometric measurements of the corpus callosum were obtained from midsagittal fluid-attenuated inversion recovery magnetic resonance images using the Witelson segmentation method, assessing genu, truncus, and splenium thickness, as well as anteroposterior length. Group comparisons were performed using the Mann-Whitney U test and the Welch t test, as appropriate. Associations between callosal measurements and clinical variables, including disease duration, age at migraine onset, attack frequency, and Migraine Disability Assessment Scores, were analyzed using the Spearman rank correlation. A receiver operating characteristic analysis was conducted to evaluate the discriminative ability of callosal measurements. RESULTS: Compared with controls, patients with migraine had statistically significant reduced mean (SD) thickness of the genu (10.41 [1.35] mm vs 11.43 [1.08] mm), truncus (5.91 [0.73] mm vs 6.68 [0.84] mm), and splenium (10.73 [1.16] mm vs 11.13 [1.16] mm) all P < 0.05; anteroposterior length did not differ significantly. Within the migraine group, genu thickness correlated positively with age at onset (r = 0.33) and Migraine Disability Assessment Score (r = 0.37) and negatively with disease duration (r = -0.30). Attack frequency showed no significant association with any morphometric parameter. A receiver operating characteristic analysis showed a modest discriminatory performance for genu and truncus thickness. LIMITATIONS: Our study's cross-sectional design precludes causal inference. Also, morphometric measurements were limited to a 2-dimensional assessment thereby making us unable to conduct diffusion or volumetric analyses. CONCLUSIONS: Adult migraine is associated with segmental thinning of the corpus callosum, particularly in the genu and splenium. The relationships with age at onset and disease duration support the concept of cumulative, long-term interhemispheric remodeling in migraine, rather than short-term attack-related effects.                                                                                                                                     5
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   language
#> Disease classification in otolaryngology remains rooted in anatomical frameworks from the 18th and 19th centuries, predating modern histopathology and pathophysiology. This anatomically driven approach may inadequately capture disorders that transcend anatomical boundaries, such as laryngopharyngeal reflux disease, vestibular migraine, neurosensory hearing, disorders, and granulomatosis with polyangiitis. The transanatomical presentations of some disorders contribute therefore to documented underdiagnosis, diagnostic delays, and substantial healthcare costs. This commentary proposes a paradigm shift toward a histophysiological classification system organized by tissue type, cellular mechanisms, and pathophysiological dysfunction rather than anatomical compartments alone. Such a framework would reframe currently labeled "non-specific symptoms" as tissue-specific presentations. That may improve recognition of transanatomical disease patterns, aligning otolaryngology with precision medicine trends already transforming oncology, gastroenterology, and pulmonology. This complementary classification layer does not replace anatomy but enhances diagnostic reasoning. Prospective multicenter studies comparing diagnostic accuracy and outcomes between frameworks are needed to validate this approach.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             en
#> BACKGROUND: Caloric testing and the video head impulse test (vHIT) assess vestibular function at different frequency ranges and provide complementary information in patients with acute vertigo. Although a canal paresis (CP) threshold of 25% is commonly used to define caloric abnormality, interpreting CP values in relation to vHIT-defined unilateral high-frequency vestibular dysfunction remains clinically challenging. OBJECTIVE: We evaluated how conventional and alternative caloric CP thresholds align with vHIT-defined acute unilateral vestibular dysfunction and sought an interpretive CP threshold best corresponding to vHIT-defined findings. METHODS: This retrospective analysis included patients presenting with acute vertigo within 72 h of symptom onset who underwent both caloric testing and vHIT at a tertiary referral center. Patients with clinically suspected benign paroxysmal positional vertigo, Ménière's disease, vestibular migraine, sudden sensorineural hearing loss or labyrinthitis with acute auditory symptoms, central vestibular disorders, bilateral vestibulopathy, or bilateral caloric weakness were excluded. vHIT-defined unilateral dysfunction was based on compatible clinical features and abnormal horizontal-canal vHIT findings indicating unilateral high-frequency vestibulo-ocular reflex dysfunction. Receiver operating characteristic (ROC) analysis examined how caloric CP values corresponded to this classification. RESULTS: Of 1,634 eligible patients, 145 met criteria for vHIT-defined unilateral dysfunction. The symptomatic vHIT-normal comparison group comprised 1,489 patients without a final diagnosis of definite peripheral or central vestibular disease, although some had isolated caloric abnormalities. The conventional 25% CP threshold showed high sensitivity for the vHIT-based classification but classified a larger number of symptomatic vHIT-normal patients as CP abnormal. ROC analysis identified an approximately 30% CP threshold (Youden's index) with sensitivity 0.945 and specificity 0.867. This threshold reduced vHIT-discordant caloric abnormal classifications compared with 25% while maintaining close correspondence with the vHIT-defined classification. CONCLUSION: In patients evaluated within 72 h of acute vertigo onset, a CP threshold of approximately 30% showed the closest correspondence with vHIT-defined unilateral high-frequency vestibular dysfunction. It should be interpreted as a practical benchmark for interpreting caloric CP in relation to vHIT findings, not as an independent diagnostic criterion for AUVP.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            en
#> OBJECTIVE: This narrative review highlights the importance of orofacial pain considerations in the differential diagnosis of trigeminal autonomic cephalalgias (TACs)/trigeminal autonomic orofacial pains (TAOPs). In addition, we provide novel insights into the pathophysiology of the presentation of TACs in the maxillary (V2) and mandibular (V3) trigeminal distributions (TAOPs). BACKGROUND: TACs are lifelong disorders characterized by severe unilateral head pain accompanied by cranial autonomic phenomena. However, the head pain experienced may refer to the face, be present solely in the orofacial region as TAOPs, or even be experienced as a toothache. These presentations, involving V2/V3, may resemble disorders of diverse etiology and pathophysiology that may share some similarities with TACs, confusing the patient while relating symptoms, and creating a diagnostic dilemma for the clinician potentially leading to misdiagnosis. Moreover, TACs pathophysiology has not been discussed in relation to V2/V3 presentations (TAOPs). METHODS: A literature search was performed on PubMed/Scopus to find relevant literature about TACs and TAOPs, and case reports of orofacial presentations. Deep reanalysis of several of our published articles on preclinical models of TACs was conducted to assess potential of V2-V3 components. RESULTS: TACs orofacial presentations are not as common but if present can lead to misdiagnosis with significant consequences. Patients presenting TACs involving the midface as TAOPs experience an important delay for a correct diagnosis including multiple and diverse health provider visits, with a risk of having well-intended but misguided procedures. Differential diagnosis considerations need to include dental/odontogenic causes, sinusitis, temporomandibular disorders, Eagle syndrome, trigeminal neuralgia, and migraine (orofacial migraine, neurovascular orofacial pain). A reanalysis of preclinical data provides novel insights into this orofacial involvement. In two TAC-specific preclinical neuronal populations, recording either trigeminal or superior salivatory nucleus neurons, it was observed that ~20% and 37.5% of neurons, respectively, had cutaneous receptive fields that included or were exclusively within the V2-V3 trigeminal division. Whereas the numbers are not large, these demonstrate that even in rodent models in neuronal populations that could be considered TAC-like, they can extend to, or exclusively involve, the facial region, similar to TAOPs. CONCLUSION: The potential presence of TACs in the orofacial region can be observed from preclinical models to the clinical setting. The International Classification of Headache Disorders (ICHD) needs to recognize this additional localization, as well as the intraoral one, including dental structures. Education about TACs/TAOPs in the medical and dental setting is vital. Evidence has shown that dentists are one of the first providers that are seen by this patient population due to similarities with dental pain. The dentist specialized in orofacial pain is a key ally in the identification of TACs/TAOPs. The medical/neurology and dental/orofacial pain settings have a great opportunity and responsibility to work together to stop years of pain in this patient population.       en
#> OBJECTIVES/BACKGROUND: This narrative review summarizes novel applications for the use of calcitonin gene-related peptide (CGRP)-targeted therapies that go beyond migraine, the latest updates with respect to targeting pituitary adenylate cyclase-activating peptide (PACAP) as therapeutic in migraine, as well as exploring other more recently discovered targets that are undergoing preclinical through advanced clinical development, for the prevention and treatment of headache disorders. Headache disorders affect over one billion individuals worldwide and represent a major public health burden. Although CGRP-targeted therapies have transformed migraine care, a substantial proportion of patients do not achieve adequate relief or remain untreated. Therefore, there is the need to identify and validate novel mechanistic targets across the full spectrum of headache disorders. METHODS: This narrative review reports preclinical and clinical evidence for emerging therapeutic targets in headache, with a focus on those presented at the 2025 Scottsdale meeting of the American Headache Society, during the Advanced Science session. Literature searches were performed on specific topic areas using PubMed/Scopus to find relevant peer-reviewed literature, as well as studies in ongoing clinical trial registries. RESULTS: In addition to their established efficacy in migraine, CGRP-targeted therapies are increasingly being explored across other headache disorders, reflecting their broader relevance to headache pathophysiology. Beyond CGRP, several promising targets have emerged. PACAP has been identified as a CGRP-independent headache mediator, supported by robust preclinical data and two phase 2 trials demonstrating preventive efficacy with a PACAP monoclonal antibody in migraine. The endocannabinoid system shows antinociceptive potential, particularly through multitarget modulation of cannabinoid receptors and endocannabinoid-degrading enzymes. Several therapeutic targets in earlier stages of development are also gaining attention. Among these, prolactin signaling and orexin-2 receptor pathways represent sex-specific mechanisms, demonstrating female-specific and male-specific relevance in headache-related nociception, respectively. Additionally, protease-activated receptor-2 is implicated in dural-trigeminovascular nociceptive sensitization and advancing through early clinical development. Finally, modulation of reactive nitroxidative species with peroxynitrite has emerged as an early-stage strategy given its role in trigeminovascular sensitization and central pain maintenance. CONCLUSION: Altogether, these emerging targets expand the therapeutic landscape for headache disorders beyond CGRP and support a shift toward alternative, sex-informed, and potentially combinatorial approaches for headache prevention and treatment, with the potential to benefit the untreated portion of patients.                                                                                                                                                                                                                                                                                                                                                                                     en
#> BACKGROUND: Migraine is increasingly recognized as a disorder associated with widespread neuroanatomical and white-matter alterations rather than a purely episodic pain condition. The corpus callosum, the largest interhemispheric commissural tract, plays a critical role in sensory integration, pain modulation, and interhemispheric connectivity. Structural alterations of the corpus callosum may therefore reflect cumulative neurobiological effects of chronic migraine. OBJECTIVES: To compare corpus callosum morphometric characteristics between adult patients with migraine and controls without migraine and to investigate the associations between callosal morphology and clinical disease burden, including migraine duration, age at onset, attack frequency, and migraine-related disability. STUDY DESIGN: Single-center, cross-sectional observational study. SETTING: Tertiary referral neurology center with retrospective magnetic resonance imaging evaluation and prospective clinical assessment. METHODS: A total of 101 adult patients diagnosed with migraine according to ICHD-3 criteria and 101 age- and gender-matched controls without migraine were included in our study. Morphometric measurements of the corpus callosum were obtained from midsagittal fluid-attenuated inversion recovery magnetic resonance images using the Witelson segmentation method, assessing genu, truncus, and splenium thickness, as well as anteroposterior length. Group comparisons were performed using the Mann-Whitney U test and the Welch t test, as appropriate. Associations between callosal measurements and clinical variables, including disease duration, age at migraine onset, attack frequency, and Migraine Disability Assessment Scores, were analyzed using the Spearman rank correlation. A receiver operating characteristic analysis was conducted to evaluate the discriminative ability of callosal measurements. RESULTS: Compared with controls, patients with migraine had statistically significant reduced mean (SD) thickness of the genu (10.41 [1.35] mm vs 11.43 [1.08] mm), truncus (5.91 [0.73] mm vs 6.68 [0.84] mm), and splenium (10.73 [1.16] mm vs 11.13 [1.16] mm) all P < 0.05; anteroposterior length did not differ significantly. Within the migraine group, genu thickness correlated positively with age at onset (r = 0.33) and Migraine Disability Assessment Score (r = 0.37) and negatively with disease duration (r = -0.30). Attack frequency showed no significant association with any morphometric parameter. A receiver operating characteristic analysis showed a modest discriminatory performance for genu and truncus thickness. LIMITATIONS: Our study's cross-sectional design precludes causal inference. Also, morphometric measurements were limited to a 2-dimensional assessment thereby making us unable to conduct diffusion or volumetric analyses. CONCLUSIONS: Adult migraine is associated with segmental thinning of the corpus callosum, particularly in the genu and splenium. The relationships with age at onset and disease duration support the concept of cumulative, long-term interhemispheric remodeling in migraine, rather than short-term attack-related effects.                                                                                                                                 en

Entity Extraction

After preprocessing, the next step is to extract biomedical entities from the text.

Loading Entity Dictionaries

First, let’s load entity dictionaries that will be used for entity recognition:

# Load a disease dictionary
disease_dict <- load_dictionary(
  dictionary_type = "disease",
  source = "mesh"
)
#> Searching MeSH database for: disease[MeSH]
#> Found 195145 PubMed records with matching MeSH terms
#> Error getting MeSH links: Must specify either (not both) 'id' or 'web_history' arguments
#> Trying direct MeSH database search...
#> Processing batch 1 of 5
#> Extracted 20 unique terms from MeSH text format
#> Processing batch 2 of 5
#> Extracted 21 unique terms from MeSH text format
#> Processing batch 3 of 5
#> Extracted 25 unique terms from MeSH text format
#> Processing batch 4 of 5
#> Extracted 19 unique terms from MeSH text format
#> Processing batch 5 of 5
#> Extracted 21 unique terms from MeSH text format
#> Retrieved 102 unique terms from MeSH
#> Sanitizing dictionary with 102 terms...
#>   Removed 56 terms that did not match their claimed entity types
#>   Removed 38 terms with non-alphanumeric characters (final cleanup)
#> Sanitization complete. 8 terms remaining (7.8% of original)

# Load a drug dictionary
drug_dict <- load_dictionary(
  dictionary_type = "drug",
  source = "mesh"
)
#> Searching MeSH database for: pharmaceutical preparations[MeSH]
#> Found 1042483 PubMed records with matching MeSH terms
#> Error getting MeSH links: Must specify either (not both) 'id' or 'web_history' arguments
#> Trying direct MeSH database search...
#> Processing batch 1 of 2
#> Extracted 23 unique terms from MeSH text format
#> Processing batch 2 of 2
#> Extracted 3 unique terms from MeSH text format
#> Retrieved 26 unique terms from MeSH
#> Sanitizing dictionary with 26 terms...
#>   Removed 26 terms that did not match their claimed entity types
#> Sanitization complete. 0 terms remaining (0% of original)

# View a sample of each dictionary
head(disease_dict, 3)
#>               term            id    type    source
#> 10     Lobomycosis       MESH_10 disease mesh_text
#> 20         Disease MESH_ENTRY_19 disease mesh_text
#> 48 Osteochondrosis        MESH_7 disease mesh_text
head(drug_dict, 3)
#> [1] term   id     type   source
#> <0 rows> (or 0-length row.names)

Basic Entity Extraction

Now we can extract entities from the text using these dictionaries:

# Extract disease and drug entities
entities <- extract_entities(
  preprocessed_data,
  text_column = "abstract",
  dictionary = rbind(disease_dict, drug_dict),
  case_sensitive = FALSE,
  overlap_strategy = "priority"
)
#> Sanitizing dictionary with 8 terms...
#> Sanitization complete. 8 terms remaining (100% of original)
#> Extracting entities from 99 documents...
#> Extracted 32 entity mentions:
#>   disease: 32

# View some extracted entities
head(entities[, c("doc_id", "entity", "entity_type", "sentence")], 10)
#>    doc_id  entity entity_type
#> 1       1 Disease     disease
#> 2       1 Disease     disease
#> 3       1 Disease     disease
#> 4       2 Disease     disease
#> 5       2 Disease     disease
#> 6       5 Disease     disease
#> 7       5 Disease     disease
#> 8       5 Disease     disease
#> 9       5 Disease     disease
#> 10      6 Disease     disease
#>                                                                                                                                                                                                                                                                                                                             sentence
#> 1                                                                                                                                                            Disease classification in otolaryngology remains rooted in anatomical frameworks from the 18th and 19th centuries, predating modern histopathology and pathophysiology.
#> 2                                                                                   This anatomically driven approach may inadequately capture disorders that transcend anatomical boundaries, such as laryngopharyngeal reflux disease, vestibular migraine, neurosensory hearing, disorders, and granulomatosis with polyangiitis.
#> 3                                                                                                                                         That may improve recognition of transanatomical disease patterns, aligning otolaryngology with precision medicine trends already transforming oncology, gastroenterology, and pulmonology.
#> 4                             Patients with clinically suspected benign paroxysmal positional vertigo, Ménière's disease, vestibular migraine, sudden sensorineural hearing loss or labyrinthitis with acute auditory symptoms, central vestibular disorders, bilateral vestibulopathy, or bilateral caloric weakness were excluded.
#> 5                                                                                                                            The symptomatic vHIT-normal comparison group comprised 1,489 patients without a final diagnosis of definite peripheral or central vestibular disease, although some had isolated caloric abnormalities.
#> 6  OBJECTIVES: To compare corpus callosum morphometric characteristics between adult patients with migraine and controls without migraine and to investigate the associations between callosal morphology and clinical disease burden, including migraine duration, age at onset, attack frequency, and migraine-related disability.
#> 7                                                                                              Associations between callosal measurements and clinical variables, including disease duration, age at migraine onset, attack frequency, and Migraine Disability Assessment Scores, were analyzed using the Spearman rank correlation.
#> 8                                                                                                                                 Within the migraine group, genu thickness correlated positively with age at onset (r = 0.33) and Migraine Disability Assessment Score (r = 0.37) and negatively with disease duration (r = -0.30).
#> 9                                                                                                                                      The relationships with age at onset and disease duration support the concept of cumulative, long-term interhemispheric remodeling in migraine, rather than short-term attack-related effects.
#> 10                                                                                                                                                                                                                                     Hippocampal decline accelerated beyond approximately 11 years disease duration (exploratory).

Complete Entity Extraction Workflow

For a more comprehensive approach, we can use the complete entity extraction workflow:

# Extract entities using the complete workflow
# Check if running in R CMD check environment
is_check <- !interactive() && 
            (!is.null(Sys.getenv("R_CHECK_RUNNING")) && 
             Sys.getenv("R_CHECK_RUNNING") == "true")
             
# More robust check for testing environment
if (!is_check && !is.null(Sys.getenv("_R_CHECK_LIMIT_CORES_"))) {
  is_check <- TRUE
}

# Set number of cores based on environment
num_cores_to_use <- if(is_check) 1 else 4

# Extract entities using the complete workflow
entities_workflow <- extract_entities_workflow(
  preprocessed_data,
  text_column = "abstract",
  entity_types = c("disease", "drug", "gene", "protein", "pathway"),
  dictionary_sources = c("local", "mesh"),
  sanitize = TRUE,
  parallel = !is_check,           # Disable parallel in check environment
  num_cores = num_cores_to_use    # Use 1 core in check environment
)
#> Running in R CMD check environment. Disabling parallel processing.
#> Creating dictionaries for entity extraction...
#> Loading dictionaries sequentially...
#>   Using cached dictionary for disease (local)
#>   Using cached dictionary for drug (local)
#>   Using cached dictionary for gene (local)
#> Searching MeSH database for: proteins[MeSH]
#> Found 7901004 PubMed records with matching MeSH terms
#> Error getting MeSH links: Must specify either (not both) 'id' or 'web_history' arguments
#> Trying direct MeSH database search...
#> Processing batch 1 of 5
#> Extracted 24 unique terms from MeSH text format
#> Processing batch 2 of 5
#> Extracted 23 unique terms from MeSH text format
#> Processing batch 3 of 5
#> Extracted 19 unique terms from MeSH text format
#> Processing batch 4 of 5
#> Extracted 20 unique terms from MeSH text format
#> Processing batch 5 of 5
#> Extracted 19 unique terms from MeSH text format
#> Retrieved 105 unique terms from MeSH
#>   Added 105 terms from protein (mesh)
#> Searching MeSH database for: metabolic networks and pathways[MeSH]
#> Found 199793 PubMed records with matching MeSH terms
#> Error getting MeSH links: Must specify either (not both) 'id' or 'web_history' arguments
#> Trying direct MeSH database search...
#> Processing batch 1 of 1
#> Extracted 6 unique terms from MeSH text format
#> Retrieved 6 unique terms from MeSH
#>   Added 6 terms from pathway (mesh)
#> Created combined dictionary with 135 unique terms
#> Sanitizing dictionary with 135 terms...
#>   Removed 8 terms with numbers followed by special characters
#>   Removed 78 terms that did not match their claimed entity types
#>   Removed 42 terms with non-alphanumeric characters (final cleanup)
#> Sanitization complete. 7 terms remaining (5.2% of original)
#> Extracting entities from 99 documents...
#> Processing batch 1/1
#> Extracting entities from 99 documents...
#> Extracted 436 entity mentions:
#>   disease: 428
#>   protein: 8
#> Extracted 436 entity mentions in 0.13 minutes
#>   disease: 428
#>   protein: 8

# View summary of entity types
table(entities_workflow$entity_type)
#> 
#> disease protein 
#>     428       8

Customizing Entity Extraction

We can customize the entity extraction process by providing additional MeSH queries or custom dictionaries:

# Define custom MeSH queries for different entity types
mesh_queries <- list(
  "disease" = "migraine disorders[MeSH] OR headache disorders[MeSH]",
  "drug" = "analgesics[MeSH] OR serotonin agonists[MeSH] OR anticonvulsants[MeSH]",
  "gene" = "genes[MeSH] OR channelopathy[MeSH]"
)

# Create a custom dictionary
custom_dict <- data.frame(
  term = c("CGRP", "trigeminal nerve", "cortical spreading depression"),
  type = c("protein", "anatomy", "biological_process"),
  id = c("CUSTOM_1", "CUSTOM_2", "CUSTOM_3"),
  source = rep("custom", 3),
  stringsAsFactors = FALSE
)

# Extract entities with custom settings
custom_entities <- extract_entities_workflow(
  preprocessed_data,
  text_column = "abstract",
  entity_types = c("disease", "drug", "gene", "protein", "pathway"),
  dictionary_sources = c("local", "mesh"),
  additional_mesh_queries = mesh_queries,
  custom_dictionary = custom_dict,
  sanitize = TRUE
)
#> Running in R CMD check environment. Disabling parallel processing.
#> Creating dictionaries for entity extraction...
#> Adding 3 terms from custom dictionary
#> Loading dictionaries sequentially...
#>   Using cached dictionary for disease (local)
#>   Using cached dictionary for drug (local)
#>   Using cached dictionary for gene (local)
#>   Using cached dictionary for protein (mesh)
#>   Using cached dictionary for pathway (mesh)
#> Created combined dictionary with 138 unique terms
#> Sanitizing dictionary with 135 terms...
#>   Removed 8 terms with numbers followed by special characters
#>   Removed 78 terms that did not match their claimed entity types
#>   Removed 42 terms with non-alphanumeric characters (final cleanup)
#> Sanitization complete. 7 terms remaining (5.2% of original)
#> Extracting entities from 99 documents...
#> Processing batch 1/1
#> Extracting entities from 99 documents...
#> Extracted 523 entity mentions:
#>   anatomy: 1
#>   biological_process: 3
#>   disease: 428
#>   protein: 91
#> Extracted 523 entity mentions in 0.01 minutes
#>   anatomy: 1
#>   biological_process: 3
#>   disease: 428
#>   protein: 91

# View custom entities
custom_entities[custom_entities$source == "custom", ]
#> [1] entity      entity_type doc_id      start_pos   end_pos     sentence   
#> [7] frequency  
#> <0 rows> (or 0-length row.names)

Dictionary Sanitization

The quality of entity extraction heavily depends on the quality of the dictionaries. We can sanitize dictionaries to improve extraction quality:

# Create a raw dictionary with some problematic entries
raw_dict <- data.frame(
  term = c("migraine", "5-HT", "headache", "the", "and", "patient", "inflammation", "study"),
  type = c("disease", "chemical", "symptom", "NA", "NA", "NA", "biological_process", "NA"),
  id = paste0("ID_", 1:8),
  source = rep("example", 8),
  stringsAsFactors = FALSE
)

# Sanitize the dictionary
sanitized_dict <- sanitize_dictionary(
  raw_dict,
  term_column = "term",
  type_column = "type",
  validate_types = TRUE,
  verbose = TRUE
)
#> Sanitizing dictionary with 8 terms...
#>   Removed 1 terms with numbers followed by special characters
#>   Removed 3 common non-medical terms, conjunctive adverbs, and general terms
#> Sanitization complete. 4 terms remaining (50% of original)

# View the sanitized dictionary
sanitized_dict
#>           term               type   id  source
#> 1     migraine            disease ID_1 example
#> 3     headache            symptom ID_3 example
#> 6      patient                 NA ID_6 example
#> 7 inflammation biological_process ID_7 example

Mapping Terms to Biomedical Ontologies

We can map extracted terms to standard biomedical ontologies like MeSH or UMLS:

# Extract terms to map
terms_to_map <- c("migraine", "headache", "CGRP", "serotonin")

# Map to MeSH
mesh_mappings <- map_ontology(
  terms_to_map,
  ontology = "mesh",
  fuzzy_match = TRUE,
  similarity_threshold = 0.8
)
#> Searching MeSH database for: disease[MeSH]
#> Found 195145 PubMed records with matching MeSH terms
#> Error getting MeSH links: Must specify either (not both) 'id' or 'web_history' arguments
#> Trying direct MeSH database search...
#> Processing batch 1 of 5
#> Extracted 20 unique terms from MeSH text format
#> Processing batch 2 of 5
#> Extracted 21 unique terms from MeSH text format
#> Processing batch 3 of 5
#> Extracted 25 unique terms from MeSH text format
#> Processing batch 4 of 5
#> Extracted 19 unique terms from MeSH text format
#> Processing batch 5 of 5
#> Extracted 21 unique terms from MeSH text format
#> Retrieved 102 unique terms from MeSH
#> Sanitizing dictionary with 102 terms...
#>   Removed 56 terms that did not match their claimed entity types
#>   Removed 38 terms with non-alphanumeric characters (final cleanup)
#> Sanitization complete. 8 terms remaining (7.8% of original)
#> No matches found for the input terms in the mesh ontology

# View MeSH mappings
mesh_mappings
#> [1] term          ontology_id   ontology_term match_type   
#> <0 rows> (or 0-length row.names)

Topic Modeling

We can also apply topic modeling to discover the main themes in the corpus:

# Extract topics from the corpus
topics <- extract_topics(
  migraine_articles,
  text_column = "abstract",
  n_topics = 5,
  max_terms = 10
)
#> Tokenizing text...

# View top terms for each topic
topics$topics
#> $`Topic 1`
#>                      term   weight
#> patients         patients 71.07754
#> migraine         migraine 63.17836
#> between           between 53.17098
#> functional     functional 42.33254
#> right               right 39.07004
#> pfo                   pfo 34.45454
#> clinical         clinical 31.00856
#> connectivity connectivity 30.20348
#> group               group 29.45787
#> study               study 28.19996
#> 
#> $`Topic 2`
#>                  term    weight
#> headache     headache 102.91290
#> chronic       chronic  29.88857
#> cluster       cluster  28.30510
#> cervical     cervical  19.81231
#> associated associated  15.81053
#> cgrp             cgrp  14.88888
#> controls     controls  14.45871
#> neck             neck  12.10583
#> iih               iih  11.69420
#> patients     patients  11.63959
#> 
#> $`Topic 3`
#>                    term   weight
#> migraine       migraine 63.93754
#> patients       patients 29.74175
#> controls       controls 23.48366
#> between         between 21.30846
#> levels           levels 15.55091
#> iih                 iih 15.23222
#> group             group 13.42550
#> 001                 001 12.04050
#> healthy         healthy 11.77543
#> significant significant 10.96709
#> 
#> $`Topic 4`
#>                term    weight
#> migraine   migraine 105.40212
#> pain           pain  67.31240
#> related     related  35.78451
#> these         these  26.95189
#> patients   patients  26.63096
#> clinical   clinical  26.00548
#> treatment treatment  25.69668
#> may             may  23.10884
#> tacs           tacs  21.98757
#> irak           irak  21.30721
#> 
#> $`Topic 5`
#>                  term    weight
#> migraine     migraine 108.09428
#> cgrp             cgrp  49.01696
#> clinical     clinical  45.29280
#> vestibular vestibular  44.96687
#> may               may  36.52247
#> headache     headache  28.05930
#> specific     specific  26.38211
#> studies       studies  24.59660
#> evidence     evidence  24.00856
#> associated associated  23.34053