def test_string_keys(self): nodes = ["AFC", "BZ"] print(nodes) print(tuple(nodes)) print("{0[0]}{0[1]}".format(nodes)) print("{1}--{0}".format(*nodes)) pm = ParseMetrics() pm.average_parsed_ratio = Decimal("0.66") pm.sentences = 3 print("{sentences}>>{sentences}>>{parseability}".format( parseability=pm.parseability(pm), sentences=pm.sentences)) print("{nodes[2]}{nodes[1]}{nodes[0]}".format(nodes=["A", "B", "C"])) print("{nodes[1]}>>{sentences}>>{parseability}".format( parseability=pm.parseability(pm), sentences=pm.sentences, nodes=["A", "B", "C"]))
def test_grammar_cfg(conf_path: str) -> (Decimal, Decimal, Decimal): """ Test grammar using configuration(s) from a JSON file :param conf_path: Path to a configuration file :return: Tuple (ParseMetrics, ParseQuality) of the last processed test. """ pm, pq = ParseMetrics(), ParseQuality() try: cfgman = JsonFileConfigManager(conf_path) # dboard = HTMLFileDashboard(cfgman) dboard = TextFileDashboard(cfgman) if len( cfgman.get_config("", "dash-board")) else None parser = LGInprocParser() # Get configuration parameters config = cfgman.get_config("", "grammar-tester") # Create GrammarTester instance tester = GrammarTester(handle_path_string(config[0][CONF_GRMR_PATH]), handle_path_string(config[0][CONF_TMPL_PATH]), config[0][CONF_LNK_LIMIT], parser, dboard) # Config file may have multiple configurations for one component for cfg in config: # Run grammar test pm, pq = tester.test(handle_path_string(cfg[CONF_DICT_PATH]), handle_path_string(cfg[CONF_CORP_PATH]), handle_path_string(cfg[CONF_DEST_PATH]), handle_path_string(cfg[CONF_REFR_PATH]), get_options(cfg)) # Save dashboard data to whatever source the dashboard is bounded to dboard.update_dashboard() # print(pm.text(pm)) except Exception as err: print(str(err)) finally: return pm.parseability(pm), pq.parse_quality(pm), PQA(pm, pq)