ParseRDFAsLibDefn.hs revision c4076ff1721f8901a30e4b7aa004479ecb2631e0
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder{- |
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian MaederModule : $Header$
e9458b1a7a19a63aa4c179f9ab20f4d50681c168Jens ElknerCopyright : Felix Mance
e6d40133bc9f858308654afb1262b8b483ec5922Till MossakowskiLicense : GPLv2 or higher, see LICENSE.txt
c34f9e8091bab44a6956db9bf4f2ae5d77d818fbChristian Maeder
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : f.mance@jacobs-university.de
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian MaederStability : provisional
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederPortability : non-portable (imports Logic.Logic)
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maeder
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederanalyse OWL files by calling the external Java parser.
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder-}
f97523766972a5b9dfb6e357ba3a9c71aa3afca9Christian Maeder
c7c90bab17cfec4793ecf70b20c39f1622977a7eChristian Maedermodule RDF.ParseRDFAsLibDefn (parseRDF) where
9e6ce33401d2bbbe82156d59f6a9be0331d9a4b7Christian Maeder
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederimport OWL2.AS
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederimport RDF.AS
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport RDF.Parse
9e6ce33401d2bbbe82156d59f6a9be0331d9a4b7Christian Maederimport RDF.Logic_RDF
c7c90bab17cfec4793ecf70b20c39f1622977a7eChristian Maederimport Data.Char
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maeder
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport Common.Id
9e6ce33401d2bbbe82156d59f6a9be0331d9a4b7Christian Maederimport Common.LibName
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport Common.ProverTools
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederimport Common.AS_Annotation hiding (isAxiom, isDef)
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport Logic.Grothendieck
9e6ce33401d2bbbe82156d59f6a9be0331d9a4b7Christian Maederimport RDF.Logic_RDF
c7c90bab17cfec4793ecf70b20c39f1622977a7eChristian Maeder
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport Driver.Options
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maeder
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport Syntax.AS_Library
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederimport Syntax.AS_Structured
410ff490af511ffa09b52e4de631d36a154b9730Christian Maeder
b2eb5854497af395cbf17a08c7ace5ab73e7eea2Christian Maederimport System.Directory
59597e83448c2fc763557b56e0319615b33518d9Christian Maederimport System.Exit
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederimport System.FilePath
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederimport System.Process
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder
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"
392581ea95e3a242153594d6d911c1aa5e0b0875Klaus Luettich ++ errStr
075f71723257906d689c71a8b2fa6cce4b386317Christian Maeder
1a38107941725211e7c3f051f7a8f5e12199f03acmaederparseNT :: FilePath -> LIB_DEFN
ad270004874ce1d0697fb30d7309f180553bb315Christian MaederparseNT filename = convertToLibDefN filename $ parseNtriples filename
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian MaedercreateSpec :: RDFGraph -> Annoted SPEC
392581ea95e3a242153594d6d911c1aa5e0b0875Klaus LuettichcreateSpec gr = emptyAnno $ Basic_spec (G_basic_spec RDF gr) nullRange
8ecdb62fa2cef068eb4dbce59f3219a8e3adc0baChristian Maeder
9db318e6d01634c66e10dd0c6eb66c96305cb4f9Christian Maederconvertone :: RDFGraph -> Annoted LIB_ITEM
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maederconvertone gr = emptyAnno $ Spec_defn (mkSimpleId "") emptyGenericity (createSpec gr) nullRange
1a38107941725211e7c3f051f7a8f5e12199f03acmaeder
1a38107941725211e7c3f051f7a8f5e12199f03acmaederconvertToLibDefN :: FilePath -> RDFGraph -> LIB_DEFN
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian MaederconvertToLibDefN filename l = Lib_defn
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder (emptyLibName $ convertFileToLibStr filename)
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder [convertone l] nullRange []
e0f1794e365dd347e97b37d7d22b2fce27296fa1Christian Maeder