Core Concepts/Components

Literal (Property)

Understanding Literals as the properties in a Knowledge Graph.

See the documentation for the Literal Value model.

Literals as Labels and Properties in a Knowledge Graph

In a standard knowledge graph, labels and properties provide descriptive information about entities (nodes) and relations (edges). Labels often classify the type of a node or edge, while properties are attributes that further describe them with data values.

These can include categorical or numerical values such as a name, a date, a number, or a description. They enrich the graph by providing context and specific details, allowing for a more nuanced representation of knowledge beyond simple connections.

Literals in the Perseus Client

A LiteralValue in the Perseus Client functions as a property associated with an entity (node) or a relation (edge). It's a data value that provides a specific attribute about the entity or the relationship.

The value field of a LiteralValue object can hold any standard data type, such as a string, integer, float, or boolean. This flexibility allows for a rich and precise description of your data.

Additionally, a LiteralValue can specify an optional datatype field, which is a URI indicating the precise data type of the value. This is especially useful for semantic web standards like RDF, where explicit datatype URIs (e.g., http://www.w3.org/2001/XMLSchema#decimal for decimal numbers) provide unambiguous interpretation of the literal's value.

For example, a Person entity might have a name literal with a string value like "John Doe", while a Relation might have a year literal with an integer value like 1903.

Examples of LiteralValue Objects

Here are a few examples of LiteralValue objects with different data types and explicit datatypes in the Perseus Client.

String without explicit datatype (default):

LiteralValue(value="Apartment at 42 Rue Oberkampf, 75011 Paris")

Float with unit datatype:

LiteralValue(value=82.3, datatype="http://qudt.org/vocab/unit/squareMetre")

Integer with currency datatype:

LiteralValue(value=780000, datatype="https://example.org/ontology/currency/EUR")

Integer with year datatype:

LiteralValue(value=2021, datatype="http://www.w3.org/2001/XMLSchema#gYear")

Float with decimal datatype:

LiteralValue(value=1.35, datatype="http://www.w3.org/2001/XMLSchema#decimal")