This tutorial covers installing all the tools you'll need to design metadata documents with AML and shows you how to get up and running quickly.
- JVM: version 7 or higher
- SBT to build the AMF command-line
You can download the example from the AML project examples repository in Github.
Download AMF from its github repository and build AMF command-line (you will need Scala SBT):
This will leave a versioned fat jar (amf-X.Y.Z-SNAPSHOT.jar) in the top-level repository of the project. Copy this jar file to the top-level of the examples repository:
In this example we will define a new type of metadata document to exchange information about geographical locations.
First, we will define a new type of AML Dialect describing the structure of the document, located in the examples repository in the file
The dialect is very simple. It just defines a document with a couple of nodes: one for the place, and the other for an image of the place. We are using the Schema.org vocabulary to provide the semantics of the metadata.
You can check the validity of this AML Dialect using AMF. From the top-level directory of the examples repository:
Having a valid AML Dialect, we can start using it to parse metadata documents with information about different places.
For example, we can try the
We can use AMF to parse and validate the example, passing as an argument the location of the dialect and dialect instance to be parsed:
The following JSON-LD document will be returned in the console:
AML allows users to define the semantics for metadata documents in AML Vocabulary files.
aml/quickstart/geolocation.yaml contains a vocabulary defining a few terms for a custom geolocation vocabulary:
We could modify our dialect to generate a new version that uses the AML Vocabulary for geolocation we have just reviewed:
Now, we can parse documents that include geographical coordinates like:
The geographical information will appear in the graph using the semantic terms defined in our geolocation vocabulary:
If we try to parse an invalid document, the parser will fail and return an error message with a list of errors and syntactic information about the location of the error.
As an example, you can try to parse the
aml/quickstart/piccadilly_circus_error.yaml document in the examples. In this document, geographical coordinates are provided as strings instead of double values:
Parsing the document throws a textual error in the console:
To get the error report as a machine-friendly graph encoded using JSON-LD, the
validate AMF command must be used.