Skip to content

Commit

Permalink
fix typos and small mistakes in book
Browse files Browse the repository at this point in the history
  • Loading branch information
pchampin committed Jan 8, 2024
1 parent b5de88d commit 3ac76d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions book/src/ch02_rdf_terms.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ In Sophia, all functions accepting terms as parameters are expecting a type `T:

The solution is to pass [`t.borrow_term()`] to the function. This method returns *something* implementing [`Term`], representing the same RDF term as `t`, without waiving ownership. This is a very common pattern in Sophia.

More precisely, the type returned by [`t.borrow_term()`] is the associated type [`Term::BorrowTerm`]. In most cases, this is a reference a reference or a copy of `t`.
More precisely, the type returned by [`t.borrow_term()`] is the associated type [`Term::BorrowTerm`]. In most cases, this is a reference or a copy of `t`.


## Recipes for constructing terms
Expand Down Expand Up @@ -126,15 +126,15 @@ let lit_date = "2023-11-15" * xsd::date;
# fn main() -> Result<(), Box<dyn std::error::Error>> {
#
# use sophia::api::term::BnodeId;
let b = BnodeId::new("x");
let b = BnodeId::new_unchecked("x");
#
# Ok(()) }
```

### Converting terms into a different type
```rust,noplayground
# use sophia::api::{ns::xsd, term::{SimpleTerm, Term}};
fn main() -> Result<(), Box<dyn std::error::Error>> {
#fn main() -> Result<(), Box<dyn std::error::Error>> {
# let some_term = "42" * xsd::integer;
let t1: SimpleTerm = "hello".into_term();
let t2: i32 = some_term.try_into_term()?;
Expand Down
6 changes: 3 additions & 3 deletions book/src/ch03_rdf_statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The [`Triple`] and [`Quad`] traits define how you interact with [RDF statements]

Note that in Sophia's [generalized RDF] model, terms of any kind can occur in any position in a statement.
This contrasts to strict RDF where only IRIs can occur in predicate position,
and where literals can not occur in the subject position.
and where literals can only occur in the object position.


## Using triples
Expand All @@ -16,7 +16,7 @@ These methods also have a `to_X` version that destructs the original triple inst

```rust,noplayground
# use sophia::api::{ns::rdf, prelude::*};
// Example: yield all the tems besing used as types in the given triples
// Example: yield all the terms being used as types in the given triples
fn all_types<IT, T>(triples: IT) -> impl Iterator<Item=T::Term>
where
IT: IntoIterator<Item=T>,
Expand Down Expand Up @@ -56,7 +56,7 @@ where

To check whether two values implementing [`Triple`] (resp. [`Quad`])
represent the same RDF statements, the method [`Triple::eq`] (resp. [`Quad::eq`])
must be used.r
must be used.
It will compare each component of the statements using the [`Term::eq`] method.
Note that the `==` operator may give a different result than [`Triple::eq`] or [`Quad::eq`]
on some types implementing the [`Triple`] or the [`Quad`] trait.
Expand Down
12 changes: 7 additions & 5 deletions book/src/ch04_rdf_graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ graph
[`Graph::triples_matching`] accepts a large variety of parameters,
which will be described in more detail [in the next chapter](./ch05_term_matchers.md).

[`Graph`] also provide methods to iterate over all unique [subjects](https://docs.rs/sophia_api/0.8.0/sophia_api/graph/trait.Graph.html#method.subjects),
[`Graph`] also provide methods to iterate over all [subjects](https://docs.rs/sophia_api/0.8.0/sophia_api/graph/trait.Graph.html#method.subjects),
[predicate](https://docs.rs/sophia_api/0.8.0/sophia_api/graph/trait.Graph.html#method.predicates)
and [object](https://docs.rs/sophia_api/0.8.0/sophia_api/graph/trait.Graph.html#method.objects)
in the graph,
Expand Down Expand Up @@ -101,14 +101,15 @@ and are described in more detail in the [next chapter](./ch05_term_matchers.md).
* slices of [triples] implement [`Graph`];
* standard collections ([`Vec`], [`HashSet`] and [`BTreeSet`]) of [triples] implement [`Graph`] and [`MutableGraph`];
* [`sophia::inmem::LightGraph`] provides a [`Graph`] and [`MutableGraph`] implementation with a low memory footprint;
* [`sophia::inmem::FastGraph`] provides a [`Graph`] and [`MutableGraph`] implementation design for fast retrieval of any given triple.
* [`sophia::inmem::FastGraph`] provides a [`Graph`] and [`MutableGraph`] implementation designed for fast retrieval of any given triple.

## Recipies for constructing graphs

### Constructing and populating an empty graph

```rust,noplayground
# use sophia::{api::{ns::{Namespace, rdf}, prelude::*}, inmem::graph::FastGraph};
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut g = FastGraph::new();
let ex = Namespace::new_unchecked("https://example.org/ns#");
let alice = ex.get_unchecked("alice");
Expand All @@ -117,12 +118,13 @@ g.insert(
&alice,
rdf::type_,
s.get_unchecked("Person")
).unwrap();
)?;
g.insert(
&alice,
s.get_unchecked("name"),
"Alice"
).unwrap();
)?;
# Ok(()) }
```

### Constructing a graph from a triple source[^triple_source]
Expand Down Expand Up @@ -192,4 +194,4 @@ In particular, any iterator of `Result<T, E>` where `T: `[`Triple`] is a [`Tripl
[`sophia::inmem::FastGraph`]: https://docs.rs/sophia_inmem/0.8.0/sophia_inmem/graph/type.FastGraph.html
[`TripleSource`]: https://docs.rs/sophia_api/0.8.0/sophia_api/source/trait.TripleSource.html
[parsers]: ./ch07_parsing_and_serializing.md
[`CollectibeGraph`]: https://docs.rs/sophia_api/0.8.0/sophia_api/graph/trait.CollectibleGraph.html
[`CollectibleGraph`]: https://docs.rs/sophia_api/0.8.0/sophia_api/graph/trait.CollectibleGraph.html

0 comments on commit 3ac76d5

Please sign in to comment.