private String unquoteLiteral(String tok) { String lit = ""; if (!tok.endsWith("\"")) { consumeToken(); throw new ExceptionBuilder().withKeyword("\"").build(); } if (tok.length() > 2) { lit = tok.substring(1, tok.length() - 1); } return verifyNotNull(lit); }
private OWLDataRange parseDataOneOf() { consumeToken(); Set<OWLLiteral> cons = new HashSet<>(); String sep = COMMA.keyword(); while (COMMA.matches(sep)) { OWLLiteral con = parseLiteral(null); cons.add(con); sep = consumeToken(); } if (!CLOSEBRACE.matches(sep)) { throw new ExceptionBuilder().withKeyword(COMMA, CLOSEBRACE).build(); } return df.getOWLDataOneOf(cons); }
private void consumeToken(ManchesterOWLSyntax expected) { String tok = consumeToken(); if (!expected.matches(tok)) { throw new ExceptionBuilder().withKeyword(expected).build(); } }
@Override public Set<OntologyAxiomPair> parseValuePartitionFrame() { String section = consumeToken(); if (!VALUE_PARTITION.matches(section)) { throw new ExceptionBuilder().withKeyword(VALUE_PARTITION).build(); } OWLObjectPropertyExpression prop = parseObjectPropertyExpression(false); String clsName = consumeToken(); if (eof(clsName)) { throw new ExceptionBuilder().withObject().build(); } OWLClass cls = getOWLClass(clsName); Set<OntologyAxiomPair> axioms = new HashSet<>(); Set<OWLOntology> onts = getOntologies(); axioms.addAll(parseValuePartitionValues(onts, cls)); for (OWLOntology ont : onts) { axioms.add(new OntologyAxiomPair(ont, df.getOWLFunctionalObjectPropertyAxiom(prop))); axioms.add(new OntologyAxiomPair(ont, df.getOWLObjectPropertyRangeAxiom(prop, cls))); } return axioms; }
private OWLDataRange parseDataOneOf() { consumeToken(); Set<OWLLiteral> cons = new HashSet<>(); String sep = COMMA.keyword(); while (COMMA.matches(sep)) { OWLLiteral con = parseLiteral(null); cons.add(con); sep = consumeToken(); } if (!CLOSEBRACE.matches(sep)) { throw new ExceptionBuilder().withKeyword(COMMA, CLOSEBRACE).build(); } return df.getOWLDataOneOf(cons); }
@Override public Set<OntologyAxiomPair> parseValuePartitionFrame() { String section = consumeToken(); if (!VALUE_PARTITION.matches(section)) { throw new ExceptionBuilder().withKeyword(VALUE_PARTITION).build(); } OWLObjectPropertyExpression prop = parseObjectPropertyExpression(false); String clsName = consumeToken(); if (eof(clsName)) { throw new ExceptionBuilder().withObject().build(); } OWLClass cls = getOWLClass(clsName); Set<OntologyAxiomPair> axioms = new HashSet<>(); Set<OWLOntology> onts = getOntologies(); axioms.addAll(parseValuePartitionValues(onts, cls)); for (OWLOntology ont : onts) { axioms.add(new OntologyAxiomPair(ont, df.getOWLFunctionalObjectPropertyAxiom(prop))); axioms.add(new OntologyAxiomPair(ont, df.getOWLObjectPropertyRangeAxiom(prop, cls))); } return axioms; }
private void consumeToken(ManchesterOWLSyntax expected) { String tok = consumeToken(); if (!expected.matches(tok)) { throw new ExceptionBuilder().withKeyword(expected).build(); } }
protected IRI parseIRI() { String iriString = consumeToken(); if (!(iriString.startsWith("<") && iriString.endsWith(">"))) { throw new ExceptionBuilder().withKeyword("<$IRI$>").build(); } return IRI.create(iriString.substring(1, iriString.length() - 1)); }
private OWLDataRange parseDataOneOf() { consumeToken(); Set<OWLLiteral> cons = new HashSet<>(); String sep = COMMA.keyword(); while (COMMA.matches(sep)) { OWLLiteral con = parseLiteral(null); cons.add(con); sep = consumeToken(); } if (!CLOSEBRACE.matches(sep)) { throw new ExceptionBuilder().withKeyword(COMMA, CLOSEBRACE).build(); } return df.getOWLDataOneOf(cons); }
@Override public Set<OntologyAxiomPair> parseValuePartitionFrame() { String section = consumeToken(); if (!VALUE_PARTITION.matches(section)) { throw new ExceptionBuilder().withKeyword(VALUE_PARTITION).build(); } OWLObjectPropertyExpression prop = parseObjectPropertyExpression(false); String clsName = consumeToken(); if (eof(clsName)) { throw new ExceptionBuilder().withObject().build(); } OWLClass cls = getOWLClass(clsName); Set<OntologyAxiomPair> axioms = new HashSet<>(); Set<OWLOntology> onts = getOntologies(); axioms.addAll(parseValuePartitionValues(onts, cls)); for (OWLOntology ont : onts) { axioms.add(new OntologyAxiomPair(ont, df.getOWLFunctionalObjectPropertyAxiom(prop))); axioms.add(new OntologyAxiomPair(ont, df.getOWLObjectPropertyRangeAxiom(prop, cls))); } return axioms; }
private void consumeToken(ManchesterOWLSyntax expected) { String tok = consumeToken(); if (!expected.matches(tok)) { throw new ExceptionBuilder().withKeyword(expected).build(); } }
private SWRLIArgument parseIObject() { String s = peekToken(); if (isIndividualName(s)) { return parseIIndividualObject(); } else if ("?".equals(s)) { return parseIVariable(); } else { consumeToken(); throw new ExceptionBuilder().withInd().withKeyword("?$var$").build(); } }
private OWLDataRange parseDataOneOf() { consumeToken(); Set<OWLLiteral> cons = new HashSet<>(); String sep = COMMA.keyword(); while (COMMA.matches(sep)) { OWLLiteral con = parseLiteral(null); cons.add(con); sep = consumeToken(); } if (!CLOSEBRACE.matches(sep)) { throw new ExceptionBuilder().withKeyword(COMMA, CLOSEBRACE).build(); } return df.getOWLDataOneOf(cons); }
@Override public Set<OntologyAxiomPair> parseValuePartitionFrame() { String section = consumeToken(); if (!VALUE_PARTITION.matches(section)) { throw new ExceptionBuilder().withKeyword(VALUE_PARTITION).build(); } OWLObjectPropertyExpression prop = parseObjectPropertyExpression(false); String clsName = consumeToken(); if (eof(clsName)) { throw new ExceptionBuilder().withObject().build(); } OWLClass cls = getOWLClass(clsName); Set<OntologyAxiomPair> axioms = new HashSet<>(); Set<OWLOntology> onts = getOntologies(); axioms.addAll(parseValuePartitionValues(onts, cls)); for (OWLOntology ont : onts) { axioms.add(new OntologyAxiomPair(ont, df.getOWLFunctionalObjectPropertyAxiom(prop))); axioms.add(new OntologyAxiomPair(ont, df.getOWLObjectPropertyRangeAxiom(prop, cls))); } return axioms; }
private void consumeToken(ManchesterOWLSyntax expected) { String tok = consumeToken(); if (!expected.matches(tok)) { throw new ExceptionBuilder().withKeyword(expected).build(); } }
private Set<OntologyAxiomPair> parseClassFrame(boolean eof) { String tok = consumeToken(); if (!CLASS.matches(tok)) { throw new ExceptionBuilder().withKeyword(CLASS).build(); } String subj = consumeToken(); OWLClass cls = getOWLClass(subj); Set<OntologyAxiomPair> axioms = new HashSet<>(); axioms.add(new OntologyAxiomPair(defaultOntology, df.getOWLDeclarationAxiom(cls))); parseFrameSections(eof, axioms, cls, classFrameSections); return axioms; }
protected OWLDataPropertyCharacteristicAxiom parseDataPropertyCharacteristic( OWLDataPropertyExpression prop) { String characteristic = consumeToken(); if (FUNCTIONAL.matches(characteristic)) { return df.getOWLFunctionalDataPropertyAxiom(prop); } else { throw new ExceptionBuilder().withKeyword(FUNCTIONAL).build(); } }
private Set<OntologyAxiomPair> parseClassFrame(boolean eof) { String tok = consumeToken(); if (!CLASS.matches(tok)) { throw new ExceptionBuilder().withKeyword(CLASS).build(); } String subj = consumeToken(); OWLClass cls = getOWLClass(subj); Set<OntologyAxiomPair> axioms = new HashSet<>(); axioms.add(new OntologyAxiomPair(defaultOntology, df.getOWLDeclarationAxiom(cls))); parseFrameSections(eof, axioms, cls, classFrameSections); return axioms; }
protected OWLDataPropertyCharacteristicAxiom parseDataPropertyCharacteristic( OWLDataPropertyExpression prop) { String characteristic = consumeToken(); if (FUNCTIONAL.matches(characteristic)) { return df.getOWLFunctionalDataPropertyAxiom(prop); } else { throw new ExceptionBuilder().withKeyword(FUNCTIONAL).build(); } }
private Set<OntologyAxiomPair> parseClassFrame(boolean eof) { String tok = consumeToken(); if (!CLASS.matches(tok)) { throw new ExceptionBuilder().withKeyword(CLASS).build(); } String subj = consumeToken(); OWLClass cls = getOWLClass(subj); Set<OntologyAxiomPair> axioms = new HashSet<>(); axioms.add(new OntologyAxiomPair(defaultOntology, df.getOWLDeclarationAxiom(cls))); parseFrameSections(eof, axioms, cls, classFrameSections); return axioms; }