1package parse
2
3// Text struct contains a parsed text.
4type Text struct {
5 parsedSentences []ParsedSentence
6}
7
8// ParsedSentence struct contains the original raw sentences and their words.
9type ParsedSentence struct {
10 original string
11 words []string
12}
13
14// Append method creates a sentence and its words and append them to the Text
15// object.
16func (text *Text) Append(rawSentence string, words []string) {
17 if len(words) > 0 {
18 parsedSentence := ParsedSentence{
19 original: rawSentence,
20 words: words,
21 }
22
23 text.parsedSentences = append(
24 text.parsedSentences,
25 parsedSentence,
26 )
27 }
28}
29
30// GetSentences method returns ParsedSentence slice from Text struct.
31func (text *Text) GetSentences() []ParsedSentence {
32 return text.parsedSentences
33}
34
35// GetWords methods returns the words string slice of ParsedSentence struct.
36func (parsedSentence *ParsedSentence) GetWords() []string {
37 return parsedSentence.words
38}
39
40// GetOriginal method returns the original sentence as a string from a
41// ParsedSentence struct.
42func (parsedSentence *ParsedSentence) GetOriginal() string {
43 return parsedSentence.original
44}