def test_setting_display_morphology(self): po = ParseOptions() po.display_morphology = True self.assertEqual(po.display_morphology, True) self.assertEqual(clg.parse_options_get_display_morphology(po._obj), 1) po.display_morphology = False self.assertEqual(po.display_morphology, False) self.assertEqual(clg.parse_options_get_display_morphology(po._obj), 0)
def test_setting_display_morphology(self): po = ParseOptions() po.display_morphology = True self.assertEqual(po.display_morphology, True) self.assertEqual(clg.parse_options_get_display_morphology(po._obj), 1) po.display_morphology = False self.assertEqual(po.display_morphology, False) self.assertEqual(clg.parse_options_get_display_morphology(po._obj), 0)
arg = args.parse_args() try: lgdict = Dictionary(arg.lang) except LG_Error: # The default error handler will print the error message args.print_usage() sys.exit(2) po = ParseOptions(verbosity=arg.verbosity) po.max_null_count = 999 # > allowed maximum number of words po.max_parse_time = 10 # actual parse timeout may be about twice bigger po.spell_guess = True if DISPLAY_GUESSES else False po.display_morphology = arg.morphology print("Enter sentences:") # iter(): avoid python2 input buffering for sentence_text in iter(sys.stdin.readline, ''): if sentence_text.strip() == '': continue sent = Sentence(str(sentence_text), lgdict, po) try: linkages = sent.parse() except LG_TimerExhausted: print('Sentence too complex for parsing in ~{} second{}.'.format( po.max_parse_time, nsuffix(po.max_parse_time))) continue if not linkages: print('Error occurred - sentence ignored.')
DISPLAY_GUESSES = True # Display regex and POS guesses DEBUG_POSITION = True # Debug word position DISPLAY_MORPHOLOGY = True lang = 'en' if len(sys.argv) > 1: lang = sys.argv[1] po = ParseOptions(verbosity=0) # 1=more verbose; 2=trace; >5=debug lgdict = Dictionary(lang) po.max_null_count = 999 # > allowed maximum number of words po.max_parse_time = 10 # actual parse timeout may be about twice bigger po.spell_guess = True if DISPLAY_GUESSES else False po.display_morphology = True if DISPLAY_MORPHOLOGY else False if sys.version_info < (3, 0): import codecs #sys.stdout = codecs.getreader('utf-8')(sys.stdout) print("Enter sentences:") # iter(): avoid python2 input buffering for sentence_text in iter(sys.stdin.readline, ''): if sentence_text.strip() == '': continue sent = Sentence(str(sentence_text), lgdict, po) try: linkages = sent.parse() except LG_TimerExhausted: print('Sentence too complex for parsing in ~{} second{}.'.format(
arg = args.parse_args() try: lgdict = Dictionary(arg.lang) except LG_Error: # The default error handler will print the error message args.print_usage() sys.exit(2) po = ParseOptions(verbosity=arg.verbosity) po.max_null_count = 999 # > allowed maximum number of words po.max_parse_time = 10 # actual parse timeout may be about twice bigger po.spell_guess = True if DISPLAY_GUESSES else False po.display_morphology = arg.morphology # iter(): avoid python2 input buffering while True: sentence_text = get_input("sentence-check: ") if sentence_text.strip() == '': continue sent = Sentence(str(sentence_text), lgdict, po) try: linkages = sent.parse() except LG_TimerExhausted: print('Sentence too complex for parsing in ~{} second{}.'.format( po.max_parse_time,nsuffix(po.max_parse_time))) continue if not linkages: