Cross Reference: /hets/OWL2/ColimSign.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance{- |
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerModule : ./OWL2/ColimSign.hs
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel ManceDescription : OWL signatures colimits
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel ManceCopyright : (c) Mihai Codescu, and Uni Bremen 2009
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel ManceLicense : GPLv2 or higher, see LICENSE.txt
fae04f4a69922eb1ddf0f46b34fa15a5a080b693Felix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel ManceMaintainer : mcodescu@informatik.uni-bremen.de
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel ManceStability : provisional
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel MancePortability : non-portable
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
68ace74bf7cd65cb7eb7e19ffe373520fc520e0cFelix Gabriel ManceOWL2 signature colimits, computed component-wise.
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance-}
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mancemodule OWL2.ColimSign where
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport OWL2.Sign
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport OWL2.Morphism
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport OWL2.AS
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowskiimport Common.IRI
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport Common.SetColimit
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport Common.Lib.Graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport Data.Graph.Inductive.Graph as Graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Manceimport qualified Data.Map as Map
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel MancesignColimit :: Gr Sign (Int, OWLMorphism) ->
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance (Sign, Map.Map Int OWLMorphism)
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel MancesignColimit graph = let
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance conGraph = emap (getEntityTypeMap Class) $ nmap concepts graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance dataGraph = emap (getEntityTypeMap Datatype) $ nmap datatypes graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance indGraph = emap (getEntityTypeMap NamedIndividual) $ nmap individuals graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance objGraph = emap (getEntityTypeMap ObjectProperty) $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance nmap objectProperties graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance dataPropGraph = emap (getEntityTypeMap DataProperty) $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance nmap dataProperties graph
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance annPropGraph = emap (getEntityTypeMap AnnotationProperty) $
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance nmap annotationRoles graph
732014c1519f1087a7fed3316969b21537394b77Christian Maeder _prefixGraph = emap getPrefixMap
f6f50c832e59d06ae11bbfcf94d0df87313c844eFelix Gabriel Mance $ nmap (Map.keysSet . toQName . prefixMap) graph
51be3b318544e318688bc3f8ee41e21b765dba61Mihai Codescu (con, funC) = addIntToSymbols $ computeColimitSet conGraph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance (dat, funD) = addIntToSymbols $ computeColimitSet dataGraph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance (ind, funI) = addIntToSymbols $ computeColimitSet indGraph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance (obj, funO) = addIntToSymbols $ computeColimitSet objGraph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance (dp, funDP) = addIntToSymbols $ computeColimitSet dataPropGraph
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance (ap, funAP) = addIntToSymbols $ computeColimitSet annPropGraph
732014c1519f1087a7fed3316969b21537394b77Christian Maeder -- (pf, funP) = addIntToSymbols $ computeColimitSet prefixGraph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance morFun i = foldl Map.union Map.empty
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance [ setEntityTypeMap Class $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance Map.findWithDefault (error "maps") i funC,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance setEntityTypeMap Datatype $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance Map.findWithDefault (error "maps") i funD,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance setEntityTypeMap NamedIndividual $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance Map.findWithDefault (error "maps") i funI,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance setEntityTypeMap ObjectProperty $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance Map.findWithDefault (error "maps") i funO,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance setEntityTypeMap DataProperty $
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance Map.findWithDefault (error "maps") i funDP,
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance setEntityTypeMap AnnotationProperty $
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance Map.findWithDefault (error "maps") i funAP
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance ]
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance morMaps = Map.fromAscList $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance map (\ x -> (x, morFun x)) $ nodes graph
a254a6ea12c3651c56ef5c00edf1dd20740156faFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance nameMap = foldl Map.union Map.empty $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance map (\ (_, l) -> prefixMap l) $ labNodes graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance colimSign = emptySign {
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance concepts = con,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance datatypes = dat,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance objectProperties = obj,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance dataProperties = dp,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance individuals = ind,
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance annotationRoles = ap,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance prefixMap = nameMap
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance }
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance colimMor = Map.fromAscList $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance map (\ (i, ssig) -> let
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance mm = Map.findWithDefault (error "mor") i morMaps
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance om = OWLMorphism {
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance osource = ssig,
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance otarget = colimSign,
732014c1519f1087a7fed3316969b21537394b77Christian Maeder mmaps = mm,
732014c1519f1087a7fed3316969b21537394b77Christian Maeder pmap = Map.empty
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance }
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance in (i, om)
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance ) $ labNodes graph
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance in (colimSign, colimMor)
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel MancegetEntityTypeMap :: EntityType -> (Int, OWLMorphism)
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski -> (Int, Map.Map IRI IRI)
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel MancegetEntityTypeMap e (i, phi) = let
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance f = Map.filterWithKey
7852de3551fc797566ee71165bafe05b6d81728cnotanartist (\ (Entity _ x _) _ -> x == e) $ mmaps phi
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance in (i, Map.fromList $
7852de3551fc797566ee71165bafe05b6d81728cnotanartist map (\ (Entity _ _ x, y) -> (x, y)) $
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance Map.toAscList f)
f501e448d92c4d819b6bfc1d6487da76cf22528cFelix Gabriel Mance
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskisetEntityTypeMap :: EntityType -> Map.Map IRI IRI
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski -> Map.Map Entity IRI
7852de3551fc797566ee71165bafe05b6d81728cnotanartistsetEntityTypeMap = Map.mapKeys . mkEntity
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskigetPrefixMap :: (Int, OWLMorphism) -> (Int, Map.Map IRI IRI)
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel MancegetPrefixMap (i, phi) = let
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance f = pmap phi
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance in (i, Map.fromList $
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski map (\ (x, y) -> (mkIRI x, mkIRI y)) $
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance Map.toAscList f)
7a443a42affdb218b848a9d6b58a4d7675c1c543Felix Gabriel Mance
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskitoQName :: PrefixMap -> Map.Map IRI String
80875f917d741946a39d0ec0b5721e46ba609823Till MossakowskitoQName pm = Map.fromList $ map (\ (p, s) -> (mkIRI p, s)) $ Map.toList pm