https://github.com/flarebyte/ntriples-filter
Filter for rdf ntriples in Elm
https://github.com/flarebyte/ntriples-filter
Last synced: over 1 year ago
JSON representation
Filter for rdf ntriples in Elm
- Host: GitHub
- URL: https://github.com/flarebyte/ntriples-filter
- Owner: flarebyte
- License: bsd-3-clause
- Created: 2017-04-09T21:25:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-05T16:39:02.000Z (almost 9 years ago)
- Last Synced: 2025-01-04T10:24:05.711Z (over 1 year ago)
- Language: Elm
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Filtering of n-triples
[](https://travis-ci.org/flarebyte/ntriples-filter)
> This library provides an easy way of filtering a list of simplified n-triples. A simplified n-triple with a subject, a predicate and an object. It is simplified because it does not discriminate between URI, blank node, language or datatype. More about [RDF n-triples](https://en.wikipedia.org/wiki/N-Triples)
## Getting Started
### Installing Elm packages
There is no dependency.
```
elm-app package install
```
## Create a n-triple
Create a simplified n-triple with a subject, a predicate and an object.
```
createTriple "http://example.org/show/218" "http://www.w3.org/2000/01/rdf-schema#label" "That Seventies Show"
```
Please note that intentionally this library has a very casual approach to the specs, and any string will be accepted.
## Filter a list of n-triples
Filter a list of n-triples based on a filter expression.
```
-- Select only the triples which have a given subject
filter (WithSubject (Equals "http://example.org/show/218")) listOfTriples
-- Select only the triples which have a label and which starts with "That"
filter (And (WithPredicate (Equals "http://www.w3.org/2000/01/rdf-schema#label"))(WithObject (StartsWith "That")) ) listOfTriples
```
## Filter expression
| Type | Description |
|---------------|-------------------------------------------------------------------------------------------------------------------------|
| WithSubject | Specify a criteria for the subject field. |
| WithPredicate | Specify a criteria for the predicate field. |
| WithObject | Specify a criteria for the object field. |
| Not | Inverts the effect of a filter expression and returns a list of triples that does not match it. |
| And | Joins filter expressions clauses with a logical AND returns all the triples that match the conditions of both clauses. |
| Or | Joins filter expressions clauses with a logical OR returns all the triples that match the conditions of either clauses. |
## Field comparator
| Type | Description |
|--------------------|-----------------------------------------------------------------------------|
| IsEmpty | Determine if the field is empty. |
| Equals | Determine if the field is equal to the given value. |
| StartsWith | Determine if the field starts with the given value. |
| EndsWith | Determine if the field ends with the given value. |
| Contains | Determine if the field contains the given value. |
| Regx | Determine if the field satisfies the given regular expression. |
| IsTrue | Determine if the field is true (contains the string "true"). |
| IsFalse | Determine if the field is true (contains the string "false"). |
| EqualsAny | Determine if the field is equal any of the given values. |
| GreaterThan | Determine if the field is greater than the given float value. |
| GreaterThanOrEqual | Determine if the field is greater or equal to the given float value. |
| LessThan | Determine if the field is less than the given float value. |
| LessThanOrEqual | Determine if the field is less or equal to the given float value. |
| Custom | Determine if the field satisfies a custom function against the given value. |
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## Versioning
Managed automatically by [Elm version rules](https://github.com/elm-lang/elm-package#version-rules).
## Authors
* **Olivier Huin** - *Initial work* - [olih](https://github.com/olih)
See also the list of [contributors](https://github.com/flarebyte/ntriples-filter/graphs/contributors) who participated in this project.
## License
This project is licensed under the BSD 3-Clause License - see the [LICENSE.md](LICENSE) file for details