code: def main():
      """
      Runs a toy example, or can run a given semgrex expression on the given input file.
  
      For example:
      python3 -m stanza.server.semgrex --input_file demo/semgrex_sample.conllu
  
      --matches_only to only print sentences that match the semgrex pattern
      --no_print_input to not print the input
      """
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "--input_file",
          type=str,
          default=None,
          help="Input file to process (otherwise will process a sample text)",
      )
      parser.add_argument(
          "semgrex",
          type=str,
          nargs="*",
          default=["{}=source >obj=zzz {}=target"],
          help="Semgrex to apply to the text.  The default looks for sentences with objects",
      )
      parser.add_argument(
          "--semgrex_file",
          type=str,
          default=None,
          help="File to read semgrex patterns from - relevant in case the pattern you want to use doesn't work well on the command line, for example",
      )
      parser.add_argument(
          "--print_input",
          dest="print_input",
          action="store_true",
          default=False,
          help="Print the input alongside the output - gets kind of noisy",
      )
      parser.add_argument(
          "--no_print_input",
          dest="print_input",
          action="store_false",
          help="Don't print the input alongside the output - gets kind of noisy",
      )
      parser.add_argument(
          "--matches_only",
          action="store_true",
          default=False,
          help="Only print the matching sentences",
      )
      parser.add_argument(
          "--enhanced",
          action="store_true",
          default=False,
          help="Use the enhanced dependencies instead of the basic",
      )
      args = parser.parse_args()
  
      if args.semgrex_file:
          with open(args.semgrex_file) as fin:
              args.semgrex = [
                  x.strip() for x in fin.readlines() if x.strip()
              ]
  
      if args.input_file:
          doc = CoNLL.conll2doc(
              input_file=args.input_file, ignore_gapping=False
          )
      else:
          nlp = stanza.Pipeline(
              "en", processors="tokenize,pos,lemma,depparse"
          )
          doc = nlp("Uro ruined modern.  Fortunately, Wotc banned him.")
  
      if args.print_input:
          print("{:C}".format(doc))
          print()
          print("-" * 75)
          print()
      semgrex_result = process_doc(
          doc, *args.semgrex, enhanced=args.enhanced
      )
      doc = annotate_doc(
          doc, semgrex_result, args.semgrex, args.matches_only
      )
      print("{:C}".format(doc))
  
file_path: stanza/stanza/server/semgrex.py
imports: import argparse
  import copy
  import stanza
  from stanza.protobuf import SemgrexRequest, SemgrexResponse
  from stanza.server.java_protobuf_requests import send_request, add_token, add_word_to_graph, JavaProtobufContext, convert_networkx_graph
  from stanza.utils.conll import CoNLL
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types