Я узнал, что происходит.
Чтобы получить «список» токенов, выполните следующие действия.
# My Original Code(Perhaps even you)
syntax = client.analyze_syntax(document=document, encoding_type='UTF8')
# Changes to do
tokens = whatever_name_of_client.analyze_syntax(some_args).tokens
На странице с основными сведениями кажется, что Google иллюстрирует возможности этого метода. Не так, как это на самом деле вернется.
Это ответ, который я получил после внесения изменений
# The square brackets :)
[text {
content: "Google"
}
part_of_speech {
tag: NOUN
number: SINGULAR
proper: PROPER
}
dependency_edge {
head_token_index: 3
label: NSUBJ
}
lemma: "Google"
, text {
content: "certainly"
begin_offset: 7
}
part_of_speech {
tag: ADV
}
dependency_edge {
head_token_index: 3
label: ADVMOD
}
lemma: "certainly"
, text {
content: "should"
begin_offset: 17
}
part_of_speech {
tag: VERB
}
dependency_edge {
head_token_index: 3
label: AUX
}
lemma: "should"
, text {
content: "make"
begin_offset: 24
}
part_of_speech {
tag: VERB
}
dependency_edge {
head_token_index: 3
label: ROOT
}
lemma: "make"
, text {
content: "better"
begin_offset: 29
}
part_of_speech {
tag: ADJ
}
dependency_edge {
head_token_index: 5
label: AMOD
}
lemma: "good"
, text {
content: "documentation"
begin_offset: 36
}
part_of_speech {
tag: NOUN
number: SINGULAR
}
dependency_edge {
head_token_index: 3
label: DOBJ
}
lemma: "documentation"
, text {
content: "."
begin_offset: 49
}
part_of_speech {
tag: PUNCT
}
dependency_edge {
head_token_index: 3
label: P
}
lemma: "."
, text {
content: "I"
begin_offset: 51
}
part_of_speech {
tag: PRON
case: NOMINATIVE
number: SINGULAR
person: FIRST
}
dependency_edge {
head_token_index: 8
label: NSUBJ
}
lemma: "I"
, text {
content: "had"
begin_offset: 53
}
part_of_speech {
tag: VERB
mood: INDICATIVE
tense: PAST
}
dependency_edge {
head_token_index: 8
label: ROOT
}
lemma: "have"
, text {
content: "to"
begin_offset: 57
}
part_of_speech {
tag: PRT
}
dependency_edge {
head_token_index: 11
label: AUX
}
lemma: "to"
, text {
content: "really"
begin_offset: 60
}
part_of_speech {
tag: ADV
}
dependency_edge {
head_token_index: 11
label: ADVMOD
}
lemma: "really"
, text {
content: "try"
begin_offset: 67
}
part_of_speech {
tag: VERB
}
dependency_edge {
head_token_index: 8
label: XCOMP
}
lemma: "try"
, text {
content: "out"
begin_offset: 71
}
part_of_speech {
tag: PRT
}
dependency_edge {
head_token_index: 11
label: PRT
}
lemma: "out"
, text {
content: "stuff"
begin_offset: 75
}
part_of_speech {
tag: NOUN
number: SINGULAR
}
dependency_edge {
head_token_index: 11
label: DOBJ
}
lemma: "stuff"
, text {
content: "over"
begin_offset: 81
}
part_of_speech {
tag: ADP
}
dependency_edge {
head_token_index: 11
label: PREP
}
lemma: "over"
, text {
content: "their"
begin_offset: 86
}
part_of_speech {
tag: PRON
case: GENITIVE
number: PLURAL
person: THIRD
}
dependency_edge {
head_token_index: 16
label: POSS
}
lemma: "their"
, text {
content: "website"
begin_offset: 92
}
part_of_speech {
tag: NOUN
number: SINGULAR
}
dependency_edge {
head_token_index: 14
label: POBJ
}
lemma: "website"
, text {
content: "."
begin_offset: 99
}
part_of_speech {
tag: PUNCT
}
dependency_edge {
head_token_index: 8
label: P
}
lemma: "."
, text {
content: "What"
begin_offset: 101
}
part_of_speech {
tag: PRON
person: THIRD
}
dependency_edge {
head_token_index: 19
label: ATTR
}
lemma: "What"
, text {
content: "is"
begin_offset: 106
}
part_of_speech {
tag: VERB
mood: INDICATIVE
number: SINGULAR
person: THIRD
tense: PRESENT
}
dependency_edge {
head_token_index: 19
label: ROOT
}
lemma: "be"
, text {
content: "a"
begin_offset: 109
}
part_of_speech {
tag: DET
}
dependency_edge {
head_token_index: 21
label: DET
}
lemma: "a"
, text {
content: "car"
begin_offset: 111
}
part_of_speech {
tag: NOUN
number: SINGULAR
}
dependency_edge {
head_token_index: 19
label: NSUBJ
}
lemma: "car"
, text {
content: "though"
begin_offset: 115
}
part_of_speech {
tag: ADV
}
dependency_edge {
head_token_index: 19
label: ADVMOD
}
lemma: "though"
, text {
content: "?"
begin_offset: 121
}
part_of_speech {
tag: PUNCT
}
dependency_edge {
head_token_index: 19
label: P
}
lemma: "?"
]