Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
melvincarvalho committed Jan 11, 2025
1 parent f7c7f57 commit 6f7aeb6
Show file tree
Hide file tree
Showing 10 changed files with 578 additions and 2 deletions.
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# agent
agent ontology
# Agent Vocabulary

A simple vocabulary for describing Agents and agency relationships.

## Overview

This vocabulary defines:

- The concept of an Agent - an entity that has agency and can act independently
- A property to link any Thing to an Agent that has agency over it

## Namespace

The namespace for this vocabulary is `https://w3id.org/agent#`

## Classes

### Agent

An entity that has agency - the capacity to act independently and make free choices.

## Properties

### agent

Links a Thing to an Agent that has agency over it.

- Domain: owl:Thing
- Range: agent:Agent

## Status

This document is a draft vocabulary specification.

## License

This vocabulary is available under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).

---
7 changes: 7 additions & 0 deletions context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": {
"@version": 1.1,
"Agent": "https://w3id.org/agent#Agent",
"agent": "https://w3id.org/agent#agent"
}
}
96 changes: 96 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Agent Vocabulary</title>
<link href="./vocab.json" rel="alternate" type="application/json" />
<link href="./vocab.jsonld" rel="alternate" type="application/ld+json" />
<link rel="stylesheet" href="./style.css" />
<script type="application/ld+json" id="data">
{
"@context": {
"dc": "http://purl.org/dc/elements/1.1/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"owl": "http://www.w3.org/2002/07/owl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"terms": "http://www.w3.org/2003/06/sw-vocab-status/ns#",
"agent": "https://w3id.org/agent#",
"description": {
"@id": "dc:description",
"@type": "xsd:string"
},
"title": {
"@id": "dc:title",
"@type": "xsd:string"
},
"comment": {
"@id": "rdfs:comment",
"@type": "xsd:string"
},
"label": {
"@id": "rdfs:label",
"@type": "xsd:string"
},
"term_status": {
"@id": "terms:term_status",
"@type": "xsd:string"
},
"type": {
"@id": "rdf:type",
"@type": "@id"
},
"domain": {
"@id": "rdfs:domain",
"@type": "@id"
},
"range": {
"@id": "rdfs:range",
"@type": "@id"
},
"isDefinedBy": {
"@id": "rdfs:isDefinedBy",
"@type": "@id"
},
"Property": "rdfs:Property",
"Class": "rdfs:Class"
},
"@graph": [
{
"@id": "agent:",
"@type": "owl:Ontology",
"description": "This vocabulary defines the concept of an Agent - an entity that has agency and can act independently.",
"title": "Agent vocabulary"
},
{
"@id": "agent:Agent",
"@type": "rdfs:Class",
"comment": "An entity that has agency - the capacity to act independently and make free choices.",
"label": "Agent",
"term_status": "stable"
},
{
"@id": "agent:agent",
"@type": ["rdfs:Property"],
"comment": "Links a Thing to an Agent that has agency over it.",
"domain": {
"@id": "owl:Thing"
},
"isDefinedBy": {
"@id": "agent:"
},
"label": "agent",
"range": {
"@id": "agent:Agent"
},
"term_status": "stable"
}
]
}
</script>
</head>

<script type="module" src="./js/app.js"></script>

<body></body>
</html>
109 changes: 109 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { html, Component, render } from '../js/spux.js'
import '../js/dior.js'

const json = di.data['@graph']

async function getVersion () {
try {
const response = await fetch('https://sandy-mount.github.io/agent/package.json')
const data = await response.json()
return data.version
} catch (error) {
console.warn('Failed to fetch package.json, falling back to version 0.0.1:', error)
return '0.0.1'
}
}

function Ontology (props) {
return html`
<div>
<h1>${props.title}</h1>
<p>${props.description}</p>
<p style="font-style: italic;">Version: ${version}</p>
</div>
`
}

function Category (props) {
function handleHeadingClick (e) {
e.preventDefault()
const id = e.target.id
window.history.pushState(null, null, `#${id}`)
}

return html`
<div>
<h1 id="${props.label}" onClick=${handleHeadingClick}>${props.label}</h1>
<p>Comment: ${props.comment}</p>
<p>Term status: ${props.termStatus}</p>
</div>
`
}

function App () {
const ontology = json.find(item => item['@type'] === 'owl:Ontology')
const items = json.filter(item => item['@type'].includes('rdfs:Class'))

const properties = json.filter(item =>
item['@type'].includes('rdfs:Property')
)


const githubUrl = 'https://github.com/sandy-mount/agent/'

return html`
<a href="${githubUrl}" class="github-fork">
<img
decoding="async"
loading="lazy"
width="149"
height="149"
src="https://github.blog/wp-content/uploads/2008/12/forkme_right_white_ffffff.png?resize=149%2C149"
class="attachment-full size-full"
alt="Fork me on GitHub"
data-recalc-dims="1"
/>
</a>
<header class="w3c-header">
<h1><a style="text-decoration: none" href="${githubUrl}" target="_blank" rel="noopener noreferrer">Agent Vocabulary</a></h1>
<h2>Community Draft</h2>
</header>
<div class="container">
<${Ontology} title=${ontology.title} description=${ontology.description} />
<hr />
${items.map(
item => html`
<div class="property-block">
<${Category}
label="${item.label}"
comment=${item.comment}
termStatus=${item.term_status}
/>
</div>
`
)}
<hr />
${properties.map(
item => html`
<div class="property-block">
<${Category}
label="${item.label}"
comment=${item.comment}
termStatus=${item.term_status}
/>
</div>
`
)}
</div>
`
}

var version = await getVersion()
// console.log('version', version)

render(html`<${App} />`, document.body)
26 changes: 26 additions & 0 deletions js/dior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
;(() => {
globalThis.qs = Object.fromEntries(
new URLSearchParams(document.location.search)
)

globalThis.di = new Proxy(
Array.from(
document.querySelectorAll(
'script[type="application/ld+json"], script[type="application/json"]'
)
)
.map(island => [island.id, JSON.parse(island.text || JSON.stringify(''))])
.reduce((obj, item) => {
obj[item[0]] = item[1]
return obj
}, {}),
{
set: (obj, prop, value) => {
obj[prop] = value
var island = document.getElementById(prop)
island.text = JSON.stringify(value, null, 2)
return true
}
}
)
})()
Loading

0 comments on commit 6f7aeb6

Please sign in to comment.