本文整理汇总了Python中dipper.utils.GraphUtils.GraphUtils.get_properties_from_graph方法的典型用法代码示例。如果您正苦于以下问题:Python GraphUtils.get_properties_from_graph方法的具体用法?Python GraphUtils.get_properties_from_graph怎么用?Python GraphUtils.get_properties_from_graph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dipper.utils.GraphUtils.GraphUtils
的用法示例。
在下文中一共展示了GraphUtils.get_properties_from_graph方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse
# 需要导入模块: from dipper.utils.GraphUtils import GraphUtils [as 别名]
# 或者: from dipper.utils.GraphUtils.GraphUtils import get_properties_from_graph [as 别名]
def test_parse(self):
if self.source is not None: # don't test the abstract class
self.source.parse()
"""
seems we get a better stack trace by not catching the exception
am I missing something?
try:
self.source.parse()
except Exception as ParseException: # tec too broad?
logger.error(ParseException)
self.assertFalse(True, "Parsing failed")
"""
try:
properties = GraphUtils.get_properties_from_graph(self.source.graph)
GraphUtils.add_property_axioms(self.source.graph, properties)
self.source.write() # default to fmt='turtle'
#self.source.write(fmt='nt')
#self.source.write(fmt='nquads')
except Exception as WriteException:
logger.error(WriteException)
self.assertFalse(True, "Write failed")
return
示例2: main
# 需要导入模块: from dipper.utils.GraphUtils import GraphUtils [as 别名]
# 或者: from dipper.utils.GraphUtils.GraphUtils import get_properties_from_graph [as 别名]
#.........这里部分代码省略.........
elif args.dest_fmt == 'notation3':
args.dest_fmt = 'n3'
else:
LOG.error("You have specified an invalid serializer: %s", args.dest_fmt)
exit(0)
else:
args.dest_fmt = 'turtle'
# Provide feedback if we can't proceed
if args.sources is None or args.sources.split(',')[0] not in source_to_class_map:
LOG.info('Unknown Source %s', args.sources.split(',')[0])
LOG.info('Sources Known are limited to:')
for key in sorted(source_to_class_map):
LOG.info('\t%s\t%s', key, source_to_class_map[key])
exit(0)
# iterate through all the sources
for source in args.sources.split(','):
LOG.info("\n******* %s *******", source)
source = source.lower()
src = source_to_class_map[source]
# import source lib
module = "dipper.sources.{0}".format(src)
imported_module = importlib.import_module(module)
source_class = getattr(imported_module, src)
mysource = None
# arg factory
source_args = dict(
graph_type=args.graph
)
source_args['are_bnodes_skolemized'] = not args.use_bnodes
# args should be available to source supported (yet) or not
if src in taxa_supported:
source_args['tax_ids'] = tax_ids
if args.version:
source_args['version'] = args.version
mysource = source_class(**source_args)
if args.parse_only is False:
start_fetch = time.perf_counter()
mysource.fetch(args.force)
end_fetch = time.perf_counter()
LOG.info("Fetching time: %d sec", end_fetch-start_fetch)
mysource.settestonly(args.test_only)
# run tests first
if (args.no_verify or args.skip_tests) is not True:
suite = mysource.getTestSuite()
if suite is None:
LOG.warning(
"No tests configured for this source: %s", source)
else:
unittest.TextTestRunner(verbosity=2).run(suite)
else:
LOG.info("Skipping Tests for source: %s", source)
if args.test_only is False and args.fetch_only is False:
start_parse = time.perf_counter()
mysource.parse(args.limit)
end_parse = time.perf_counter()
LOG.info("Parsing time: %d sec", end_parse-start_parse)
if args.graph == 'rdf_graph':
LOG.info("Found %d nodes", len(mysource.graph))
# Add property axioms
start_axiom_exp = time.perf_counter()
LOG.info("Adding property axioms")
properties = GraphUtils.get_properties_from_graph(mysource.graph)
GraphUtils.add_property_axioms(mysource.graph, properties)
end_axiom_exp = time.clock()
LOG.info("Property axioms added: %d sec", end_axiom_exp-start_axiom_exp)
start_write = time.perf_counter()
mysource.write(fmt=args.dest_fmt)
end_write = time.perf_counter()
LOG.info("Writing time: %d sec", end_write-start_write)
# if args.no_verify is not True:
# status = mysource.verify()
# if status is not True:
# LOG.error(
# 'Source %s did not pass verification tests.', source)
# exit(1)
# else:
# LOG.info('skipping verification step')
LOG.info('***** Finished with %s *****', source)
# load configuration parameters
# for example, keys
LOG.info("All done.")