#
QuickstartThis 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.
#
Before you beginPrerequisites:
- JVM: version 7 or higher
- SBT to build the AMF command-line
#
Download the exampleYou can download the example from the AML project examples repository in Github.
#
Build and install the AMF command-line toolDownload 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:
#
Defining an AML Dialect for a new type of metadata documentsIn 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 aml/quickstart/dialects/places.yaml
:
places.yaml
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:
#
Parsing metadata documentsHaving a valid AML Dialect, we can start using it to parse metadata documents with information about different places.
For example, we can try the golden_gate.yaml
document:
golden_gate.yaml
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:
JSON-LD is a W3C standard to store graphs of information with support for hyperlinks. JSON-LD is the native format for AMF-parsed graph models.
#
Using vocabularies for custom semanticsAML allows users to define the semantics for metadata documents in AML Vocabulary files.
The file aml/quickstart/geolocation.yaml
contains a vocabulary defining a few terms for a custom geolocation vocabulary:
geolocation.yaml
We could modify our dialect to generate a new version that uses the AML Vocabulary for geolocation we have just reviewed:
places_2.yaml
Now, we can parse documents that include geographical coordinates like:
golden_gate_2.yaml
The geographical information will appear in the graph using the semantic terms defined in our geolocation vocabulary:
#
Validating metadata documentsIf 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:
piccadilly_circus_error.yaml
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.