Guest User

Untitled

a guest
Jun 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. module Main where
  2.  
  3. import Text.XML.Expat.Tree
  4. import Text.XML.Expat.Proc
  5. import System.Environment (getArgs)
  6. import Control.Monad (liftM)
  7. import qualified Data.ByteString.Lazy as C
  8.  
  9. justSentences t = filterChildrenName (=="sentence") t
  10.  
  11. main :: IO ()
  12. main = do
  13. f <- liftM head getArgs >>= C.readFile
  14. let (tree, mError) = parse defaultParseOptions f
  15. putStrLn . show $ (length $ justSentences (tree :: UNode String))
  16.  
  17. case mError of (Just err) -> putStrLn $ "Parsing error: " ++ (show err)
  18. Nothing -> return ()
Add Comment
Please, Sign In to add comment