mirror of
https://github.com/arnaucube/goMarkov.git
synced 2026-02-07 11:26:45 +01:00
minimal changes and readme update
This commit is contained in:
@@ -8,3 +8,7 @@ generatedText := markov.generateText(states, firstWord, count)
|
|||||||
fmt.Println(generatedText)
|
fmt.Println(generatedText)
|
||||||
```
|
```
|
||||||
(in the text variable, goes the text content, can be loaded from a .txt file)
|
(in the text variable, goes the text content, can be loaded from a .txt file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
BIN
build/goMarkov
Executable file
BIN
build/goMarkov
Executable file
Binary file not shown.
BIN
goMarkov.gif
Normal file
BIN
goMarkov.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 480 KiB |
3
main.go
3
main.go
@@ -45,5 +45,6 @@ func main() {
|
|||||||
fmt.Println("generating text")
|
fmt.Println("generating text")
|
||||||
generatedText := markov.generateText(states, firstWord, count)
|
generatedText := markov.generateText(states, firstWord, count)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println(generatedText)
|
fmt.Println("generated text")
|
||||||
|
fmt.Println("\x1b[32;1m" + generatedText + "\x1b[0m")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func printLoading(n int, total int) {
|
|||||||
bar = append(bar, "█")
|
bar = append(bar, "█")
|
||||||
}
|
}
|
||||||
progressBar := strings.Join(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) {
|
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)
|
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)
|
//fmt.Println(states)
|
||||||
return states
|
return states
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ func (markov Markov) generateText(states []State, initWord string, count int) st
|
|||||||
word = getNextMarkovState(states, word)
|
word = getNextMarkovState(states, word)
|
||||||
generatedText = append(generatedText, word)
|
generatedText = append(generatedText, word)
|
||||||
}
|
}
|
||||||
generatedText = append(generatedText, ".")
|
//generatedText = append(generatedText, ".")
|
||||||
text := strings.Join(generatedText, " ")
|
text := strings.Join(generatedText, " ")
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user