Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func simpleSlicer(phrase string) []string {
- slice := ""
- returns := make([]string, 0, 0)
- for x := 0; x < len(phrase); x++ {
- if string(phrase[x]) == " " {
- returns = append(returns, slice)
- slice = ""
- } else {
- slice += string(phrase[x])
- }
- }
- for x := 0; x < len(returns); x++ {
- if returns[x] == "a" || returns[x] == "an" || returns[x] == "the" {
- returns[x] = "^"
- }
- }
- return returns
- }
- func interpret(verbs []verb, nouns []*thing, phrase string) (verb, *thing, *thing) {
- slicedPhrase := simpleSlicer(phrase)
- subPhrases := make([]string, 0, 0)
- samples := make([]samp, 0, 0)
- for x := 0; x < len(slicedPhrase); x++ {
- subPhrases = append(subPhrases, "")
- for y := 0; y < len(subPhrases)-1; y++ {
- subPhrases[y] += " " + slicedPhrase[x]
- }
- subPhrases[len(subPhrases)-1] = slicedPhrase[x]
- pos := 1
- for y := 0; y < len(subPhrases); y++ {
- samps := interpretWord(verbs, nouns, subPhrases[y], pos)
- for z := 0; z < len(samps); z++ {
- samples = append(samples, samps[z])
- }
- pos++
- }
- }
- return nil, nil, nil
- }
- func interpretWord(verbs []verb, nouns []*thing, phrase string, pos int) []samp {
- samps := make([]samp, 0, 0)
- for _, v := range verbs {
- for _, vi := range v.verbs {
- if phrase == vi {
- // isVerb = true
- samps = append(samps, samp{true, false, &v, nil, vi, pos})
- }
- }
- for _, avi := range v.adverbs {
- if phrase == avi {
- // isAdverb = true
- samps = append(samps, samp{true, true, &v, nil, avi, pos})
- }
- }
- }
- for _, n := range nouns {
- for _, ni := range n.terms {
- if ni == phrase {
- // isNoun = true
- samps = append(samps, samp{false, false, nil, n, ni, pos})
- }
- }
- for _, aji := range n.adjectives {
- if phrase == aji {
- // isAdjective = true
- samps = append(samps, samp{false, true, nil, n, aji, pos})
- }
- }
- }
- return samps
- }
- type samp struct {
- verb bool
- secondary bool
- ver *verb
- nou *thing
- term string
- pos int
- }
Advertisement
Add Comment
Please, Sign In to add comment