November 2018
Beginner to intermediate
348 pages
8h 32m
English
When dealing with natural language sentences, the first activity is typically to tokenize the sentence. Given a sentence that reads such as The child was learning a new word and was using it excessively. "Shan't!", she cried. We need to split the sentence into the components that make up the sentence. We call each component a token, hence the name of the process is tokenization. Here's one possible tokenization method, in which we do a simple strings.Split(a, " ").
Here's a simple program:
func main() { a := "The child was learning a new word and was using it excessively. \"shan't!\", she cried" dict := make(map[string]struct{}) words := strings.Split(a, " ") for _, word := range words{ fmt.Println(word) dict[word] = struct{}{} ...Read now
Unlock full access