You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "os"
  6. "strconv"
  7. "strings"
  8. )
  9. func optionTweetMarkov(states []State) {
  10. fmt.Print("entry the first word: ")
  11. newcommand := bufio.NewReader(os.Stdin)
  12. firstWord, _ := newcommand.ReadString('\n')
  13. firstWord = strings.TrimSpace(firstWord)
  14. fmt.Print("first word: ")
  15. c.Purple(firstWord)
  16. c.Red("how many words you want on the text?")
  17. newcommand = bufio.NewReader(os.Stdin)
  18. answer, _ := newcommand.ReadString('\n')
  19. answer = strings.TrimSpace(answer)
  20. fmt.Print("Number of words on text to generate: ")
  21. c.Purple(answer)
  22. count, err := strconv.Atoi(answer)
  23. if err != nil {
  24. fmt.Println("incorrect entry, need a positive number")
  25. }
  26. c.Red("how many sentences you want to generate?")
  27. newcommand = bufio.NewReader(os.Stdin)
  28. answer, _ = newcommand.ReadString('\n')
  29. answer = strings.TrimSpace(answer)
  30. fmt.Print("Number of sentences to generate: ")
  31. c.Purple(answer)
  32. sentences, err := strconv.Atoi(answer)
  33. if err != nil {
  34. fmt.Println("incorrect entry, need a positive number")
  35. }
  36. fmt.Println("generating text")
  37. for i := 0; i < sentences; i++ {
  38. generatedText := markov.generateText(states, firstWord, count)
  39. c.Green(generatedText)
  40. }
  41. }