made command-line-args static so we can debug properly

This commit is contained in:
Nicole Dresselhaus 2013-11-27 16:38:54 +01:00
parent 31f0468cfd
commit 77bb358198
3 changed files with 19 additions and 16 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@
*.eventlog *.eventlog
*.lkshf *.lkshf
/.dist-buildwrapper
.project*

4
dist/setup-config vendored

File diff suppressed because one or more lines are too long

View File

@ -61,13 +61,13 @@ createAttr input = createAttr' (T.split (=='\t') input) (Left [])
createAttr' :: [T.Text] -> Either [Double] T.Text -> Either [Double] T.Text createAttr' :: [T.Text] -> Either [Double] T.Text -> Either [Double] T.Text
createAttr' (a:as) r = createAttr' (a:as) r =
let this = read (T.unpack a) :: Double in let this = read (T.unpack a) :: Double in
case isNaN this of (if isNaN this then
True -> Right $ T.append (T.pack "cannot parse ") a Right $ T.append (T.pack "cannot parse ") a
_ -> else
let next = (createAttr' as r) in (let next = (createAttr' as r) in
case next of case next of
Left rs -> Left (this:rs) Left rs -> Left (this : rs)
_ -> next _ -> next))
emptyLine :: T.Text -> Bool emptyLine :: T.Text -> Bool
emptyLine a emptyLine a
@ -105,13 +105,14 @@ infixl 1 +||
a +|| b = a `using` b a +|| b = a `using` b
exeMain = do exeMain = do
args <- getArgs -- args <- getArgs
input <- case args of -- input <- case args of
["--help"] -> showHelp -- ["--help"] -> showHelp
["-h"] -> showHelp -- ["-h"] -> showHelp
[] -> error "Error: No filename or stdinput (-) given." -- [] -> error "Error: No filename or stdinput (-) given."
[adj, attr] -> Prelude.mapM B.readFile [adj, attr] -- [adj, attr] -> Prelude.mapM B.readFile [adj, attr]
_ -> error "Wrong arguments given" -- _ -> error "Wrong arguments given"
input <- Prelude.mapM B.readFile ["sampledata.adj","sampledata.adj.atr"]
-- read file and clean -- read file and clean
adjMat <- return $ L.filter (not . emptyLine) (T.lines (decodeUtf8 (head input))) adjMat <- return $ L.filter (not . emptyLine) (T.lines (decodeUtf8 (head input)))
attrMat <- return $ L.filter (not . emptyLine) (T.lines (decodeUtf8 ((head . L.tail) input))) attrMat <- return $ L.filter (not . emptyLine) (T.lines (decodeUtf8 ((head . L.tail) input)))