bra0-kg 0.2.1

bra0 Knowledge Graph core — RDF transformations (sophia) + KgStore trait (NextGraph-First)
Documentation
//! RDF parsing via sophia — Turtle, N-Triples, JSON-LD
//!
//! Capabilities served: DP-1 (Import), DP-4 (Export), GOV-3 (Provenance)

use sophia::api::prelude::*;
use sophia::inmem::graph::LightGraph;
use sophia_turtle::parser::turtle;

/// Parse a Turtle string into a LightGraph. Returns triple count.
pub fn parse_turtle(input: &str) -> Result<(LightGraph, usize), Box<dyn std::error::Error>> {
    let mut graph = LightGraph::new();
    let count = turtle::parse_str(input).add_to_graph(&mut graph)?;
    Ok((graph, count))
}

#[cfg(test)]
mod tests {
    use super::*;

    /// T1: Parse ontoLEDGY — acceptance test from plan-sophia-rationalization.md
    #[test]
    fn t1_parse_turtle_basic() {
        let ttl = r#"
            @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
            <http://example.org/A> a rdfs:Class ;
                rdfs:label "Test"@en .
        "#;
        let (_, count) = parse_turtle(ttl).expect("parse failed");
        assert_eq!(count, 2);
    }
}