def neighbors(self):
if len(self._sentence) == <NUM_LIT:1>:<EOL><INDENT>return {<EOL>'<STR_LIT:left>': None,<EOL>'<STR_LIT:right>': None<EOL>}<EOL><DEDENT>else:<EOL><INDENT>p = self._position<EOL>if -<NUM_LIT:1> < p < len(self._sentence):<EOL><INDENT>if <NUM_LIT:0> == self._position:<EOL><INDENT>return {<EOL>'<STR_LIT:left>': None,<EOL>'<STR_LIT:right>': self._sentence.word(p+<NUM_LIT:1>)<EOL>}<EOL><DEDENT>elif <NUM_LIT:0> < self._position < len(self._sentence) - <NUM_LIT:1>:<EOL><INDENT>return {<EOL>'<STR_LIT:left>':  self._sentence.word(p-<NUM_LIT:1>),<EOL>'<STR_LIT:right>': self._sentence.word(p+<NUM_LIT:1>)<EOL>}<EOL><DEDENT>else:<EOL><INDENT>return {<EOL>'<STR_LIT:left>': self._sentence.word(p-<NUM_LIT:1>),<EOL>'<STR_LIT:right>': None<EOL>}<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise IndexError()<EOL><DEDENT><DEDENT>
Returns the left and right neighbors as Word instance.
If the word is the first one in the sentence only the right neighbor is returned and vice versa.