Esempio n. 1
0
 def from_string(cls, s):
     """
     Initialize a new DAG from a Pennman style string.
     """
     if not cls._parser_singleton: # Initialize the AMR parser only once
         _parser_singleton = make_amr_parser()           
     try:
         ast = _parser_singleton.parseString(s)
     except pyparsing.ParseException, e:
         sys.stderr.write("Could not parse DAG: %s" % s)
         raise e 
Esempio n. 2
0
 def from_string(cls, amr_string):
     """
     Initialize a new abstract meaning representation from a Pennman style string.
     """
     if not cls._parser_singleton: # Initialize the AMR parser only once
         _parser_singleton = make_amr_parser()           
     try:
         ast = _parser_singleton.parseString(amr_string)
     except pyparsing.ParseException, e:
         sys.stderr.write("Could not parse AMR: %s" % amr_string)
         raise e