code: def substitute_infinitives_as_subjects(sent_str):
      
      sent_doc = textacy.Doc(sent_str, lang='en_core_web_lg')
      #inf_pattern = r'<PART><VERB>+' # To aux/auxpass* csubj
      inf_pattern = r'<PART><VERB>' # To aux/auxpass* csubj
      infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern)
      inf_subjs = [] # => [[0,1],...]
      for inf in infinitives:
          if inf[0].text.lower() != 'to':
              continue
          if ('csubj' not in [w.dep_ for w in inf] and sent_doc[inf[-1].i + 1].dep_
                  != 'csubj'):
              continue
          if inf[-1].tag_ != 'VB':
              continue
          inf_subj = []
          for v in inf:
              inf_subj.append(v.i)
          inf_subjs.append(inf_subj) 
      new_sent_str = sent_str
      unusual_char = '形'
      for inf_subj in inf_subjs:
          start_inf = sent_doc[inf_subj[0]].idx 
          end_inf = sent_doc[inf_subj[-1]].idx + len(sent_doc[inf_subj[-1]])
          inf_len = end_inf - start_inf
          sub = (unusual_char * inf_len)
          new_sent_str = new_sent_str[:start_inf] + sub + new_sent_str[end_inf:]
      new_sent_str = re.sub('形+', '{}', new_sent_str)
      repl = [conjugate(sent_doc[i_s[-1]].text, tense='presentparticiple') for i_s in inf_subjs]
      return new_sent_str.format(*repl)
docs: If an infinitive is used as a subject, substitute the gerund.