JSON-LD type for custom vote count property


#1

For Prismo and for other link aggregators that implement ActivityPub we need to add a custom property on Objects that shows the number of Likes, or the aggregate sum of Likes/Dislikes activities on that object.

Prismo currently exposes the “votes” property for this scope, with the following JSON-LD defined context:

{
  "votes": {
    "@id": "as:votes",
    "@type": "@id"
  }
}

First problem is that the “@type” should be “xsd:integer”, not “@id”. The former should represent a resolvable IRI pointing to a resource.

Then, it shouldn’t use the “as” namespace, as the ActivityStreams doesn’t contain a votes property.

The last issue - and the more important one - is that the name somewhat assumes that the number represents the full count of votes an item received.

For Prismo that might be OK, as it doesn’t seem to allow downvotes, but other platforms might want to support that.

This is why I would like to propose a different property, called “score”, which as it’s basic level would represent the difference between upvotes and downvotes - or any algorithm that the platform uses to compute this value.

The JSON-LD representation would be the similar with I mentioned before:

{
    "@context": {
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "littr": "https://littr.me/ns#",
        "score": {
            "@id": "littr:score",
            "@type": "xsd:integer"
        }
    }
}

Thank you for reading, I’d like to know what everyone thinks.


#2

I forgot to add it as an option to the original proposal. Schema.org has separate properties for upvotes and downvotes (https://schema.org/upvoteCount, https://schema.org/downvoteCount)

However they seem a bit complicated for my liking:

{
    "@context": {
        "dct": "http://purl.org/dc/terms/",
        "owl": "http://www.w3.org/2002/07/owl#",
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfa": "http://www.w3.org/ns/rdfa#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "schema": "http://schema.org/",
        "xsd": "http://www.w3.org/2001/XMLSchema#"
    },
    "@id": "schema:upvoteCount",
    "@type": "rdf:Property",
    "rdfs:comment": "The number of upvotes this question, answer or comment has received from the community.",
    "rdfs:label": "upvoteCount",
    "schema:domainIncludes": [
        {
            "@id": "schema:Comment"
        },
        {
            "@id": "schema:Question"
        }
    ],
    "schema:rangeIncludes": {
        "@id": "schema:Integer"
    },
    "schema:sameAs": {
        "@id": "https://schema.org/upvoteCount"
    }
}