code: def write_document(doc, fnm):
      
      with codecs.open(fnm, 'wb', 'ascii') as f:
          f.write(json.dumps(doc, indent=2))
docs: Write a Text document to file.
  
      Parameters
      ----------
      doc: Text
          The document to save.
      fnm: str
          The filename to save the document