|
|
@ -4,7 +4,6 @@ import ( |
|
|
|
"bufio" |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
@ -17,8 +16,14 @@ func main() { |
|
|
|
c.Purple("https://github.com/arnaucode/twFlock") |
|
|
|
fmt.Println("version " + version) |
|
|
|
fmt.Println("Reading flockConfig.json file") |
|
|
|
//flock := readConfigTokensAndConnect()
|
|
|
|
var flock Flock |
|
|
|
flock := readConfigTokensAndConnect() |
|
|
|
|
|
|
|
c.Yellow("generating markov chains (may take some seconds)") |
|
|
|
text, _ := readTxt("text.txt") |
|
|
|
states := markov.train(text) |
|
|
|
c.Green("markov chains generated") |
|
|
|
|
|
|
|
//var flock Flock
|
|
|
|
fmt.Println("---------------") |
|
|
|
newcommand := bufio.NewReader(os.Stdin) |
|
|
|
fmt.Print("Please select command number") |
|
|
@ -40,28 +45,7 @@ option to select: ` |
|
|
|
break |
|
|
|
case "2": |
|
|
|
fmt.Println("selected 2 - Markov") |
|
|
|
|
|
|
|
fmt.Print("entry the first word: ") |
|
|
|
newcommand := bufio.NewReader(os.Stdin) |
|
|
|
firstWord, _ := newcommand.ReadString('\n') |
|
|
|
firstWord = strings.TrimSpace(firstWord) |
|
|
|
fmt.Print("first word: ") |
|
|
|
c.Purple(firstWord) |
|
|
|
|
|
|
|
c.Red("how many words you want on the text?") |
|
|
|
newcommand = bufio.NewReader(os.Stdin) |
|
|
|
answer, _ := newcommand.ReadString('\n') |
|
|
|
answer = strings.TrimSpace(answer) |
|
|
|
fmt.Print("Number of words on text to generate: ") |
|
|
|
c.Purple(answer) |
|
|
|
count, err := strconv.Atoi(answer) |
|
|
|
if err != nil { |
|
|
|
fmt.Println("incorrect entry, need a positive number") |
|
|
|
} |
|
|
|
|
|
|
|
states := markov.train("the", "text.txt") |
|
|
|
generatedText := markov.generateText(states, firstWord, count) |
|
|
|
c.Green(generatedText) |
|
|
|
optionTweetMarkov(states) |
|
|
|
break |
|
|
|
case "0": |
|
|
|
fmt.Println("selected 0 - exit script") |
|
|
|