Browse Source

minimal changes and readme update

master
arnaucode 7 years ago
parent
commit
592f97ec63
5 changed files with 9 additions and 4 deletions
  1. +4
    -0
      README.md
  2. BIN
      build/goMarkov
  3. BIN
      goMarkov.gif
  4. +2
    -1
      main.go
  5. +3
    -3
      markov.go

+ 4
- 0
README.md

@ -8,3 +8,7 @@ generatedText := markov.generateText(states, firstWord, count)
fmt.Println(generatedText)
```
(in the text variable, goes the text content, can be loaded from a .txt file)
![Argos](https://raw.githubusercontent.com/arnaucode/goMarkov/master/goMarkov.gif "goMarkov")

BIN
build/goMarkov


BIN
goMarkov.gif

Before After
Width: 576  |  Height: 384  |  Size: 480 KiB

+ 2
- 1
main.go

@ -45,5 +45,6 @@ func main() {
fmt.Println("generating text")
generatedText := markov.generateText(states, firstWord, count)
fmt.Println("")
fmt.Println(generatedText)
fmt.Println("generated text")
fmt.Println("\x1b[32;1m" + generatedText + "\x1b[0m")
}

+ 3
- 3
markov.go

@ -26,7 +26,7 @@ func printLoading(n int, total int) {
bar = append(bar, "█")
}
progressBar := strings.Join(bar, "")
fmt.Printf("\r " + progressBar + " - " + strconv.Itoa(tantPerCent) + "%")
fmt.Printf("\r " + progressBar + " - " + strconv.Itoa(tantPerCent) + "")
}
func addWordToStates(states []State, word string) ([]State, int) {
@ -70,7 +70,7 @@ func calcMarkovStates(words []string) []State {
states[i].NextStates[j].Prob = (float64(states[i].NextStates[j].Count) / float64(len(words)) * 100)
}
}
fmt.Println("total words computed: " + strconv.Itoa(len(words)))
fmt.Println("\ntotal words computed: " + strconv.Itoa(len(words)))
//fmt.Println(states)
return states
}
@ -118,7 +118,7 @@ func (markov Markov) generateText(states []State, initWord string, count int) st
word = getNextMarkovState(states, word)
generatedText = append(generatedText, word)
}
generatedText = append(generatedText, ".")
//generatedText = append(generatedText, ".")
text := strings.Join(generatedText, " ")
return text
}

Loading…
Cancel
Save