Copyright : (c) Felix Gabriel Mance
Maintainer : f.mance@jacobs-university.de
Renames prefixes in OntologyDocuments, so that there are
testAndInteg :: (String, String)
-> (PrefixMap, AMap) -> (PrefixMap, AMap)
testAndInteg (pre, oiri) (old, tm) = case
Map.lookup pre old of
if oiri == iri then (old, tm)
else let pre' = disambiguateName pre old
disambiguateName :: String -> PrefixMap -> String
disambiguateName nm nameMap =
let newname = reverse . dropWhile isDigit $ reverse nm
in fromJust $ find (not . flip
Map.member nameMap)
[newname ++ show (i :: Int) | i <- [1 ..]]
uniteSign :: Sign -> Sign -> Result Sign
let (pm, tm) = integPref (prefixMap s1) (prefixMap s2)
if
Map.null tm then return (addSign s1 s2) {prefixMap = pm}
else fail "Static analysis could not unite signatures"
integPref :: PrefixMap -> PrefixMap
integPref oldMap testMap =
newOid :: OntologyIRI -> OntologyIRI -> OntologyIRI
else if null lid2 || id1 == id2 then id1
else id1 { localPart = uriToName lid1 ++ "_" ++ uriToName lid2 }
integrateOntologyDoc :: OntologyDocument -> OntologyDocument
integrateOntologyDoc od1@( OntologyDocument ns1
( Ontology oid1 imp1 anno1 frames1))
od2@( OntologyDocument ns2
( Ontology oid2 imp2 anno2 frames2)) =
let (newPref, tm) = integPref ns1 ns2
in OntologyDocument newPref
(Ontology (newOid oid1 oid2) (nub $ imp1 ++ map (function Rename tm) imp2)
(nub $ anno1 ++ map (function Rename tm) anno2)
(nub $ frames1 ++ map (function Rename tm) frames2))
uriToName :: String -> String
in takeWhile (/= '.') $ reverse $ case takeWhile (/= '/') $ reverse str' of
unifyWith1 :: OntologyDocument -> [OntologyDocument] -> [OntologyDocument]
unifyWith1 d odl = case odl of
[doc] -> [snd $ unifyTwo d doc]
let (merged, newDoc1) = unifyTwo d doc1
in newDoc1 : unifyWith1 merged docs
{- takes 2 docs and returns as snd the corrected first one
and as fst the merge of the two -}
unifyTwo :: OntologyDocument -> OntologyDocument ->
(OntologyDocument, OntologyDocument)
let (_, tm) = integPref (prefixDeclaration od1) (prefixDeclaration od2)
newod2 = function Rename tm od2
alld = integrateOntologyDoc od1 od2
unifyDocs :: [OntologyDocument] -> [OntologyDocument]
unifyDocs = unifyWith1 emptyDoc