packages feed

wordchoice 0.1.0.4 → 0.1.0.5

raw patch · 6 files changed

+152/−83 lines, 6 filesdep ~Chartdep ~Chart-diagramsdep ~GlobPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: Chart, Chart-diagrams, Glob, base, bytestring, containers, criterion, lens, optparse-applicative, pandoc, system-filepath, text, wordchoice

API changes (from Hackage documentation)

- Data.Text.WordCount: globFile :: [String] -> IO Text
+ Data.Text.WordCount: globFile :: String -> IO Text
- Data.Text.WordCount: makeDistribution :: BarsPlotValue a => [(a, Text)] -> EC (Layout PlotIndex a) ()
+ Data.Text.WordCount: makeDistribution :: BarsPlotValue a => [(a, Text)] -> StateT (Layout PlotIndex a) (State CState) ()
- Data.Text.WordCount: makeFile :: BarsPlotValue a => [(a, Text)] -> FilePath -> IO ()
+ Data.Text.WordCount: makeFile :: [(Int, Text)] -> FilePath -> IO ()
- Data.Text.WordCount.Exec: Program :: [FilePath] -> Maybe Int -> Maybe FilePath -> Program
+ Data.Text.WordCount.Exec: Program :: FilePath -> Maybe Int -> Maybe FilePath -> Program
- Data.Text.WordCount.Exec: [file] :: Program -> [FilePath]
+ Data.Text.WordCount.Exec: [file] :: Program -> FilePath

Files

