ParseRDFAsLibDefn.hs revision c4076ff1721f8901a30e4b7aa004479ecb2631e0
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian MaederModule : $Header$
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerCopyright : Felix Mance
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiLicense : GPLv2 or higher, see LICENSE.txt
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : f.mance@jacobs-university.de
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian MaederStability : provisional
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederPortability : non-portable (imports Logic.Logic)
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederanalyse OWL files by calling the external Java parser.
c7c90bab17cfec4793ecf70b20c39f1622977a7eChristian Maedermodule RDF.ParseRDFAsLibDefn (parseRDF) where
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederimport Common.AS_Annotation hiding (isAxiom, isDef)
c1e44804ab02be8fa720960cfd1f2355dd8c0bbeChristian MaederparseRDF :: FilePath -- ^ local filepath or uri
c1e44804ab02be8fa720960cfd1f2355dd8c0bbeChristian Maeder -> IO LIB_DEFN -- ^ map: uri -> RDF graph
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian MaederparseRDF filename = do
993cbe47cbad455281db80ce9194d75ffe3f6febChristian Maeder absfile <- if checkUri filename then return filename else
152c178f9f9969ce729361a5c61aa4ff2c9ed840Christian Maeder fmap ("file://" ++) $ canonicalizePath filename
f27958e3207806f9fd3d579018e1921ce4f33b75Klaus Luettich let absfileNt = absfile ++ ".nt"
db3b74383c0afcd7a0aec50c263aec4f4e09df8dcmaeder (exitCode, result, errStr) <- readProcessWithExitCode "cwm"
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder ["--rdf", absfile, "--ntriples >", absfileNt ] ""
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder case exitCode of
681f20df85992a619d03e1adb933232a9515d7fcChristian Maeder ExitSuccess -> return $ parseNT absfileNt
8e58d2c3037f6bdd26e2f2c1e499cb6121ea806eChristian Maeder _ -> error $ "process stop! " ++ shows exitCode "\n"
1a38107941725211e7c3f051f7a8f5e12199f03acmaederparseNT :: FilePath -> LIB_DEFN
ad270004874ce1d0697fb30d7309f180553bb315Christian MaederparseNT filename = convertToLibDefN filename $ parseNtriples filename
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian MaedercreateSpec :: RDFGraph -> Annoted SPEC
392581ea95e3a242153594d6d911c1aa5e0b0875Klaus LuettichcreateSpec gr = emptyAnno $ Basic_spec (G_basic_spec RDF gr) nullRange
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederconvertone :: RDFGraph -> Annoted LIB_ITEM
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederconvertone gr = emptyAnno $ Spec_defn (mkSimpleId "") emptyGenericity (createSpec gr) nullRange
1a38107941725211e7c3f051f7a8f5e12199f03acmaederconvertToLibDefN :: FilePath -> RDFGraph -> LIB_DEFN
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian MaederconvertToLibDefN filename l = Lib_defn
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder (emptyLibName $ convertFileToLibStr filename)
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder [convertone l] nullRange []