code: def test_setter_getter(nlp_pipeline):
      int2str = {0: "ok", 1: "good", 2: "bad"}
      str2int = {"ok": 0, "good": 1, "bad": 2}
  
      def setter(self, value):
          self._classname = str2int[value]
  
      Sentence.add_property(
          "classname",
          getter=lambda self: int2str[self._classname]
          if self._classname is not None
          else None,
          setter=setter,
      )
  
      doc = nlp_pipeline(EN_DOC)
      sentence = doc.sentences[0]
      sentence.classname = "good"
      assert sentence._classname == 1
  
      # don't try this at home
      sentence._classname = 2
      assert sentence.classname == "bad"
  
file_path: stanza/stanza/tests/common/test_data_objects.py
imports: import pytest
  import stanza
  from stanza.models.common.doc import Document, Sentence, Word
  from stanza.tests import *
label_desc: Use image node_id 4 for calling a global function with example usage: test_setter_getter(nlp_pipeline) without return types