packages feed

morfeusz 0.4.0 → 0.4.1

raw patch · 7 files changed

+558/−9 lines, 7 filesdep +directorybuild-type:Customsetup-changed

Dependencies added: directory

Files

+ Setup.hs view
@@ -0,0 +1,33 @@+import Control.Monad (forM_)+import System.FilePath+import System.Directory+import System.Info (os)+import Distribution.Simple+import Distribution.Simple.Setup+import qualified Distribution.Simple.Configure as C++import Setup.Configure++morfPath :: String+morfPath = "libmorfeusz"++morfLibSrc :: String+morfLibSrc = "libmorfeusz.so"++morfLibs :: [String]+morfLibs = ["libmorfeusz.so.0", "libmorfeusz.so"]++-- | We need to copy the libmorfeusz.so file before the configuration phase.+conf desc cfg = do+    if (null (configExtraLibDirs cfg) && os == "linux")+        then do+            path <- sharedPath desc cfg+            createDirectoryIfMissing True path+            forM_ morfLibs $ \lib -> do+                copyFile (morfPath </> morfLibSrc) (path </> lib)+            C.configure desc $ cfg { configExtraLibDirs = [path] }+        else do+            C.configure desc cfg++main :: IO ()+main = defaultMainWithHooks $ simpleUserHooks { confHook = conf }
− Setup.lhs
@@ -1,4 +0,0 @@-#! /usr/bin/env runhaskell--> import Distribution.Simple-> main = defaultMain
+ Setup/Configure.hs view
@@ -0,0 +1,304 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Distribution.Simple.Configure+-- Copyright   :  Isaac Jones 2003-2005+--+-- Maintainer  :  cabal-devel@haskell.org+-- Portability :  portable+--+-- This deals with the /configure/ phase. It provides the 'configure' action+-- which is given the package description and configure flags. It then tries+-- to: configure the compiler; resolves any conditionals in the package+-- description; resolve the package dependencies; check if all the extensions+-- used by this package are supported by the compiler; check that all the build+-- tools are available (including version checks if appropriate); checks for+-- any required @pkg-config@ packages (updating the 'BuildInfo' with the+-- results)+--+-- Then based on all this it saves the info in the 'LocalBuildInfo' and writes+-- it out to the @dist\/setup-config@ file. It also displays various details to+-- the user, the amount of information displayed depending on the verbosity+-- level.++{- All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Isaac Jones nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}++module Setup.Configure+( sharedPath+) where++import Control.Applicative ((<$>))+import System.Exit+import qualified System.Info+import qualified Control.Exception as Exception++import Distribution.Simple.Compiler+    ( CompilerFlavor(..), Compiler(compilerId), compilerFlavor, compilerVersion+    , showCompilerId, unsupportedLanguages, unsupportedExtensions+    , PackageDB(..), PackageDBStack )+import Distribution.Package+    ( PackageName(PackageName), PackageIdentifier(..), PackageId+    , packageName, packageVersion, Package(..)+    , Dependency(Dependency), simplifyDependency+    , InstalledPackageId(..) )+import Distribution.InstalledPackageInfo as Installed+    ( InstalledPackageInfo, InstalledPackageInfo_(..)+    , emptyInstalledPackageInfo )+import qualified Distribution.Simple.PackageIndex as PackageIndex+import Distribution.Simple.PackageIndex (PackageIndex)+import Distribution.PackageDescription as PD+    ( PackageDescription(..), specVersion, GenericPackageDescription(..)+    , Library(..), hasLibs, Executable(..), BuildInfo(..), allExtensions+    , HookedBuildInfo, updatePackageDescription, allBuildInfo+    , FlagName(..), TestSuite(..), Benchmark(..), flagName )+import Distribution.PackageDescription.Configuration+    ( finalizePackageDescription, mapTreeData )+import Distribution.PackageDescription.Check+    ( PackageCheck(..), checkPackage, checkPackageFiles )+import Distribution.Simple.Hpc ( enableCoverage )+import Distribution.Simple.Program+    ( Program(..), ProgramLocation(..), ConfiguredProgram(..)+    , ProgramConfiguration, defaultProgramConfiguration+    , configureAllKnownPrograms, knownPrograms, lookupKnownProgram+    , userSpecifyArgss, userSpecifyPaths+    , requireProgram, requireProgramVersion+    , pkgConfigProgram, gccProgram, rawSystemProgramStdoutConf )+import Distribution.Simple.Setup+    ( ConfigFlags(..), CopyDest(..), fromFlag, fromFlagOrDefault, flagToMaybe )+import Distribution.Simple.InstallDirs+    ( InstallDirs(..), defaultInstallDirs, combineInstallDirs )+import qualified Distribution.Simple.InstallDirs as InstallDirs+import Distribution.Simple.LocalBuildInfo+    ( LocalBuildInfo(..), ComponentLocalBuildInfo(..)+    , absoluteInstallDirs, prefixRelativeInstallDirs, inplacePackageId+    , allComponentsBy, Component(..), foldComponent, ComponentName(..) )+import Distribution.Simple.BuildPaths+    ( autogenModulesDir )+import Distribution.Simple.Utils+    ( die, warn, info, setupMessage, createDirectoryIfMissingVerbose+    , intercalate, cabalVersion+    , withFileContents, writeFileAtomic+    , withTempFile )+import Distribution.System+    ( OS(..), buildOS, buildPlatform )+import Distribution.Version+         ( Version(..), anyVersion, orLaterVersion, withinRange, isAnyVersion )+import Distribution.Verbosity+    ( Verbosity, lessVerbose )++import qualified Distribution.Simple.GHC  as GHC+import qualified Distribution.Simple.JHC  as JHC+import qualified Distribution.Simple.LHC  as LHC+import qualified Distribution.Simple.NHC  as NHC+import qualified Distribution.Simple.Hugs as Hugs+import qualified Distribution.Simple.UHC  as UHC++import Control.Monad+    ( when, unless, foldM, filterM, forM )+import Data.List+    ( nub, partition, isPrefixOf, inits, find )+import Data.Maybe+    ( isNothing, catMaybes, mapMaybe )+import Data.Monoid+    ( Monoid(..) )+import Data.Graph+    ( SCC(..), graphFromEdges, transposeG, vertices, stronglyConnCompR )+import System.Directory+    ( doesFileExist, getModificationTime, createDirectoryIfMissing, getTemporaryDirectory )+import System.Exit+    ( ExitCode(..), exitWith )+import System.FilePath+    ( (</>), isAbsolute )+import qualified System.Info+    ( compilerName, compilerVersion )+import System.IO+    ( hPutStrLn, stderr, hClose )+import Distribution.Text+    ( Text(disp), display, simpleParse )+import Text.PrettyPrint+    ( comma, punctuate, render, nest, sep )++import Prelude hiding (catch)++sharedPath+    :: (GenericPackageDescription, HookedBuildInfo)+    -> ConfigFlags -> IO FilePath+sharedPath (pkg_descr0, pbi) cfg+  = do  let distPref = fromFlag (configDistPref cfg)+            buildDir' = distPref </> "build"+            verbosity = fromFlag (configVerbosity cfg)++        let programsConfig = userSpecifyArgss (configProgramArgs cfg)+                           . userSpecifyPaths (configProgramPaths cfg)+                           $ configPrograms cfg+            userInstall = fromFlag (configUserInstall cfg)+            packageDbs = implicitPackageDbStack userInstall+                           (flagToMaybe $ configPackageDB cfg)++        -- detect compiler+        (comp, programsConfig') <- configCompiler+          (flagToMaybe $ configHcFlavor cfg)+          (flagToMaybe $ configHcPath cfg) (flagToMaybe $ configHcPkg cfg)+          programsConfig (lessVerbose verbosity)+        let version = compilerVersion comp+            flavor  = compilerFlavor comp++        -- Create a PackageIndex that makes *any libraries that might be*+        -- defined internally to this package look like installed packages, in+        -- case an executable should refer to any of them as dependencies.+        --+        -- It must be *any libraries that might be* defined rather than the+        -- actual definitions, because these depend on conditionals in the .cabal+        -- file, and we haven't resolved them yet.  finalizePackageDescription+        -- does the resolution of conditionals, and it takes internalPackageSet+        -- as part of its input.+        --+        -- Currently a package can define no more than one library (which has+        -- the same name as the package) but we could extend this later.+        -- If we later allowed private internal libraries, then here we would+        -- need to pre-scan the conditional data to make a list of all private+        -- libraries that could possibly be defined by the .cabal file.+        let pid = packageId pkg_descr0+            internalPackage = emptyInstalledPackageInfo {+                --TODO: should use a per-compiler method to map the source+                --      package ID into an installed package id we can use+                --      for the internal package set. The open-codes use of+                --      InstalledPackageId . display here is a hack.+                Installed.installedPackageId = InstalledPackageId $ display $ pid,+                Installed.sourcePackageId = pid+              }+            internalPackageSet = PackageIndex.fromList [internalPackage]+        installedPackageSet <- getInstalledPackages (lessVerbose verbosity) comp+                                      packageDbs programsConfig'++        let -- Constraint test function for the solver+            dependencySatisfiable =+                not . null . PackageIndex.lookupDependency pkgs'+              where+                pkgs' = PackageIndex.insert internalPackage installedPackageSet+            enableTest t = t { testEnabled = fromFlag (configTests cfg) }+            flaggedTests = map (\(n, t) -> (n, mapTreeData enableTest t))+                               (condTestSuites pkg_descr0)+            enableBenchmark bm = bm { benchmarkEnabled = fromFlag (configBenchmarks cfg) }+            flaggedBenchmarks = map (\(n, bm) -> (n, mapTreeData enableBenchmark bm))+                               (condBenchmarks pkg_descr0)+            pkg_descr0'' = pkg_descr0 { condTestSuites = flaggedTests+                                      , condBenchmarks = flaggedBenchmarks }++        (pkg_descr0', flags) <-+                case finalizePackageDescription+                       (configConfigurationsFlags cfg)+                       dependencySatisfiable+                       Distribution.System.buildPlatform+                       (compilerId comp)+                       (configConstraints cfg)+                       pkg_descr0''+                of Right r -> return r+                   Left missing ->+                       die $ "At least the following dependencies are missing:\n"+                         ++ (render . nest 4 . sep . punctuate comma+                                    . map (disp . simplifyDependency)+                                    $ missing)++        -- add extra include/lib dirs as specified in cfg+        -- we do it here so that those get checked too+        let pkg_descr =+                enableCoverage (fromFlag (configLibCoverage cfg)) distPref+                $ addExtraIncludeLibDirs pkg_descr0'++        -- installation directories+        defaultDirs <- defaultInstallDirs flavor userInstall (hasLibs pkg_descr)+        let installDirs = combineInstallDirs fromFlagOrDefault+                            defaultDirs (configInstallDirs cfg)++        let dirs = InstallDirs.absoluteInstallDirs+                (packageId pkg_descr)+                (compilerId comp)+                NoCopyDest+                installDirs+        return $ datadir dirs+    where+      addExtraIncludeLibDirs pkg_descr =+          let extraBi = mempty { extraLibDirs = configExtraLibDirs cfg+                               , PD.includeDirs = configExtraIncludeDirs cfg}+              modifyLib l        = l{ libBuildInfo = libBuildInfo l `mappend` extraBi }+              modifyExecutable e = e{ buildInfo    = buildInfo e    `mappend` extraBi}+          in pkg_descr{ library     = modifyLib        `fmap` library pkg_descr+                      , executables = modifyExecutable  `map` executables pkg_descr}++-- -----------------------------------------------------------------------------+-- Configuring package dependencies++getInstalledPackages :: Verbosity -> Compiler+                     -> PackageDBStack -> ProgramConfiguration+                     -> IO PackageIndex+getInstalledPackages verbosity comp packageDBs progconf = do+  info verbosity "Reading installed packages..."+  case compilerFlavor comp of+    GHC -> GHC.getInstalledPackages verbosity packageDBs progconf+    Hugs->Hugs.getInstalledPackages verbosity packageDBs progconf+    JHC -> JHC.getInstalledPackages verbosity packageDBs progconf+    LHC -> LHC.getInstalledPackages verbosity packageDBs progconf+    NHC -> NHC.getInstalledPackages verbosity packageDBs progconf+    UHC -> UHC.getInstalledPackages verbosity comp packageDBs progconf+    flv -> die $ "don't know how to find the installed packages for "+              ++ display flv++-- | Currently the user interface specifies the package dbs to use with just a+-- single valued option, a 'PackageDB'. However internally we represent the+-- stack of 'PackageDB's explictly as a list. This function converts encodes+-- the package db stack implicit in a single packagedb.+--+implicitPackageDbStack :: Bool -> Maybe PackageDB -> PackageDBStack+implicitPackageDbStack userInstall maybePackageDB+  | userInstall = GlobalPackageDB : UserPackageDB : extra+  | otherwise   = GlobalPackageDB : extra+  where+    extra = case maybePackageDB of+      Just (SpecificPackageDB db) -> [SpecificPackageDB db]+      _                           -> []++-- -----------------------------------------------------------------------------+-- Determining the compiler details++configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath+               -> ProgramConfiguration -> Verbosity+               -> IO (Compiler, ProgramConfiguration)+configCompiler Nothing _ _ _ _ = die "Unknown compiler"+configCompiler (Just hcFlavor) hcPath hcPkg conf verbosity = do+  case hcFlavor of+      GHC  -> GHC.configure  verbosity hcPath hcPkg conf+      JHC  -> JHC.configure  verbosity hcPath hcPkg conf+      LHC  -> do (_,ghcConf) <- GHC.configure  verbosity Nothing hcPkg conf+                 LHC.configure  verbosity hcPath Nothing ghcConf+      Hugs -> Hugs.configure verbosity hcPath hcPkg conf+      NHC  -> NHC.configure  verbosity hcPath hcPkg conf+      UHC  -> UHC.configure  verbosity hcPath hcPkg conf+      _    -> die "Unknown compiler"
+ libmorfeusz/README view
@@ -0,0 +1,61 @@+Morphological analyser Morfeusz Polimorf++The program including contained linguistic data is hereby released+under the conditions of the so called 2-clause BSD License:++-----------------------------------------------------------------------+Copyright © 2012 Zygmunt Saloni, Włodzimierz Gruszczyński, +	    	 Marcin Woliński, Robert Wołosz,+		 Marcin Miłkowski,+		 contributors of sjp.pl,+		 Institute of Computer Sciencie PAS++All rights reserved.++Redistribution and  use in  source and binary  forms, with  or without+modification, are permitted provided that the following conditions are+met:++1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the+   distribution.++THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDERS “AS IS” AND ANY EXPRESS+OR  IMPLIED WARRANTIES,  INCLUDING, BUT  NOT LIMITED  TO,  THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED.  IN NO EVENT  SHALL COPYRIGHT  HOLDERS OR  CONTRIBUTORS BE+LIABLE FOR  ANY DIRECT,  INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR+CONSEQUENTIAL DAMAGES  (INCLUDING, BUT NOT LIMITED  TO, PROCUREMENT OF+SUBSTITUTE  GOODS OR  SERVICES;  LOSS  OF USE,  DATA,  OR PROFITS;  OR+BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF LIABILITY,+WHETHER IN  CONTRACT, STRICT LIABILITY, OR  TORT (INCLUDING NEGLIGENCE+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+-----------------------------------------------------------------------+++For more information about the program we refer you to+http://sgjp.pl/morfeusz/ .  Reading this page is especially+recommended if you feel that the program gives strange answers or+“doesn’t work”.  Reading the following article may also help+(in Polish):++Marcin Woliński, “System znaczników morfosyntaktycznych w korpusie+IPI PAN”, Polonica XXII–XXIII, pp. 39–55, 2003.++Those interested in modifying the program will quickly find that the+code is full of oddities and is not very ceeplusplusy.  We deeply+apologise for that.  Some help in understanding the program’s inner+workings may come from the article:++Marcin Woliński, “Morfeusz — a Practical Tool for the Morphological+Analysis of Polish”, In: Mieczysław Kłopotek, Sławomir Wierzchoń,+Krzysztof Trojanowski, eds., Intelligent Information Processing and+Web Mining, IIS:IIPWM'06 Proceedings, pp. 503–512, Springer, 2006.++The authors of Morfeusz can be contacted under the address+sgjpol@gmail.com.
+ libmorfeusz/libmorfeusz.so view

file too large to diff

+ libmorfeusz/morfeusz.h view
@@ -0,0 +1,134 @@+/* morfeusz.h+   Copyright (c) by Marcin Woliński +   $Date: 2009/01/06 18:48:06 $++   C language interface for Morfeusz morphological analyser++*/++#ifndef __MORFEUSZ_H__+#define __MORFEUSZ_H__++#ifndef __WIN32+#define DLLIMPORT+#else+/* A Windows system.  Need to define DLLIMPORT. */+#if BUILDING_MORFEUSZ+#  define DLLIMPORT __declspec (dllexport)+#else+#  define DLLIMPORT __declspec (dllimport)+#endif+#endif++#ifdef __cplusplus+extern "C" {+#endif /* __cplusplus */+++  /* Returns a string containing information on authors and version of+     the library:+  */++  DLLIMPORT char *morfeusz_about();++++  /* +     The result of analysis is  a directed acyclic graph with numbered+     nodes representing positions  in text (points _between_ segments)+     and edges representing interpretations of segments that span from+     one node to another.  E.g.,++         {0,1,"ja","ja","ppron12:sg:nom:m1.m2.m3.f.n1.n2:pri"}+         |+         |      {1,2,"został","zostać","praet:sg:m1.m2.m3:perf"}+         |      |+       __|  ____|   __{2,3,"em","być","aglt:sg:pri:imperf:wok"}+      /  \ /     \ / \+     * Ja * został*em *+     0    1       2   3++     Note that the word 'zostałem' got broken into 2 separate segments.++     The structure below describes one edge of this DAG:++  */++  struct _InterpMorf {+    int p, k; /* number of start node and end node */+    char *forma, /* segment (token) */+      *haslo, /* lemma */+      *interp; /* morphosyntactic tag */+  };+  typedef struct _InterpMorf InterpMorf;++++  /* Analyse a piece of text:++     'tekst' - the string to be analysed.  It should neither start nor+     end  within a  word.   Morfeusz has  limited  space for  results.+     Don't pass  to this function more  than a typical  paragraph at a+     time.  The best  strategy is probably to pass  to Morfeusz either+     separate words  or lines  of text.   If the text  is too  long to+     analyse the function will return empty result, that is with p==-1+     in the first structure returned.++     RETURNS a  table of  InterpMorf structures representing  edges of+     the  resulting  graph.   The  result  remains  valid  until  next+     invocation of morfeusz_analyse().  The function does not allocate+     any memory, the space is reused on subsequent invocations.++     The  starting node  of resulting  graph has  value of  0  on each+     invocation.  The end of results is marked with a sentinel element+     having the value -1 in the 'p' field.  If a segment is unknown to+     Morfeusz,  the  'haslo'  and  'interp' fields  in  the  resulting+     structure are NULL.+  */++  DLLIMPORT InterpMorf *morfeusz_analyse(char *tekst);++  /*+    Set options:++    'option' is set to  'value'.  Available options are represented by+    #defines listed below.++    RETURNS 1 (true) on success,  0 (false) on failure (no such option+    or value).+   */++  DLLIMPORT int morfeusz_set_option(int option, int value);++  /* +     MORFOPT_ENCODING:+     +     The encoding  used for  'tekst' argument of  morfeusz_analyse and+     fields  'forma',  'haslo',  and  'interp' of  results.   Possible+     values: UTF-8, ISO-8859-2 (default), CP1250, CP852.+  */++#define MORFOPT_ENCODING 1++#define MORFEUSZ_UTF_8      8+#define MORFEUSZ_ISO8859_2  88592+#define MORFEUSZ_CP1250     1250+#define MORFEUSZ_CP852      852++  /* MORFOPT_WHITESPACE:++     MORFEUSZ_SKIP_SPACE: whitespace characters are silently ignored+     MORFEUSZ_KEEP_SPACE: whitespace characters are reported as tokens+  */++#define MORFOPT_WHITESPACE 2++#define MORFEUSZ_SKIP_WHITESPACE 0+#define MORFEUSZ_KEEP_WHITESPACE 2+++#ifdef __cplusplus+} /* extern C */+#endif /* __cplusplus */++#endif /* __MORFEUSZ_H__ */
morfeusz.cabal view
@@ -1,5 +1,5 @@ name:               morfeusz-version:            0.4.0+version:            0.4.1 synopsis:           Bindings to the morphological analyser Morfeusz description:     The library provides bindings to the morphological analyser Morfeusz@@ -13,16 +13,37 @@ stability:          experimental category:           Natural Language Processing homepage:           https://github.com/kawu/morfeusz-build-type:         Simple+build-type:         Custom +extra-source-files:+  Setup/Configure.hs+  libmorfeusz/morfeusz.h++data-dir: libmorfeusz++data-files: README, libmorfeusz.so+ library   exposed-modules:  NLP.Morfeusz   other-modules:    NLP.Morfeusz.Lock, NLP.Morfeusz.Lock.Internal-  build-depends:    base >= 4 && < 5, containers, text, bytestring, mtl-  includes:         morfeusz.h-  extra-libraries:  morfeusz++  -- Package 'directory' is a Setup dependency!+  build-depends:+      base >= 4 && < 5+    , containers+    , text+    , bytestring+    , mtl+    , directory+   extensions:       ForeignFunctionInterface   c-sources:        cbits/global.c++  -- extra-lib-dirs is set programmaticaly in Setup.Configure.+  include-dirs:       libmorfeusz   +  includes:           morfeusz.h+  extra-libraries:    morfeusz+  source-repository head     type: git