I'm using protege 5 and trying to convert a questionnaire to an ontology. And I cant figure out how to model a multiple choice answer. I have a class (Class1) which has elements and for each element a person can select one or more of allowed values. Eg: ElementOne : "someStringValue1", "someStringValue2", "someStringValue3", someStringValue4" . And the user can pick "someStringValue1" and "someStringValue2".
Any ideas how to model this in protege and owl?
You can use enumerated classes to model a fixed set of choices. E.g., you can say things like
Question2Answers ≡ {"choice a", "choice b", "choice c", "none of the above"}
question2 ⊑ ∀ hasAnswer.Question2Answers
Here's an ontology you can download and see examples. In it, I've declared two question individuals, and three answer individuals. I've defined two properties hasObjectAnswer and hasDataAnswer, so you can either use individuals or datatyped literals as answers. I've said that the possible answers for question1 are answerA, answerB, and answerC, by asserting that
question1 ⊑ ∀ hasObjectAnswer.{answerA, answerB, answerC}
I've said that the possible answers for question2 are "answer one", "answer two", "answer three", and "none of the above" by using the axiom:
question2 ⊑ ∀ hasDataAnswer.{"answer one", …, "none of the above"}
@prefix : <urn:ex:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:answerB a owl:Thing , owl:NamedIndividual .
:question2 a owl:Thing , owl:NamedIndividual ;
a [ a owl:Restriction ;
owl:allValuesFrom [ a rdfs:Datatype ;
owl:oneOf ("answer one" "answer two" "answer three" "none of the above")
] ;
owl:onProperty :hasDataAnswer
] .
:answerA a owl:Thing , owl:NamedIndividual .
:question1 a owl:Thing , owl:NamedIndividual ;
a [ a owl:Restriction ;
owl:allValuesFrom [ a owl:Class ;
owl:oneOf ( :answerC :answerB :answerA )
] ;
owl:onProperty :hasObjectAnswer
] .
:hasObjectAnswer a owl:ObjectProperty .
:hasDataAnswer a owl:DatatypeProperty .
:answerC a owl:Thing , owl:NamedIndividual .