README.md view
@@ -25,6 +25,7 @@  $ wordchoice test/ulysses.txt -n10 -o distribution.html ``` + ## Installation  ### Manual
src/Data/Text/WordCount.hs view
@@ -16,7 +16,7 @@ import qualified Data.Map.Lazy as M import Data.Map.Lens import Control.Lens hiding (argument)-import qualified Data.Text as T+import qualified Data.Text as TL -- .Lazy as TL import Data.Tuple import Data.Monoid import Data.List@@ -25,7 +25,6 @@ import Graphics.Rendering.Chart.Backend.Diagrams import Data.Char import Data.Text.WordCount.FileRead-import Graphics.Rendering.Chart.State  -- | Return top n words and their frequencies --@@ -33,21 +32,21 @@ -- >>> topN 2 "hello hello goodbye it is time is it why why why it it" -- [(4,"it"),(3,"why")] -- @-topN :: Int -> T.Text -> [(Int,T.Text)]+topN :: Int -> TL.Text -> [(Int,TL.Text)] topN n = take n . order . buildFreq -displayWords :: [(Int,T.Text)] -> T.Text+displayWords :: [(Int,TL.Text)] -> TL.Text displayWords [] = "" displayWords (pair:pairs) = display pair <> "\n" <> displayWords pairs-    where display (n,str) = (T.pack . show) n <> ": " <> str+    where display (n,str) = (TL.pack . show) n <> ": " <> str -buildFreq :: T.Text -> M.Map T.Text Int-buildFreq = count . T.words . T.map toLower+buildFreq :: TL.Text -> M.Map TL.Text Int+buildFreq = count . TL.words . TL.map toLower -order :: M.Map T.Text Int -> [(Int, T.Text)]+order :: M.Map TL.Text Int -> [(Int, TL.Text)] order = sortBy (flip (comparing fst)) . fmap swap . M.toList -count :: [T.Text] -> M.Map T.Text Int+count :: [TL.Text] -> M.Map TL.Text Int count words = foldr ((.) . wordFunction) id words M.empty     where wordFunction word map = case map ^. at word of             Nothing -> at word ?~ 1 $ map@@ -59,14 +58,12 @@ -- makeFile :: IO () -- makeFile [(4,"it"),(3,"why")] "out.html" -- @-makeFile :: BarsPlotValue a => [(a, T.Text)] -> FilePath -> IO ()+makeFile :: [(Int,TL.Text)] -> FilePath -> IO () makeFile points out = toFile def out (makeDistribution points) --- | Make a plot from values -makeDistribution :: BarsPlotValue a => [(a, T.Text)] -> EC (Layout PlotIndex a) () makeDistribution points = do     let values = addIndexes (fmap fst points)-    let alabels = fmap (T.unpack . snd) points+    let alabels = fmap (TL.unpack . snd) points     let fillStyle = solidFillStyle (opaque lightblue)     layout_title .= "Word Frequencies"     layout_x_axis . laxis_generate .= autoIndexAxis alabels
src/Data/Text/WordCount/Exec.hs view
@@ -10,16 +10,17 @@ import Data.Text.WordCount.FileRead  -- | Program datatype to be parsed-data Program = Program { file :: [FilePath]+data Program = Program { file :: FilePath                         , num :: Maybe Int                         , output :: Maybe FilePath } -- TODO add option for separators  -- | Command line argument parser program :: Parser Program program = Program-    <$> (many (argument str+    <$> (argument str         (metavar "FILEPATH"-        <> help "Files to analyze together")))+        <> completer (bashCompleter "file -o plusdirs")+        <> help "File to analyze"))     <*> (optional (read <$> strOption         (short 'n'         <> long "number"
src/Data/Text/WordCount/FileRead.hs view
@@ -11,8 +11,10 @@ eitherError = either (error . show) id  -- | Process files given a filename glob-globFile :: [String] -> IO T.Text-globFile files = fmap T.concat . sequence $ fmap processFile files+globFile :: String -> IO T.Text+globFile str = do+    files <- glob str+    fmap T.concat . sequence $ fmap processFile files  -- | Process a file given a filename. Return text only, discarding superflouous material. processFile :: String -> IO T.Text
stack.yaml view
@@ -1,6 +1,66 @@-resolver: lts-8.12+# This file was automatically generated by 'stack init'+#+# Some commonly used options have been documented as comments in this file.+# For advanced use and comprehensive documentation of the format, please see:+# http://docs.haskellstack.org/en/stable/yaml_configuration/++# Resolver to choose a 'specific' stackage snapshot or a compiler version.+# A snapshot resolver dictates the compiler version and the set of packages+# to be used for project dependencies. For example:+#+# resolver: lts-3.5+# resolver: nightly-2015-09-21+# resolver: ghc-7.10.2+# resolver: ghcjs-0.1.0_ghc-7.10.2+# resolver:+#  name: custom-snapshot+#  location: "./custom-snapshot.yaml"+resolver: lts-8.18++# User packages to be built.+# Various formats can be used as shown in the example below.+#+# packages:+# - some-directory+# - https://example.com/foo/bar/baz-0.0.2.tar.gz+# - location:+#    git: https://github.com/commercialhaskell/stack.git+#    commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a+# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a+#   extra-dep: true+#  subdirs:+#  - auto-update+#  - wai+#+# A package marked 'extra-dep: true' will only be built if demanded by a+# non-dependency (i.e. a user package), and its test suites and benchmarks+# will not be run. This is useful for tweaking upstream packages. packages: - '.'+# Dependency packages to be pulled from upstream that are not in the resolver+# (e.g., acme-missiles-0.3) extra-deps: []++# Override default flag values for local packages and extra-deps flags: {}++# Extra package databases containing global packages extra-package-dbs: []++# Control whether we use the GHC we find on the path+# system-ghc: true+#+# Require a specific version of stack, using version ranges+# require-stack-version: -any # Default+# require-stack-version: ">=1.4"+#+# Override the architecture used by stack, especially useful on Windows+# arch: i386+# arch: x86_64+#+# Extra directories used by stack for building+# extra-include-dirs: [/path/to/dir]+# extra-lib-dirs: [/path/to/dir]+#+# Allow a newer minor version of GHC than the snapshot specifies+# compiler-check: newer-minor
wordchoice.cabal view
@@ -1,73 +1,81 @@-name:                wordchoice-version:             0.1.0.4-synopsis:            Get word counts and distributions-description:         A command line tool to compute the word distribution from various types of document, converting to text with pandoc.-homepage:            https://github.com/githubuser/wordchoice#readme-license:             BSD3-license-file:        LICENSE-author:              Author name here-maintainer:          example@example.com-copyright:           2017 Author name here-category:            Web-build-type:          Simple-extra-source-files:  README.md-                   , stack.yaml-                   , default.nix-                   , release.nix-cabal-version:       >=1.10+name: wordchoice+version: 0.1.0.5+cabal-version: >=1.10+build-type: Simple+license: BSD3+license-file: LICENSE+copyright: 2017 Author name here+maintainer: example@example.com+homepage: https://github.com/githubuser/wordchoice#readme+synopsis: Get word counts and distributions+description:+    A command line tool to compute the word distribution from various types of document, converting to text with pandoc.+category: Web+author: Author name here+extra-source-files:+    README.md+    stack.yaml+    default.nix+    release.nix -Flag llvm-fast {-  Description: Enable build with llvm backend-  Default: False-}+source-repository head+    type: git+    location: https://github.com/githubuser/wordchoice +flag llvm-fast+    description:+        Enable build with llvm backend+    default: False+ library-  hs-source-dirs:      src-  exposed-modules:     Data.Text.WordCount-                     , Data.Text.WordCount.Exec-  other-modules:       Paths_wordchoice-                     , Data.Text.WordCount.FileRead-  build-depends:       base >= 4.7 && < 5-                     , pandoc-                     , containers-                     , Glob-                     , text-                     , optparse-applicative-                     , Chart-                     , bytestring-                     , system-filepath-                     , Chart-diagrams-                     , lens-  default-language:    Haskell2010-  default-extensions:  OverloadedStrings+    exposed-modules:+        Data.Text.WordCount+        Data.Text.WordCount.Exec+    build-depends:+        base >=4.7 && <5,+        pandoc >=1.19.2.1 && <1.20,+        containers >=0.5.7.1 && <0.6,+        Glob >=0.7.14 && <0.8,+        text >=1.2.2.1 && <1.3,+        optparse-applicative >=0.13.2.0 && <0.14,+        Chart >=1.8.2 && <1.9,+        bytestring >=0.10.8.1 && <0.11,+        system-filepath >=0.4.13.4 && <0.5,+        Chart-diagrams >=1.8.2 && <1.9,+        lens >=4.15.1 && <4.16+    default-language: Haskell2010+    default-extensions: OverloadedStrings+    hs-source-dirs: src+    other-modules:+        Paths_wordchoice+        Data.Text.WordCount.FileRead  executable wrd-  hs-source-dirs:      app-  main-is:             Main.hs-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  build-depends:       base-                     , wordchoice-  default-language:    Haskell2010+    main-is: Main.hs+    build-depends:+        base >=4.9.1.0 && <4.10,+        wordchoice >=0.1.0.5 && <0.2+    default-language: Haskell2010+    hs-source-dirs: app+    ghc-options: -threaded -rtsopts -with-rtsopts=-N  test-suite wordchoice-test-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  main-is:             Spec.hs-  build-depends:       base-                     , wordchoice-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  default-language:    Haskell2010+    type: exitcode-stdio-1.0+    main-is: Spec.hs+    build-depends:+        base >=4.9.1.0 && <4.10,+        wordchoice >=0.1.0.5 && <0.2+    default-language: Haskell2010+    hs-source-dirs: test+    ghc-options: -threaded -rtsopts -with-rtsopts=-N  benchmark wordchoice-bench-  type:             exitcode-stdio-1.0-  hs-source-dirs:   bench-  main-is:          Bench.hs-  build-depends:    base-                  , criterion-                  , wordchoice-  ghc-options:       -threaded -rtsopts -with-rtsopts=-N -O3-  default-language: Haskell2010--source-repository head-  type:     git-  location: https://github.com/githubuser/wordchoice+    type: exitcode-stdio-1.0+    main-is: Bench.hs+    build-depends:+        base >=4.9.1.0 && <4.10,+        criterion >=1.1.4.0 && <1.2,+        wordchoice >=0.1.0.5 && <0.2+    default-language: Haskell2010+    hs-source-dirs: bench+    ghc-options: -threaded -rtsopts -with-rtsopts=-N -O3