1a38107941725211e7c3f051f7a8f5e12199f03acmaeder{-# LANGUAGE DeriveDataTypeable #-}
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance{- |
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerModule : ./OWL2/AS.hs
81ec673ac5ab1493568d9ef7798b752ab8ee0e61Felix Gabriel ManceCopyright : (c) C. Maeder, Felix Gabriel Mance
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel ManceLicense : GPLv2 or higher, see LICENSE.txt
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiMaintainer : Alexander.Koslowski@st.ovgu.de
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel ManceStability : provisional
5d801400993c9671010d244646936d8fd435638cChristian MaederPortability : portable
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel ManceOWL 2 Functional Syntax constructs
aa0ca44e856c87db27e61687cbb630f270976da1Felix Gabriel Mance
5d801400993c9671010d244646936d8fd435638cChristian MaederReferences:
5d801400993c9671010d244646936d8fd435638cChristian Maeder <http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
5d801400993c9671010d244646936d8fd435638cChristian Maeder <http://www.w3.org/TR/owl2-manchester-syntax/>
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance-}
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
097bc9f18b722812d480df0f5c634d09cbca8e21Felix Gabriel Mancemodule OWL2.AS where
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
852bd6145634dc2832b61c44678fe539bc1682d5Christian Maederimport Common.Id
090c663fcc1593c66f39a0972326799a672760d5Christian Maederimport Common.Keywords (stringS)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowskiimport Common.IRI
f8c3d045dda224e92bf6bcb6288e1ee75ab54d1eChristian Maeder
e40758c36e3e5312669558ad189b24b3eaf10c59Mihai Codescuimport Common.Result
e40758c36e3e5312669558ad189b24b3eaf10c59Mihai Codescu
feab1106bbee4f2ea2fd48bca7106dd041e4211dFelix Gabriel Manceimport OWL2.ColonKeywords
18ff56829e5e99383ee6106584d55bcbd8ed45e7Felix Gabriel Manceimport OWL2.Keywords
668c9c725a11c0f77057152148570af853a1bc0dFelix Gabriel Mance
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederimport Data.Char (intToDigit)
1a38107941725211e7c3f051f7a8f5e12199f03acmaederimport Data.Data
668c9c725a11c0f77057152148570af853a1bc0dFelix Gabriel Manceimport Data.List
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Manceimport Data.Maybe
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Manceimport qualified Data.Map as Map
f8c3d045dda224e92bf6bcb6288e1ee75ab54d1eChristian Maederimport qualified Data.Set as Set
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance-- | checks if an IRI is an anonymous individual
1b1144abf7f95a4b23405b8d5604813cfe7b036aFelix Gabriel ManceisAnonymous :: IRI -> Bool
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiisAnonymous i = prefixName i == "_" && isBlankNode i
668c9c725a11c0f77057152148570af853a1bc0dFelix Gabriel Mance
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance-- | prefix -> localname
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype PrefixMap = Map.Map String String
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel MancepredefPrefixes :: PrefixMap
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel MancepredefPrefixes = Map.fromList
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel Mance [ ("owl", "http://www.w3.org/2002/07/owl#")
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel Mance , ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel Mance , ("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel Mance , ("xsd", "http://www.w3.org/2001/XMLSchema#")
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski , ("", showIRICompact dummyIRI ++ "#") ]
1b90322eaf59ded3de24fc891bd67bbd73ec2bfaFelix Gabriel Mance
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype LexicalForm = String
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype LanguageTag = String
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype ImportIRI = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype OntologyIRI = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype Class = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype Datatype = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype ObjectProperty = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype DataProperty = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancetype AnnotationProperty = IRI
9cb6af1a7632f12b60f592ce5eb2ac51e6bd33bbFelix Gabriel Mancetype Individual = IRI
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancedata EquivOrDisjoint = Equivalent | Disjoint
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowEquivOrDisjoint :: EquivOrDisjoint -> String
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowEquivOrDisjoint ed = case ed of
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance Equivalent -> equivalentToC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance Disjoint -> disjointWithC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mancedata DomainOrRange = ADomain | ARange
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowDomainOrRange :: DomainOrRange -> String
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowDomainOrRange dr = case dr of
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance ADomain -> domainC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance ARange -> rangeC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mancedata SameOrDifferent = Same | Different
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel ManceshowSameOrDifferent :: SameOrDifferent -> String
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel ManceshowSameOrDifferent sd = case sd of
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance Same -> sameAsC
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance Different -> differentFromC
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancedata Relation =
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance EDRelation EquivOrDisjoint
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | SubPropertyOf
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | InverseOf
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | SubClass
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Types
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | DRRelation DomainOrRange
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | SDRelation SameOrDifferent
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
a921ae1da1302f673204e7b63cdce01439a9bd5eFelix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowRelation :: Relation -> String
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowRelation r = case r of
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance EDRelation ed -> showEquivOrDisjoint ed
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance SubPropertyOf -> subPropertyOfC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance InverseOf -> inverseOfC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance SubClass -> subClassOfC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance Types -> typesC
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance DRRelation dr -> showDomainOrRange dr
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance SDRelation sd -> showSameOrDifferent sd
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel MancegetED :: Relation -> EquivOrDisjoint
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel MancegetED r = case r of
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance EDRelation ed -> ed
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance _ -> error "not domain or range"
097bc9f18b722812d480df0f5c634d09cbca8e21Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel MancegetDR :: Relation -> DomainOrRange
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel MancegetDR r = case r of
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance DRRelation dr -> dr
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance _ -> error "not domain or range"
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel MancegetSD :: Relation -> SameOrDifferent
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel MancegetSD s = case s of
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance SDRelation sd -> sd
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance _ -> error "not same or different"
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancedata Character =
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance Functional
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | InverseFunctional
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Reflexive
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Irreflexive
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Symmetric
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Asymmetric
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Antisymmetric
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | Transitive
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Enum, Bounded, Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mancedata PositiveOrNegative = Positive | Negative
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mancedata QuantifierType = AllValuesFrom | SomeValuesFrom
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowQuantifierType :: QuantifierType -> String
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel ManceshowQuantifierType ty = case ty of
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance AllValuesFrom -> onlyS
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance SomeValuesFrom -> someS
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
083b2687afdb676237f926bdb643b24027291d05Felix Gabriel Mance-- * Predefined IRI checkings
511be329b2e8f55d0c6b18bd92571a1776b15932Felix Gabriel Mance
e26bfed39ffa184453272125a4adf147206eac74Christian MaederthingMap :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaederthingMap = makeOWLPredefMaps predefClass
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
511be329b2e8f55d0c6b18bd92571a1776b15932Felix Gabriel ManceisThing :: IRI -> Bool
e26bfed39ffa184453272125a4adf147206eac74Christian MaederisThing = checkPredef thingMap
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefObjProp :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefObjProp = makeOWLPredefMaps predefObjProp
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
0c3badd7ad83eb89f64ef5ed1122c4fa856fb45dFelix Gabriel ManceisPredefObjProp :: IRI -> Bool
e26bfed39ffa184453272125a4adf147206eac74Christian MaederisPredefObjProp = checkPredef makePredefObjProp
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefDataProp :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefDataProp = makeOWLPredefMaps predefDataProp
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel ManceisPredefDataProp :: IRI -> Bool
e26bfed39ffa184453272125a4adf147206eac74Christian MaederisPredefDataProp = checkPredef makePredefDataProp
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefRDFSAnnoProp :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefRDFSAnnoProp = preDefMaps predefRDFSAnnoProps "rdfs"
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
d850dba73b02f345f64a3546d0f0299c292f88d6Felix Gabriel ManceisPredefRDFSAnnoProp :: IRI -> Bool
e26bfed39ffa184453272125a4adf147206eac74Christian MaederisPredefRDFSAnnoProp = checkPredef makePredefRDFSAnnoProp
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefOWLAnnoProp :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakePredefOWLAnnoProp = makeOWLPredefMaps predefOWLAnnoProps
d850dba73b02f345f64a3546d0f0299c292f88d6Felix Gabriel Mance
d850dba73b02f345f64a3546d0f0299c292f88d6Felix Gabriel ManceisPredefOWLAnnoProp :: IRI -> Bool
e26bfed39ffa184453272125a4adf147206eac74Christian MaederisPredefOWLAnnoProp = checkPredef makePredefOWLAnnoProp
d850dba73b02f345f64a3546d0f0299c292f88d6Felix Gabriel Mance
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel ManceisPredefAnnoProp :: IRI -> Bool
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiisPredefAnnoProp i = isPredefOWLAnnoProp i || isPredefRDFSAnnoProp i
511be329b2e8f55d0c6b18bd92571a1776b15932Felix Gabriel Mance
6504b297e21d071d8fada2f732cabb6d8f7d38a2Felix Gabriel ManceisPredefPropOrClass :: IRI -> Bool
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiisPredefPropOrClass i = isPredefAnnoProp i || isPredefDataProp i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski || isPredefObjProp i || isThing i
6504b297e21d071d8fada2f732cabb6d8f7d38a2Felix Gabriel Mance
f8c3d045dda224e92bf6bcb6288e1ee75ab54d1eChristian MaederpredefIRIs :: Set.Set IRI
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskipredefIRIs = Set.fromList $ map (setPrefix "xsd" . mkIRI) xsdKeys
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski ++ map (setPrefix "owl" . mkIRI) owlNumbers
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski ++ map (setPrefix "rdf" . mkIRI) [rdfsLiteral, stringS]
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski ++ [setPrefix "rdfs" $ mkIRI xmlLiteral]
4b7c9b9fec53befb553f2c9b11e30a4fe2235e03Felix Gabriel Mance
44985cbd4eb61dbc348617ebdd44a774e51dac07Christian MaederisDatatypeKey :: IRI -> Bool
1075744775ba70c9ef6cdd06523204751f544ed5Christian MaederisDatatypeKey = not . null . isDatatypeKeyAux
1075744775ba70c9ef6cdd06523204751f544ed5Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdMap :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdMap = makeXsdMap xsdKeys
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederowlNumbersMap :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaederowlNumbersMap = makeOWLPredefMaps owlNumbers
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederrdfMap :: PreDefMaps
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaederrdfMap = preDefMaps [xmlLiteral, stringS] "rdf"
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederrdfsMap :: PreDefMaps
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaederrdfsMap = preDefMaps [rdfsLiteral] "rdfs"
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
1075744775ba70c9ef6cdd06523204751f544ed5Christian MaederisDatatypeKeyAux :: IRI -> [(String, String)]
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiisDatatypeKeyAux i = mapMaybe (`checkPredefAux` i)
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder [ xsdMap, owlNumbersMap, rdfMap, rdfsMap ]
f8c3d045dda224e92bf6bcb6288e1ee75ab54d1eChristian Maeder
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian Maedertype PreDefMaps = ([String], String, String)
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaederpreDefMaps :: [String] -> String -> PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaederpreDefMaps sl pref = let
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder Just puri = Map.lookup pref predefPrefixes
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder Just sp = stripPrefix "http://www.w3.org/" puri
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder in (sl, pref, sp)
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaedercheckPredefAux :: PreDefMaps -> IRI -> Maybe (String, String)
6470a08d94430381c14ed30c3a3a8e433401352bcmaedercheckPredefAux (sl, pref, exPref) u =
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski let lp = show $ iriPath u
437db42248d4e92184bf34417043a8fe891c751bcmaeder res = Just (pref, lp)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski in case prefixName u of
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder "http" -> case stripPrefix "//www." lp of
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder Just q -> case stripPrefix "w3.org/" q of
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder Just r -> case stripPrefix exPref r of
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian Maeder Just s | elem s sl -> Just (pref, s)
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder _ -> Nothing
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski Nothing -> Nothing
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder Nothing -> Nothing
437db42248d4e92184bf34417043a8fe891c751bcmaeder pu | elem lp sl -> case pu of
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski "" -> let ex = iriToStringUnsecure u in
437db42248d4e92184bf34417043a8fe891c751bcmaeder case stripPrefix "http://www." ex of
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski Just r | r == "w3.org/" ++ exPref ++ lp -- || r == lp
437db42248d4e92184bf34417043a8fe891c751bcmaeder -> res
437db42248d4e92184bf34417043a8fe891c751bcmaeder _ | null ex -> res
437db42248d4e92184bf34417043a8fe891c751bcmaeder _ -> Nothing
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski _ | pref == pu || pref ++ ":" == pu -> Just (pref, lp)
437db42248d4e92184bf34417043a8fe891c751bcmaeder _ -> Nothing
6856a07e36551ed6fadd7c01e7152a3a28878a6fChristian Maeder _ -> Nothing
f8c3d045dda224e92bf6bcb6288e1ee75ab54d1eChristian Maeder
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski
e26bfed39ffa184453272125a4adf147206eac74Christian MaedercheckPredef :: PreDefMaps -> IRI -> Bool
e26bfed39ffa184453272125a4adf147206eac74Christian MaedercheckPredef ms = isJust . checkPredefAux ms
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaedermakeOWLPredefMaps :: [String] -> PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakeOWLPredefMaps sl = preDefMaps sl "owl"
44985cbd4eb61dbc348617ebdd44a774e51dac07Christian Maeder
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance-- | sets the correct prefix for the predefined datatypes
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel MancesetDatatypePrefix :: IRI -> IRI
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskisetDatatypePrefix i = case isDatatypeKeyAux i of
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski (p, l) : _ -> setPrefix p $ mkIRI l
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski _ -> error $ showIRICompact i ++ " is not a predefined datatype"
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance-- | checks if the IRI is part of the built-in ones and puts the correct prefix
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel MancesetReservedPrefix :: IRI -> IRI
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskisetReservedPrefix i = case prefixName i of
63946b0fc89de113d5bf4819f9c8cc5d6adce810cmaeder ""
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski | isDatatypeKey i -> setDatatypePrefix i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski | isThing i || isPredefDataProp i || isPredefOWLAnnoProp i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski || isPredefObjProp i -> setPrefix "owl" i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski | isPredefRDFSAnnoProp i -> setPrefix "rdfs" i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski _ -> i
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
4b7c9b9fec53befb553f2c9b11e30a4fe2235e03Felix Gabriel MancestripReservedPrefix :: IRI -> IRI
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskistripReservedPrefix = idToIRI . uriToId
4b7c9b9fec53befb553f2c9b11e30a4fe2235e03Felix Gabriel Mance
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski{- | Extracts Id from IRI
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski returns the name of the predefined IRI (e.g <xsd:string> returns "string"
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski or <http://www.w3.org/2002/07/owl#real> returns "real") -}
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiuriToId :: IRI -> Id
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiuriToId i =
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski if (prefixName i `elem` ["", "xsd", "rdf", "rdfs", "owl"])
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski || ( null (iriScheme i)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski && null (iriQuery i)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski && null (iriFragment i)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski && isNothing (iriAuthority i))
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski then iriPath i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski else stringToId $ case mapMaybe (`stripPrefix` showIRICompact i)
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance $ Map.elems predefPrefixes of
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance [s] -> s
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski _ -> showIRIFull i
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskigetPredefName :: IRI -> String
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskigetPredefName = show . uriToId
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder-- | Extracts Token from IRI
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian MaederuriToTok :: IRI -> Token
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiuriToTok = mkSimpleId . show . getPredefName
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder-- | Extracts Id from Entities
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian MaederentityToId :: Entity -> Id
669b3375925f7a145d287fa89f3a815708dbe7a1Christian MaederentityToId = uriToId . cutIRI
92ae4d5885ea837ffe3dae9b2de742f871229b94Christian Maeder
a03c109eabfe250e4b57bdf44f37f53751a65df4Felix Gabriel ManceprintDatatype :: IRI -> String
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskiprintDatatype dt = showIRICompact $
a03c109eabfe250e4b57bdf44f37f53751a65df4Felix Gabriel Mance if isDatatypeKey dt then stripReservedPrefix dt else dt
a03c109eabfe250e4b57bdf44f37f53751a65df4Felix Gabriel Mance
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mancedata DatatypeCat = OWL2Number | OWL2String | OWL2Bool | Other
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
83f5f3291f9b40fa688776b4da10b5fa102a5ff8Felix Gabriel Mance
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel MancegetDatatypeCat :: IRI -> DatatypeCat
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskigetDatatypeCat i = case isDatatypeKey i of
fa544036407a8ec4be203ebd5e3bff225175e664Felix Gabriel Mance True
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski | checkPredef xsdBooleanMap i -> OWL2Bool
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski | checkPredef xsdNumbersMap i || checkPredef owlNumbersMap i
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance -> OWL2Number
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski | checkPredef xsdStringsMap i -> OWL2String
fa544036407a8ec4be203ebd5e3bff225175e664Felix Gabriel Mance | otherwise -> Other
fa544036407a8ec4be203ebd5e3bff225175e664Felix Gabriel Mance False -> Other
83f5f3291f9b40fa688776b4da10b5fa102a5ff8Felix Gabriel Mance
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaedermakeXsdMap :: [String] -> PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaedermakeXsdMap sl = preDefMaps sl "xsd"
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdBooleanMap :: PreDefMaps
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaederxsdBooleanMap = makeXsdMap [booleanS]
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdNumbersMap :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdNumbersMap = makeXsdMap xsdNumbers
e26bfed39ffa184453272125a4adf147206eac74Christian Maeder
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdStringsMap :: PreDefMaps
e26bfed39ffa184453272125a4adf147206eac74Christian MaederxsdStringsMap = makeXsdMap xsdStrings
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
4b7c9b9fec53befb553f2c9b11e30a4fe2235e03Felix Gabriel MancefacetToIRI :: DatatypeFacet -> ConstrainingFacet
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskifacetToIRI = setPrefix "xsd" . mkIRI . showFacet
4b7c9b9fec53befb553f2c9b11e30a4fe2235e03Felix Gabriel Mance
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance-- * Cardinalities
863fa65ac095659c6da1cde7fe7b839f1e7f60f9Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mancedata CardinalityType = MinCardinality | MaxCardinality | ExactCardinality
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel ManceshowCardinalityType :: CardinalityType -> String
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel ManceshowCardinalityType ty = case ty of
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance MinCardinality -> minS
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance MaxCardinality -> maxS
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance ExactCardinality -> exactlyS
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mancedata Cardinality a b = Cardinality CardinalityType Int a (Maybe b)
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mancedata JunctionType = UnionOf | IntersectionOf
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mancetype ConstrainingFacet = IRI
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mancetype RestrictionValue = Literal
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance-- * ENTITIES
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
669b3375925f7a145d287fa89f3a815708dbe7a1Christian Maederdata Entity = Entity
7852de3551fc797566ee71165bafe05b6d81728cnotanartist { label :: Maybe String
7852de3551fc797566ee71165bafe05b6d81728cnotanartist , entityKind :: EntityType
669b3375925f7a145d287fa89f3a815708dbe7a1Christian Maeder , cutIRI :: IRI }
7852de3551fc797566ee71165bafe05b6d81728cnotanartist deriving (Show, Typeable, Data)
7852de3551fc797566ee71165bafe05b6d81728cnotanartist
7852de3551fc797566ee71165bafe05b6d81728cnotanartistmkEntity :: EntityType -> IRI -> Entity
7852de3551fc797566ee71165bafe05b6d81728cnotanartistmkEntity = Entity Nothing
7852de3551fc797566ee71165bafe05b6d81728cnotanartist
7852de3551fc797566ee71165bafe05b6d81728cnotanartistmkEntityLbl :: String -> EntityType -> IRI -> Entity
7852de3551fc797566ee71165bafe05b6d81728cnotanartistmkEntityLbl = Entity . Just
7852de3551fc797566ee71165bafe05b6d81728cnotanartist
7852de3551fc797566ee71165bafe05b6d81728cnotanartistinstance Ord Entity where
7852de3551fc797566ee71165bafe05b6d81728cnotanartist compare (Entity _ ek1 ir1) (Entity _ ek2 ir2) = compare (ek1, ir1) (ek2, ir2)
7852de3551fc797566ee71165bafe05b6d81728cnotanartist
7852de3551fc797566ee71165bafe05b6d81728cnotanartistinstance Eq Entity where
7852de3551fc797566ee71165bafe05b6d81728cnotanartist e1 == e2 = compare e1 e2 == EQ
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Manceinstance GetRange Entity where
669b3375925f7a145d287fa89f3a815708dbe7a1Christian Maeder getRange = iriPos . cutIRI
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski rangeSpan = iRIRange . cutIRI
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mancedata EntityType =
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance Datatype
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | Class
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | ObjectProperty
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | DataProperty
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | AnnotationProperty
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | NamedIndividual
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Enum, Bounded, Show, Read, Eq, Ord, Typeable, Data)
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel ManceshowEntityType :: EntityType -> String
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel ManceshowEntityType e = case e of
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance Datatype -> datatypeC
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance Class -> classC
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance ObjectProperty -> objectPropertyC
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance DataProperty -> dataPropertyC
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance AnnotationProperty -> annotationPropertyC
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance NamedIndividual -> individualC
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel ManceentityTypes :: [EntityType]
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel ManceentityTypes = [minBound .. maxBound]
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian MaederpairSymbols :: Entity -> Entity -> Result Entity -- TODO: improve!
7852de3551fc797566ee71165bafe05b6d81728cnotanartistpairSymbols (Entity lb1 k1 i1) (Entity lb2 k2 i2) =
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian Maeder if k1 /= k2 then
e40758c36e3e5312669558ad189b24b3eaf10c59Mihai Codescu error "can't pair symbols of different kind"
6d907570443508c99867ea29ddf5e5cb0a2ef8c2Christian Maeder else do
47589c2d80dabefc0cd8e2ee5e7331e3db677c68notanartist let rest x = drop 1 $ dropWhile (/= '#') x
47589c2d80dabefc0cd8e2ee5e7331e3db677c68notanartist pairLables lbl1 lbl2 = case (lbl1, lbl2) of
47589c2d80dabefc0cd8e2ee5e7331e3db677c68notanartist (Nothing, _) -> pairLables lbl2 lbl1
47589c2d80dabefc0cd8e2ee5e7331e3db677c68notanartist (Just l1, Just l2) | l1 /= l2 -> Just $ l1 ++ ", " ++ l2
47589c2d80dabefc0cd8e2ee5e7331e3db677c68notanartist _ -> lbl1
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski pairIRIs iri1 iri2 = nullIRI
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski { prefixName = prefixName iri1
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski , iriPath = if rest (show $ iriPath iri1) ==
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski rest (show $ iriPath iri2)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski then iriPath iri1
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski else appendId (iriPath iri1) (iriPath iri2)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski } -- TODO: improve, see #1597
7852de3551fc797566ee71165bafe05b6d81728cnotanartist return $ Entity (pairLables lb1 lb2) k1 $ pairIRIs i1 i2
e40758c36e3e5312669558ad189b24b3eaf10c59Mihai Codescu
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance-- * LITERALS
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancedata TypedOrUntyped = Typed Datatype | Untyped (Maybe LanguageTag)
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederdata Literal = Literal LexicalForm TypedOrUntyped | NumberLit FloatLit
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder-- | non-negative integers given by the sequence of digits
1a38107941725211e7c3f051f7a8f5e12199f03acmaederdata NNInt = NNInt [Int] deriving (Eq, Ord, Typeable, Data)
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederinstance Show NNInt where
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder show (NNInt l) = map intToDigit l
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederzeroNNInt :: NNInt
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederzeroNNInt = NNInt []
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisZeroNNInt :: NNInt -> Bool
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisZeroNNInt (NNInt l) = null l
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederdata IntLit = IntLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder { absInt :: NNInt
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder , isNegInt :: Bool }
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Eq, Ord, Typeable, Data)
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederinstance Show IntLit where
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder show (IntLit n b) = (if b then ('-' :) else id) $ show n
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederzeroInt :: IntLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederzeroInt = IntLit zeroNNInt False
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisZeroInt :: IntLit -> Bool
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisZeroInt (IntLit n _) = isZeroNNInt n
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaedernegNNInt :: Bool -> NNInt -> IntLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaedernegNNInt b n = IntLit n b
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaedernegInt :: IntLit -> IntLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaedernegInt (IntLit n b) = IntLit n $ not b
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederdata DecLit = DecLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder { truncDec :: IntLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder , fracDec :: NNInt }
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Eq, Ord, Typeable, Data)
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederinstance Show DecLit where
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder show (DecLit t f) = show t
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder ++ if isZeroNNInt f then "" else
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder '.' : show f
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisDecInt :: DecLit -> Bool
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisDecInt = isZeroNNInt . fracDec
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
cbb0a924599bcaea230e7dcd2892cc91c49319aeChristian MaedernegDec :: Bool -> DecLit -> DecLit
d66846429fcdd6882e62c7e5b911f98b3812ff09Felix Gabriel MancenegDec b (DecLit t f) = DecLit (if b then negInt t else t) f
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederdata FloatLit = FloatLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder { floatBase :: DecLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder , floatExp :: IntLit }
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Eq, Ord, Typeable, Data)
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maederinstance Show FloatLit where
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder show (FloatLit b e) = show b
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder ++ if isZeroInt e then "" else
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder 'E' : show e ++ "F"
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisFloatDec :: FloatLit -> Bool
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisFloatDec = isZeroInt . floatExp
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisFloatInt :: FloatLit -> Bool
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederisFloatInt f = isFloatDec f && isDecInt (floatBase f)
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederfloatToInt :: FloatLit -> IntLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederfloatToInt = truncDec . floatBase
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederintToDec :: IntLit -> DecLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederintToDec i = DecLit i zeroNNInt
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederdecToFloat :: DecLit -> FloatLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederdecToFloat d = FloatLit d zeroInt
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederintToFloat :: IntLit -> FloatLit
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian MaederintToFloat = decToFloat . intToDec
b1162cc13e8371724e3382ae6d1cfdeb43891fbbChristian Maeder
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceabInt :: IntLit -> IntLit
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceabInt int = int {isNegInt = False}
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel Mance
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceabDec :: DecLit -> DecLit
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceabDec dec = dec {truncDec = abInt $ truncDec dec}
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel Mance
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceabFloat :: FloatLit -> FloatLit
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceabFloat f = f {floatBase = abDec $ floatBase f}
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel Mance
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceisNegDec :: DecLit -> Bool
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel ManceisNegDec d = isNegInt $ truncDec d
c704da29ad5d9d00c07e75f9109442d178dd990bFelix Gabriel Mance
a4a1b0cfce938fc38d5924b8fb6a7e140602ec5cFelix Gabriel MancenumberName :: FloatLit -> String
cbb0a924599bcaea230e7dcd2892cc91c49319aeChristian MaedernumberName f
52991d9b46a98ad6a9020421a3244950b0f8a522Felix Gabriel Mance | isFloatInt f = integerS
52991d9b46a98ad6a9020421a3244950b0f8a522Felix Gabriel Mance | isFloatDec f = decimalS
52991d9b46a98ad6a9020421a3244950b0f8a522Felix Gabriel Mance | otherwise = floatS
a4a1b0cfce938fc38d5924b8fb6a7e140602ec5cFelix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel MancecTypeS :: String
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel MancecTypeS = "^^"
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance-- * PROPERTY EXPRESSIONS
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancetype InverseObjectProperty = ObjectPropertyExpression
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancedata ObjectPropertyExpression = ObjectProp ObjectProperty
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance | ObjectInverseOf InverseObjectProperty
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
707454ba169478cbf17b91b53f8f0aa2ff8a89beChristian MaederobjPropToIRI :: ObjectPropertyExpression -> Individual
707454ba169478cbf17b91b53f8f0aa2ff8a89beChristian MaederobjPropToIRI opExp = case opExp of
707454ba169478cbf17b91b53f8f0aa2ff8a89beChristian Maeder ObjectProp u -> u
707454ba169478cbf17b91b53f8f0aa2ff8a89beChristian Maeder ObjectInverseOf objProp -> objPropToIRI objProp
707454ba169478cbf17b91b53f8f0aa2ff8a89beChristian Maeder
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mancetype DataPropertyExpression = DataProperty
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance-- * DATA RANGES
c77c0efe19dc6556ac872828bfb4cfc5fbca5ac5Felix Gabriel Mance
fa544036407a8ec4be203ebd5e3bff225175e664Felix Gabriel Mancedata DataRange =
fa544036407a8ec4be203ebd5e3bff225175e664Felix Gabriel Mance DataType Datatype [(ConstrainingFacet, RestrictionValue)]
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | DataJunction JunctionType [DataRange]
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | DataComplementOf DataRange
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | DataOneOf [Literal]
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance-- * CLASS EXPERSSIONS
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancedata ClassExpression =
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance Expression Class
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | ObjectJunction JunctionType [ClassExpression]
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance | ObjectComplementOf ClassExpression
e99c3c1f572d0442872bba58f187ca520ef5d040Felix Gabriel Mance | ObjectOneOf [Individual]
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance | ObjectValuesFrom QuantifierType ObjectPropertyExpression ClassExpression
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance | ObjectHasValue ObjectPropertyExpression Individual
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance | ObjectHasSelf ObjectPropertyExpression
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance | ObjectCardinality (Cardinality ObjectPropertyExpression ClassExpression)
ffa6044b04fa0e31242141ff56a5d80c4233b676Felix Gabriel Mance | DataValuesFrom QuantifierType DataPropertyExpression DataRange
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance | DataHasValue DataPropertyExpression Literal
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance | DataCardinality (Cardinality DataPropertyExpression DataRange)
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
1435782fda52a2898ea74e99088351d4f5b450dcChristian Maeder-- * ANNOTATIONS
c298a419605037f5352b5ad0f67b3e06db094051Felix Gabriel Mance
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mancedata Annotation = Annotation [Annotation] AnnotationProperty AnnotationValue
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)
8af00c8930672188ae80c8829428859160d329d0Felix Gabriel Mance
771c32080c77497c6c023a3b1c422f7daf3773f7Felix Gabriel Mancedata AnnotationValue = AnnValue IRI | AnnValLit Literal
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder deriving (Show, Eq, Ord, Typeable, Data)