{"id":27118611,"url":"https://github.com/doga/object-semantic-mapping","last_synced_at":"2025-04-07T07:59:10.228Z","repository":{"id":228606449,"uuid":"774326963","full_name":"doga/object-semantic-mapping","owner":"doga","description":"OSM is similar to ORM, except that it is for semantic data.","archived":false,"fork":false,"pushed_at":"2024-11-05T19:05:43.000Z","size":118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-05T20:21:57.665Z","etag":null,"topics":["es6-javascript","framework","javascript-library","object-semantic-mapping","rdf","runnable-readme","semantic-web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-19T11:02:34.000Z","updated_at":"2024-11-05T19:05:46.000Z","dependencies_parsed_at":"2024-03-23T00:45:25.951Z","dependency_job_id":"93643a03-823d-4f98-9474-99f8856f066c","html_url":"https://github.com/doga/object-semantic-mapping","commit_stats":null,"previous_names":["doga/object-semantic-mapping"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fobject-semantic-mapping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fobject-semantic-mapping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fobject-semantic-mapping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fobject-semantic-mapping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doga","download_url":"https://codeload.github.com/doga/object-semantic-mapping/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615458,"owners_count":20967183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es6-javascript","framework","javascript-library","object-semantic-mapping","rdf","runnable-readme","semantic-web"],"created_at":"2025-04-07T07:59:09.698Z","updated_at":"2025-04-07T07:59:10.204Z","avatar_url":"https://github.com/doga.png","language":"JavaScript","readme":"\u003cp align=\"left\"\u003e\n\u003ca href=\"https://qworum.net\" target=\"_blank\" rel=\"noreferrer\"\u003e\u003cimg src=\"https://github.com/doga/doga/raw/main/logos/rdf.svg\" height=\"85\" alt=\"Qworum\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Object-semantic mapping\n\nObject-semantic mapping (OSM) is like [ORM](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping), but for [RDF](https://www.w3.org/TR/rdf-primer/).\n\nThis ES6 JavaScript library defines a base model for creating in-memory model instances, and for reading models from and writing models to [DatasetCore](https://rdf.js.org/dataset-spec/#datasetcore-interface)-compliant datasets.\n\nApplications would normally use subclasses that extend the base `Model` class. To illustrate how this is done, this library contains a `Person` model.\n\nThis library is intended as a solid foundation for building OSM models on, and for making RDF easy to manipulate by applications.\n\n## Some projects that are using this library\n\n[Template for a Qworum application that uses RDF data](https://github.com/doga/qworum-application-template-with-semantic-data).\n\n## How to import this library\n\n- `import * as OSM from 'https://esm.sh/gh/doga/object-semantic-mapping@1.1.2/mod.mjs';`\n\n## Usage examples\n\n_Tip: Run the examples below by typing this in your terminal (requires [Deno](https://deno.com/) 2+):_\n\n```shell\ndeno run \\\n  --allow-net --allow-run --allow-env --allow-read \\\n  jsr:@andrewbrey/mdrb@3.0.4 \\\n  --dax=false \\\n  https://raw.githubusercontent.com/doga/object-semantic-mapping/master/README.md\n```\n\n\u003cdetails data-mdrb\u003e\n\u003csummary\u003eExample: Create a model instance, and write it to an RDF dataset.\u003c/summary\u003e\n\n\u003cpre\u003e\ndescription = '''\nRunning this code is safe.\n'''\n\u003c/pre\u003e\n\u003c/details\u003e\n\n```javascript\nimport { Model, IRI } from 'https://esm.sh/gh/doga/object-semantic-mapping@1.1.2/mod.mjs';\nimport { Store, Writer } from 'https://esm.sh/gh/doga/N3@1.18.2/mod.mjs';\nconst {schema} = Model.wellKnownPrefixes;\n\nawait demo();\n\nasync function demo() {\n  console.info(`Creating new model instance ..`);\n  const\n  modelId   = IRI.parse('urn:isbn:0451450523'),\n  modelType = IRI.parse(`${schema}Product`),\n  model     = new Model(modelId, {types: modelType});\n\n  console.info(`${model}`);\n\n  console.info(`\\nWriting the model instance to an empty dataset ..`);\n  const store = new Store();\n  model.writeTo(store);\n\n  // Non-standard way of printing out the dataset\n  const writer = new Writer();\n  for (const quad of store) writer.addQuad(quad);\n  writer.end((err, res) =\u003e {if (!err) console.info(`\\nUpdated dataset:\\n${res}`);});\n}\n```\n\nSample output for the code above:\n\n```text\nCreating new model instance ..\n\u003curn:isbn:0451450523\u003e a \u003chttps://schema.org/Product\u003e.\n\nWriting the model instance to an empty dataset ..\n\nUpdated dataset:\n\u003curn:isbn:0451450523\u003e a \u003chttps://schema.org/Product\u003e.\n```\n\n\u003cdetails data-mdrb\u003e\n\u003csummary\u003eExample: Read model instances from a dataset sourced from a Turtle file.\u003c/summary\u003e\n\n\u003cpre\u003e\ndescription = '''\nRunning this code is safe.\n'''\n\u003c/pre\u003e\n\u003c/details\u003e\n\n```javascript\nimport { Model, IRI } from 'https://esm.sh/gh/doga/object-semantic-mapping@1.1.2/mod.mjs';\nimport { Store, Parser } from 'https://esm.sh/gh/doga/N3@1.18.2/mod.mjs';\nconst { org } = Model.wellKnownPrefixes;\n\nawait demo();\n\nasync function demo() {\n  // build the dataset from a Turtle file\n  const\n  url          = IRI.parse('https://qworum.net/data/org.ttl'),\n  response     = await fetch(url),\n  text         = await response.text(),\n  store        = new Store(),\n  parser       = new Parser({baseIRI: `${url}`}),\n  parseHandler = (error, quad, prefixes) =\u003e {if (quad) store.add(quad);};\n\n  await parser.parse(text, parseHandler);\n\n  // read the models from the dataset\n  const models = await Model.readFrom(store, {types: IRI.parse(`${org}Organization`)});\n  for (const model of models) console.info(`${model}`);\n}\n```\n\nSample output for the code above:\n\n```text\n\u003chttps://qworum.net/data/org.ttl#id\u003e a \u003chttp://www.w3.org/ns/org#Organization\u003e.\n```\n\n\u003cdetails data-mdrb\u003e\n\u003csummary\u003eExample: Read persons from a dataset sourced from a Turtle file.\u003c/summary\u003e\n\n\u003cpre\u003e\ndescription = '''\nRunning this code is safe.\n'''\n\u003c/pre\u003e\n\u003c/details\u003e\n\n```javascript\nimport { Person, IRI } from 'https://esm.sh/gh/doga/object-semantic-mapping@1.1.2/mod.mjs';\nimport { Store, Writer, Parser } from 'https://esm.sh/gh/doga/N3@1.18.2/mod.mjs';\n\nawait demo();\n\nasync function demo() {\n  // build the dataset from a Turtle file\n  const\n  url          = IRI.parse('https://qworum.net/data/DoğaArmangil.ttl'),\n  response     = await fetch(url),\n  text         = await response.text(),\n  store        = new Store(),\n  parser       = new Parser({baseIRI: `${url}`}),\n  parseHandler = (error, quad, prefixes) =\u003e {if (quad) store.add(quad);};\n  await parser.parse(text, parseHandler);\n\n  // read the persons from the dataset\n  const persons = await Person.readFrom(store);\n\n  for (const person of persons){\n    console.info(`\\n${person.id}`);\n\n    // add in-memory data\n    person.emails.add('an@email.example');\n\n    const \n    names  = await person.getNames(),\n    olbs   = await person.getOneLineBios(),\n    emails = await person.getEmails();\n\n    for (const name  of names)              console.info(`  name: ${name}`);\n    for (const olb   of olbs)               console.info(`  one-line bio: ${olb}`);\n    for (const email of emails)             console.info(`  email: ${email}`);\n    for (const name  of person.names)       console.info(`  in-memory name: ${name}`);\n    for (const olb   of person.oneLineBios) console.info(`  in-memory one-line bio: ${olb}`);\n    for (const email of person.emails)      console.info(`  in-memory email: ${email}`);\n  }\n\n  console.info(`\\nWriting the persons' ID, type(s) and in-memory data to an empty dataset ..`);\n  const store2 = new Store();\n  for(const person of persons) await person.writeTo(store2);\n\n  // Non-standard way of printing out the dataset\n  const writer = new Writer();\n  for (const quad of store2) writer.addQuad(quad);\n  writer.end((err, res) =\u003e {if (!err) console.info(`\\nUpdated dataset:\\n${res}`);});\n}\n```\n\nSample output for the code above:\n\n```text\nhttps://qworum.net/data/DoğaArmangil.ttl#id\n  name: Doğa Armangil\n  one-line bio: \"EPFL software engineer living in Switzerland. Patent author. Business owner in software.\"@en\n  email: d.armangil@qworum.net\n  email: doga.armangil@alumni.epfl.ch\n  in-memory email: an@email.example\n\nWriting the persons' ID, type(s) and in-memory data to an empty dataset ..\n\nUpdated dataset:\n\u003chttps://qworum.net/data/DoğaArmangil.ttl#id\u003e a \u003chttp://xmlns.com/foaf/0.1/Person\u003e, \u003chttps://schema.org/Person\u003e, \u003chttp://sparql.cwrc.ca/ontologies/cwrc#NaturalPerson\u003e, \u003chttp://www.w3.org/ns/prov#Agent\u003e;\n    \u003chttp://xmlns.com/foaf/0.1/mbox\u003e \u003cmailto:an@email.example\u003e.\n```\n\n∎\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoga%2Fobject-semantic-mapping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoga%2Fobject-semantic-mapping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoga%2Fobject-semantic-mapping/lists"}