summaryrefslogtreecommitdiff
path: root/vendor/github.com/DavidBelicza/TextRank/v2/parse/text.go
blob: aab27c36cbb0d890040df82edc3912b24da20117 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package parse

// Text struct contains a parsed text.
type Text struct {
	parsedSentences []ParsedSentence
}

// ParsedSentence struct contains the original raw sentences and their words.
type ParsedSentence struct {
	original string
	words    []string
}

// Append method creates a sentence and its words and append them to the Text
// object.
func (text *Text) Append(rawSentence string, words []string) {
	if len(words) > 0 {
		parsedSentence := ParsedSentence{
			original: rawSentence,
			words:    words,
		}

		text.parsedSentences = append(
			text.parsedSentences,
			parsedSentence,
		)
	}
}

// GetSentences method returns ParsedSentence slice from Text struct.
func (text *Text) GetSentences() []ParsedSentence {
	return text.parsedSentences
}

// GetWords methods returns the words string slice of ParsedSentence struct.
func (parsedSentence *ParsedSentence) GetWords() []string {
	return parsedSentence.words
}

// GetOriginal method returns the original sentence as a string from a
// ParsedSentence struct.
func (parsedSentence *ParsedSentence) GetOriginal() string {
	return parsedSentence.original
}