Skip to content

Instantly share code, notes, and snippets.

@vital-edu
Last active July 9, 2018 06:18
Show Gist options
  • Save vital-edu/fb7193809c1ec20ab8a3c9ebe18aabb4 to your computer and use it in GitHub Desktop.
Save vital-edu/fb7193809c1ec20ab8a3c9ebe18aabb4 to your computer and use it in GitHub Desktop.
Nexte Ontology
@prefix : <http://nexte.io/ontology/>.
@prefix users: <http://nexte.io/users/>.
@prefix rules: <http://nexte.io/rules/>.
@prefix challenges: <http://nexte.io/challenges/>.
@prefix clubs: <http://nexte.io/clubs/>.
@prefix rankings: <http://nexte.io/rankings/>.
@prefix positions: <http://nexte.io/positions/>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix sport: <http://iptc.org/std/nar/2006-10-01/>.
@prefix event: <http://purl.org/NET/c4dm/event.owl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix time: <http://www.w3.org/2006/time#>.
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>.
#################################################################
# Classes
#################################################################
:ClasseComNome rdf:type owl:Class.
:QuadraDeTenis rdfs:subClassOf geo:SpatialThing.
:Desafio rdfs:subClassOf event:Event.
:Posicao rdfs:subClassOf :ClasseComNome.
:Ranking rdfs:subClassOf :ClasseComNome.
:Regra rdfs:subClassOf :ClasseComNome.
:Status rdfs:subClassOf :ClasseComNome.
:Tenista rdfs:subClassOf foaf:Agent, :ClasseComNome.
:RegraDeAtivacaoDeTenista rdfs:subClassOf :Regra.
:RegraDeDesativacaoDeTenista rdfs:subClassOf :Regra.
:RegraDeCriacaoDeDesafio rdfs:subClassOf :Regra.
:RegraDeReposicionamento rdfs:subClassOf :Regra.
:RegraDeReposicionamentoPorGanhoEPerdaDePosicoes rdfs:subClassOf :RegraDeReposicionamento.
:RegraDeReposicionamentoPorGanhoEPerdaDePontos rdfs:subClassOf :RegraDeReposicionamento.
:RegraDeReposicionamentoPorTrocaDePosicoes rdfs:subClassOf :RegraDeReposicionamento.
#################################################################
# Object Properties
#################################################################
:ocorreNo rdf:type owl:ObjectProperty, owl:IrreflexiveProperty, owl:FunctionalProperty;
rdfs:domain :Desafio;
rdfs:range :QuadraDeTenis.
:ocupaPosicao rdf:type owl:ObjectProperty, owl:IrreflexiveProperty, owl:FunctionalProperty;
rdfs:domain :Tenista;
rdfs:range :Posicao.
:ocupadaPor rdf:type owl:ObjectProperty, owl:FunctionalProperty;
rdfs:domain :Posicao;
rdfs:range :Tenista;
owl:inverseOf :ocupaPosicao.
:participa rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Tenista;
rdfs:range :Desafio.
:possuiRegra rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Ranking;
rdfs:range :Regra.
:influenciaRanking rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Regra;
rdfs:range :Ranking;
owl:inverseOf :possuiRegra.
:compostoPor rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Ranking;
rdfs:range :Posicao.
:ocorreEm rdf:type owl:ObjectProperty, owl:IrreflexiveProperty, owl:FunctionalProperty;
rdfs:domain :Desafio;
rdfs:range time:GeneralDateTimeDescription.
:possuiStatus rdf:type owl:ObjectProperty, owl:IrreflexiveProperty, owl:FunctionalProperty;
rdfs:domain :Desafio;
rdfs:range :Status.
:possuiVencedor rdf:type owl:ObjectProperty, owl:IrreflexiveProperty, owl:FunctionalProperty;
rdfs:domain :Desafio;
rdfs:range :Tenista.
:possuiPerdedor rdf:type owl:ObjectProperty, owl:IrreflexiveProperty, owl:FunctionalProperty;
rdfs:domain :Desafio;
rdfs:range :Tenista;
owl:propertyDisjointWith :possuiVencedor.
:teveComoDesafiante rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Desafio;
rdfs:range :Tenista.
:teveComoDesafiado rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Desafio;
rdfs:range :Tenista.
:participaComoDesafiante rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Tenista;
rdfs:range :Desafio;
owl:inverseOf :teveComoDesafiante;
rdfs:subPropertyOf :participa.
:participaComoDesafiado rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Tenista;
rdfs:range :Desafio;
rdfs:subPropertyOf :participa;
owl:inverseOf :teveComoDesafiado;
owl:propertyDisjointWith :participaComoDesafiante.
:venceuDesafio rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Tenista;
rdfs:range :Desafio;
owl:inverseOf :possuiVencedor.
:perdeuDesafio rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :Tenista;
rdfs:range :Desafio;
owl:inverseOf :possuiPerdedor;
owl:propertyDisjointWith :venceuDesafio.
:adicionaTenistaAoRanking rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :RegraDeAtivacaoDeTenista;
rdfs:range :Tenista.
:removeTenistaDoRanking rdf:type owl:ObjectProperty, owl:IrreflexiveProperty;
rdfs:domain :RegraDeDesativacaoDeTenista;
rdfs:range :Tenista.
#################################################################
# Data Type Properties
#################################################################
:temNome rdf:type owl:DatatypeProperty;
rdfs:domain :ClasseComNome;
rdfs:range xsd:string.
:temDescricao rdf:type owl:DatatypeProperty;
rdfs:domain :Regra;
rdfs:range xsd:string.
:temValor rdf:type owl:DatatypeProperty;
rdfs:domain :Posicao;
rdfs:range xsd:nonNegativeInteger.
:vencedorDeDesafioGanhaPosicoes rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeReposicionamentoPorGanhoEPerdaDePosicoes;
rdfs:range xsd:nonNegativeInteger.
:perdedorDeDesafioPerdePosicoes rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeReposicionamentoPorGanhoEPerdaDePosicoes;
rdfs:range xsd:nonNegativeInteger.
:vencedorDeDesafioGanhaPontos rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeReposicionamentoPorGanhoEPerdaDePontos;
rdfs:range xsd:nonNegativeInteger.
:perdedorDeDesafioPerdePontos rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeReposicionamentoPorGanhoEPerdaDePontos;
rdfs:range xsd:nonNegativeInteger.
:perdedorDeDesafioPorTrocaDeDeposicoesPerdePosicao rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeReposicionamentoPorTrocaDePosicoes;
rdfs:range xsd:nonNegativeInteger.
:permiteDesafiarTenistasAcima rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeCriacaoDeDesafio;
rdfs:range xsd:nonNegativeInteger.
:permiteDesafiarTenistasAbaixo rdf:type owl:DatatypeProperty;
rdfs:domain :RegraDeCriacaoDeDesafio;
rdfs:range xsd:nonNegativeInteger.
#################################################################
# Exemplos
#################################################################
# Clubes ########################################################
clubs:clt rdf:type owl:NamedIndividual, :QuadraDeTenis.
# Posições ######################################################
rankings:rankingTest rdf:type owl:NamedIndividual, :Ranking;
:temNome "Ranking de Teste";
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "1º";
:temValor 1;
:ocupadaPor users:Cardoso;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "2º";
:temValor 2;
:ocupadaPor users:Anacleto;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "3º";
:temValor 3;
:ocupadaPor users:Schwanz;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "4º";
:temValor 4;
:ocupadaPor users:Souza;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "5º";
:temValor 5;
:ocupadaPor users:Neto;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "6º";
:temValor 6;
:ocupadaPor users:Cordova;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "7º";
:temValor 7;
:ocupadaPor users:Martins;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "8º";
:temValor 7;
:ocupadaPor users:Miranda;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "9º";
:temValor 9;
:ocupadaPor users:CardosoFilho;
];
:compostoPor [
rdf:type owl:NamedIndividual, :Posicao;
:temNome "10º";
:temValor 10;
:ocupadaPor users:Pasta;
].
# Tenistas ######################################################
users:Cardoso rdf:type owl:NamedIndividual, :Tenista;
:temNome "Bruno Cardoso".
users:Anacleto rdf:type owl:NamedIndividual, :Tenista;
:temNome "Jean Anacleto".
users:Schwanz rdf:type owl:NamedIndividual, :Tenista;
:temNome "Tarcisio Schwanz".
users:Souza rdf:type owl:NamedIndividual, :Tenista;
:temNome "Fábio Souza".
users:Neto rdf:type owl:NamedIndividual, :Tenista;
:temNome "João Neto".
users:Cordova rdf:type owl:NamedIndividual, :Tenista;
:temNome "Clóvis Cordova".
users:Martins rdf:type owl:NamedIndividual, :Tenista;
:temNome "Jorge Martins".
users:Miranda rdf:type owl:NamedIndividual, :Tenista;
:temNome "Ramires de Miranda".
users:CardosoFilho rdf:type owl:NamedIndividual, :Tenista;
:temNome "José Cardoso Filho".
users:Pasta rdf:type owl:NamedIndividual, :Tenista;
:temNome "André Pasta".
# Desafios ######################################################
## Desafio
challenges:challenge1 rdf:type owl:NamedIndividual, :Desafio;
:ocorreEm [ # challenge date
a time:GeneralDateTimeDescription;
:day "---01"^^:generalDay;
:year "2018"^^:generalYear;
];
:ocorreNo clubs:clt;
:possuiStatus [
:temNome "Jogado";
];
:teveComoDesafiante: users:Pasta;
:teveComoDesafiado: users:CardosoFilho;
:possuiVencedor users:CardosoFilho;
:possuiPerdedor users:Pasta.
# Regras ########################################################
rankings:regra1 rdf:type owl:NamedIndividual, :RegraDeAtivacaoDeTenista;
:temNome "Entre em último";
:temDescricao "O jogador ativado ocupa automaticamente a última posição do ranking.".
rankings:regra2 rdf:type owl:NamedIndividual, :RegraDeDesativacaoDeTenista;
:temNome "Perde posição até sair do ranking";
:temDescricao "O jogador desativado perde 1 posição a cada semana que esteja desativado e quando ocupa a última posição, é removido do ranking.".
rankings:regra3 rdf:type owl:NamedIndividual, :RegraDeCriacaoDeDesafio;
:temNome "5 para cima";
:temDescricao "O jogador só pode desafiar os 5 jogadores logo acima no ranking.".
rankings:regra4 rdf:type owl:NamedIndividual, :RegraDeReposicionamentoPorTrocaDePosicoes;
:temNome "Ganhador ocupa posição do vencedor";
:temDescricao "O jogador que ganha um desafio, ocupa a posição do perdedor. O perdedor desce uma posição no ranking.";
:perdedorDeDesafioPorTrocaDeDeposicoesPerdePosicao 1.
rankings:rankingTest :possuiRegra rankings:regra1, rankings:regra2, rankings:regra3, rankings:regra4.
# Get Ranking
PREFIX : <http://nexte.io/ontology/>
SELECT DISTINCT ?nomeDoTenista ?posicao
WHERE {
?x :compostoPor ?position.
?position :temNome ?posicao;
:ocupadaPor ?tenista.
?tenista :temNome ?nomeDoTenista.
}
# Get rules from ranking
PREFIX : <http://nexte.io/ontology/>
SELECT DISTINCT ?Nome ?Descricao
WHERE {
?ranking :possuiRegra ?regra.
?regra :temDescricao ?Descricao;
:temNome ?Nome
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment