Commits

Grzegorz Chrupała committed cc85281

Added nlp-scores-scripts.

  • Participants
  • Parent commits eb36c71

Comments (0)

Files changed (5)

File nlp-scores-scripts/LICENSE

+Copyright (c) 2013, Grzegorz Chrupała
+
+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 Grzegorz Chrupała 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.

File nlp-scores-scripts/Setup.hs

+import Distribution.Simple
+main = defaultMain

File nlp-scores-scripts/ap.hs

+{-# LANGUAGE OverloadedStrings #-}
+
+import NLP.Scores
+import Data.List.Split
+import Text.Printf
+import qualified Data.Text.Lazy as Text
+import qualified Data.Text.Lazy.IO as Text
+import qualified Data.Set as Set
+
+main = Text.interact $  Text.unlines . map format 
+       . map (uncurry avgPrecision . parse) 
+       . Text.lines
+
+format :: Double -> Text.Text
+format  = Text.pack . printf "%.4f"
+
+parse :: Text.Text -> (Set.Set Text.Text, [Text.Text])
+parse ln = 
+    let [g,t] = Text.words ln
+    in (Set.fromList . Text.splitOn "," $ g, Text.splitOn "," $ t)
+
+

File nlp-scores-scripts/mean.hs

+{-# LANGUAGE OverloadedStrings #-}
+import NLP.Scores
+import Data.List.Split
+import Text.Printf
+import qualified Data.Text.Lazy as Text
+import qualified Data.Text.Lazy.Read as Text
+import qualified Data.Text.Lazy.IO as Text
+
+main = Text.interact $  format . mean . map readDouble . Text.lines
+
+format :: Double -> Text.Text
+format  = Text.pack . printf "%.4f\n"
+
+readDouble x = 
+    case Text.double x of
+      Left err -> error err
+      Right (d, "") -> d

File nlp-scores-scripts/nlp-scores-scripts.cabal

+-- Initial nlp-scores-scripts.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name:                nlp-scores-scripts
+version:             0.1.0.0
+synopsis:            NLP scoring command-line programs
+-- description:         
+homepage:            https://bitbucket.org/gchrupala/lingo
+license:             BSD3
+license-file:        LICENSE
+author:              Grzegorz Chrupała
+maintainer:          pitekus@gmail.com
+category:            Natural Language Processing
+build-type:          Simple
+cabal-version:       >=1.8
+
+executable ap
+  main-is: ap.hs             
+
+  build-depends:       base ==4.6.*, nlp-scores == 0.5.*, text == 0.11.*, split == 0.2.*,
+                       containers == 0.5.*
+
+executable mean
+  main-is: mean.hs             
+
+  build-depends:       base ==4.6.*, nlp-scores == 0.5.*, text == 0.11.*, split == 0.2.*
+