logicaffeine_language/
ontology.rs

1//! Ontology module for bridging anaphora and sort compatibility checking.
2//!
3//! This module provides:
4//! - Part-whole relationship lookup for bridging anaphora resolution
5//! - Predicate sort requirements for metaphor detection
6
7use crate::lexicon::Sort;
8
9include!(concat!(env!("OUT_DIR"), "/ontology_data.rs"));
10
11/// Find possible whole objects for a given part noun.
12/// Returns None if the noun is not a known part of any whole.
13pub fn find_bridging_wholes(part_noun: &str) -> Option<&'static [&'static str]> {
14    let wholes = get_possible_wholes(&part_noun.to_lowercase());
15    if wholes.is_empty() {
16        None
17    } else {
18        Some(wholes)
19    }
20}
21
22/// Check if a predicate is compatible with a subject's sort.
23/// Returns true if compatible or no sort requirement exists.
24pub fn check_sort_compatibility(predicate: &str, subject_sort: Sort) -> bool {
25    match get_predicate_sort(&predicate.to_lowercase()) {
26        Some(required) => subject_sort.is_compatible_with(required),
27        None => true,
28    }
29}
30
31/// Get the required sort for a predicate, if any.
32pub fn required_sort(predicate: &str) -> Option<Sort> {
33    get_predicate_sort(&predicate.to_lowercase())
34}