pschema-rs

CI codecov latest_version documentation

pschema-rs is a Rust library that provides a Pregel-based schema validation algorithm for generating subsets of data from Wikidata. It is designed to be efficient, scalable, and easy to use, making it suitable for a wide range of applications that involve processing large amounts of data from Wikidata.

Features

Installation

To use pschema-rs in your Rust project, you can add it as a dependency in your Cargo.toml file:

toml [dependencies] pschema = "0.0.2"

Usage

Here's an example of how you can use pschema-rs to perform schema validation and generate a subset of data from Wikidata:

```rust use pregelrs::graphframe::GraphFrame; use pschemars::backends::duckdb::DuckDB; use pschemars::backends::Backend; use pschemars::pschema::PSchema; use pschemars::shape::shex::Shape; use pschemars::shape::shex::TripleConstraint; use wikidatars::id::Id;

fn main() -> Result<(), String> { // Define validation rules let start = Shape::TripleConstraint(TripleConstraint::new( 1, Id::from("P31").into(), Id::from("Q515").into(), ));

// Load Wikidata entities
let edges = DuckDB::import("./examples/from_duckdb/3000lines.duckdb")?;

// Perform schema validation
match GraphFrame::from_edges(edges) {
    Ok(graph) => match PSchema::new(start).validate(graph) {
        Ok(result) => {
            println!("Schema validation result:");
            println!("{:?}", result);
            Ok(())
        }
        Err(error) => Err(error.to_string()),
    },
    Err(error) => Err(format!("Cannot create a GraphFrame: {}", error)),
}

} ```

For more information on how to define validation rules, load entities from Wikidata, and process subsets of data, refer to the documentation.

Related projects

  1. wdsub is an application for generating Wikidata subsets written in Scala.
  2. pschema is a Scala-based library which is equivalent to this.

License

Copyright © 2023 Ángel Iglesias Préstamo (angel.iglesias.prestamo@gmail.com)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

By contributing to this project, you agree to release your contributions under the same license.