-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use PrefixMap? #113
Comments
How to build a PrefixMapThe trait PrefixMap is implemented by any slice of (prefix, IRI) pair. For example, a Vec of (PrefixBox, IriBox) would do the trick. How to use a PrefixMap to abbreviate IRIsThe easiest way is to use the get_prefixed_pair method of PrefixMap. It takes any term, and returns a pair (prefix, suffix) if that term is an IRI and can be abbreviated using one of the prefixes in the map. Otheriwse, it returns None (meaning that you should display the IRI in full). Hope this helps. |
Thanks for the quick reply! As a Rust beginner, I'm not quite sure what to do but I got as far as:
However that causes: |
UpdateI think I got it now: let mut prefixes: Vec<(PrefixBox,IriBox)> = Vec::new();
let hito_prefix: PrefixBox = Prefix::new("hito").unwrap().boxed();
let hito_iri: IriBox = Iri::new("http://hitontology.eu/ontology/").unwrap().boxed();
prefixes.push((hito_prefix,hito_iri)); Could this be added as an example to the documentation? (using ? instead of unwrap()) A convenience method to read a prefix map from a turtle file would also be nice and a method to add a prefix map entry such as |
Yes, the lack of documentation is well recognized. My efforts are now focused on a big refactorying of the library. Any new documentation is at risk of being quickly outdated, so unfortunately, it is not my priority at the moment. About being able to get the prefix map out of a parsed turtle file: I agree. There is an issue about it Rio, the parser library on which Sophia is relying. |
Ah OK, then I will just write a quick convenience method and adapt to the refactoring later for sophia 0.8, thanks for the help! |
I want to shorten URIs shown to users using a prefix map, but following https://docs.rs/sophia/latest/sophia/prefix/trait.PrefixMap.html I do not understand how to construct and fill one. Can you give an example on how it is supposed to be used?
The text was updated successfully, but these errors were encountered: