TheorySerializer

A Serializer of whole Theory instances, e.g. to persist a knowledge base to disk or send it to another process (or tool, possibly written in another language) as JSON, YAML, or XML. Internally, a TheorySerializer objectifies the Theory via TheoryObjectifier (which in turn objectifies each it.unibo.tuprolog.core.Clause with TermObjectifier into a plain list) and then writes that list in the requested MimeType.

Usage example:

val serializer: TheorySerializer = TheorySerializer.of(MimeType.Json)
val theory: Theory = Theory.of(Unificator.default, Rule.of(Atom.of("foo"), Atom.of("bar")))
val json: String = serializer.serialize(theory) // [{"head":"foo","body":"bar"}]

See also

for the inverse operation.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val mimeType: MimeType

Functions

Link copied to clipboard
abstract fun serialize(value: Theory): String
Link copied to clipboard
abstract fun serializeMany(values: Iterable<Theory>): String
open fun serializeMany(values: Sequence<Theory>): String
open fun serializeMany(vararg values: Theory): String