Importing and processing input

Let's start by creating a vocab.go file in the root of our project directory. In here, you will define a number of reserved unicode characters that will represent the beginning/end of our sequences, as well as a BLANK character for padding out our sequences.

Note that we do not include our shakespeare.txt input file here. Instead, we build a vocabulary and index, and split up our input corpus into chunks:

package mainimport (  "fmt"  "strings")const START rune = 0x02const END rune = 0x03const BLANK rune = 0x04// vocab relatedvar sentences []stringvar vocab []runevar vocabIndex map[rune]intvar maxsent int = 30func initVocab(ss []string, thresh int) {  s := strings.Join(ss, " ")  fmt.Println(s) dict := make(map[rune]int) ...

Get Hands-On Deep Learning with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.