Skip to content

Commit c0401ca

Browse files
committed
Added file write for training
1 parent 517f810 commit c0401ca

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: project
2+
version: 0.1.0.0
3+
id: project-0.1.0.0-2Scmje53n8s89ErMJTJgIF
4+
key: project-0.1.0.0-2Scmje53n8s89ErMJTJgIF
5+
license: BSD-3-Clause
6+
copyright: 2019 Author name here
7+
maintainer: [email protected]
8+
author: Author name here
9+
homepage: https://github.com/githubuser/project#readme
10+
description:
11+
Please see the README on GitHub at <https://github.com/githubuser/project#readme>
12+
abi: 6adbca45f363d8af52d0ac81af3c4e40
13+
exposed: True
14+
exposed-modules:
15+
Lib
16+
hidden-modules: Paths_project
17+
import-dirs: /Users/JugrajB/cpsc-312/project/.stack-work/install/x86_64-osx/e84c8ad8d8bb3370e9a352676bb26703752eda667e2ea564117ad883c9cd9779/8.6.5/lib/x86_64-osx-ghc-8.6.5/project-0.1.0.0-2Scmje53n8s89ErMJTJgIF
18+
library-dirs: /Users/JugrajB/cpsc-312/project/.stack-work/install/x86_64-osx/e84c8ad8d8bb3370e9a352676bb26703752eda667e2ea564117ad883c9cd9779/8.6.5/lib/x86_64-osx-ghc-8.6.5/project-0.1.0.0-2Scmje53n8s89ErMJTJgIF
19+
dynamic-library-dirs: /Users/JugrajB/cpsc-312/project/.stack-work/install/x86_64-osx/e84c8ad8d8bb3370e9a352676bb26703752eda667e2ea564117ad883c9cd9779/8.6.5/lib/x86_64-osx-ghc-8.6.5
20+
data-dir: /Users/JugrajB/cpsc-312/project/.stack-work/install/x86_64-osx/e84c8ad8d8bb3370e9a352676bb26703752eda667e2ea564117ad883c9cd9779/8.6.5/share/x86_64-osx-ghc-8.6.5/project-0.1.0.0
21+
hs-libraries: HSproject-0.1.0.0-2Scmje53n8s89ErMJTJgIF
22+
depends:
23+
base-4.12.0.0
24+
haddock-interfaces: /Users/JugrajB/cpsc-312/project/.stack-work/install/x86_64-osx/e84c8ad8d8bb3370e9a352676bb26703752eda667e2ea564117ad883c9cd9779/8.6.5/doc/project-0.1.0.0/project.haddock
25+
haddock-html: /Users/JugrajB/cpsc-312/project/.stack-work/install/x86_64-osx/e84c8ad8d8bb3370e9a352676bb26703752eda667e2ea564117ad883c9cd9779/8.6.5/doc/project-0.1.0.0

project/app/ChatClassifier.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ readCsv filename = do
1212
file <- readFile filename
1313
return [splitsep (==',') row | row <- ( splitsep (=='\n') file )]
1414

15+
writeCsv :: FilePath -> [Char] -> [Char] -> IO ()
16+
writeCsv filename c q = appendFile filename ("\n" ++ c ++ "," ++ q)
17+
1518
fetchAnswer :: FilePath -> Category -> IO String
1619
fetchAnswer filename c = do
1720
file <- readFile filename

project/app/Main.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module Main where
5656
hPutStrLn hdl ("Category: " ++ category)
5757

5858
let prob = probabilityForCategory chat_classifier question category
59+
-- hPutStrLn hdl ("Prob: " ++ (show prob))
60+
5961
let ansDir = (curdDir ++ "/project/src/answers.csv")
6062
str <- fetchAnswer ansDir (dropWhile (==' ') category)
6163

@@ -65,8 +67,9 @@ module Main where
6567
hPutStrLn hdl "Chatbot: To help us improve, was this answer helpful? (y/n)"
6668
answer <- fmap init (hGetLine hdl)
6769
if answer == "y"
68-
then
70+
then do
6971
--- if answer is good, add question with category to questions.csv
72+
write <- writeCsv (curdDir ++ "/project/src/questions.csv") (dropWhile (==' ') category) question
7073
hPutStrLn hdl "Chatbot: If you need anymore help feel free to ask another question, otherwise type 'quit' to exit"
7174
else
7275
-- nothing

project/src/questions.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ I forgot my password, password
66
Whats my password, password
77
My email doesn't work, email
88
When is my flight, leaving_flight
9-
What is my flight number, flight_number
9+
What is my flight number, flight_number
10+
password,My password

0 commit comments

Comments
 (0)