From d925d786d8bbb32a1797d866b60daf49f97d954c Mon Sep 17 00:00:00 2001 From: LBBassani Date: Sat, 14 Nov 2020 14:34:27 -0300 Subject: [PATCH] =?UTF-8?q?Consertos=20finais=20e=20makefile=20Gera=C3=A7?= =?UTF-8?q?=C3=A3o=20do=20compilado,=20conserto=20de=20problemas=20nos=20i?= =?UTF-8?q?ndices=20aleat=C3=B3rios=20e=20de=20buffering=20output.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- DataHandler.hs | 2 +- main.hs | 6 +++++- makefile | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 makefile diff --git a/.gitignore b/.gitignore index 4e2cef0..ab8084f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ cabal.project.local~ .HTF/ .ghc.environment.* -testes \ No newline at end of file +testes +main \ No newline at end of file diff --git a/DataHandler.hs b/DataHandler.hs index 91f3181..435d27d 100644 --- a/DataHandler.hs +++ b/DataHandler.hs @@ -24,7 +24,7 @@ base_treino_teste regs percent seed = (base_treino, base_teste) where base_treino = [ regs!!x | x <- drop n aleatorios] base_teste = [ regs!!x | x <- take n aleatorios] - aleatorios = randomList tamanho seed (tamanho) + aleatorios = randomList tamanho seed (tamanho - 1) n = truncate $ fromIntegral(tamanho*percent)/100.0 tamanho = length regs diff --git a/main.hs b/main.hs index ce98e97..e84e8ae 100644 --- a/main.hs +++ b/main.hs @@ -4,6 +4,8 @@ import CentroidClassifier import NearestNeighbor import ClassifierAnalysis import Text.Printf +import System.IO + {- Primeiro trabalho computacional de Programação Funcional em Haskell. Realiza o treinamento de dois classificadores @@ -12,7 +14,9 @@ import Text.Printf -} main :: IO () -main = do --leitura dos parametros de entrada +main = do -- Impedir buffering para escrever todas as mensagens na tela + hSetBuffering stdout NoBuffering + --leitura dos parametros de entrada putStr("Forneca o nome do arquivo de entrada: ") entrada <- getLine putStr("Forneca o nome do arquivo de saida: ") diff --git a/makefile b/makefile new file mode 100644 index 0000000..ce8b71b --- /dev/null +++ b/makefile @@ -0,0 +1,2 @@ +all: main.hs + ghc -no-keep-hi-files -no-keep-o-files main.hs