docs: def convert_to_gt( text, layer_name=GT_WORDS ):
      ''' Converts all words in a morphologically analysed Text from FS format to 
          giellatekno (GT) format, and stores in a new layer named GT_WORDS. 
          If the keyword argument *layer_name=='words'* , overwrites the old 'words' 
          layer with the new layer containing GT format annotations. 
  
          Parameters
          -----------
          text : estnltk.text.Text
              Morphologically annotated text that needs to be converted from FS format 
              to GT format;
          
          layer_name : str
              Name of the Text's layer in which GT format morphological annotations 
              are stored; 
              Defaults to GT_WORDS;
      '''
      assert WORDS in text, \
          '(!) The input text should contain "'+str(WORDS)+'" layer.'
      assert len(text[WORDS])==0 or (len(text[WORDS])>0 and ANALYSIS in text[WORDS][0]), \
          '(!) Words in the input text should contain "'+str(ANALYSIS)+'" layer.'
      new_words_layer = []
      # 1) Perform the conversion
      for word in text[WORDS]:
          new_analysis = []
          new_analysis.extend( convert_analysis( word[ANALYSIS] ) )
          new_words_layer.append( {TEXT:word[TEXT], ANALYSIS:new_analysis, START:word[START], END:word[END]} )
      # 2) Perform some context-specific disambiguation
      _disambiguate_neg( new_words_layer )
      _disambiguate_sid_ksid( new_words_layer, text, scope=CLAUSES )
      _disambiguate_sid_ksid( new_words_layer, text, scope=SENTENCES )
      _make_postfixes_2( new_words_layer )
      # 3) Attach the layer
      if layer_name != WORDS:
          #  Simply attach the new layer
          text[layer_name] = new_words_layer
      else:
          #  Perform word-by-word replacements
          # (because simple attaching won't work here)
          for wid, new_word in enumerate( new_words_layer ):
              text[WORDS][wid] = new_word
      return text