Пример #1
0
def map_to_owl(json_data):
    for d in json_data:
        """mapping json data to ontology properties"""
        name = Preprocessor.toolname_underline(d['name'])
        # name = re.sub("[()-*,/]", " ", name).strip()
        executable = Preprocessor.normalize("saga_cmd ", d['command']['exec'])
        keywords = d['keywords']
        toolClass = tool_class(keywords)
        if onto[name]:
            # if has the same name and executable
            if onto[name].executable == executable:
                onto[name].is_a.append(toolClass)
                continue
            else:
                name = name + '_' + keywords[0].replace(' ', '_')
        tool = toolClass(name,
                         prefLabel=locstr(re.sub('^(Tool)[0-9: ]+', '',
                                                 d['name']),
                                          lang='en'))
        # tool = toolClass(Preprocessor.space_2_underline(name), prefLabel=locstr(re.sub('^(Tool)[0-9: ]+', '', d['name']), lang='en'))
        tool.isToolOfSoftware.append(cyber.SAGA_GIS)
        tool.identifier = name
        tool.manualPageURL.append(d['manual_url'])
        # task
        handle_task(tool, name, d['name'], keywords,
                    OWLUtils.join_list(d['description']))
        tool.executable = executable
        tool.commandLine.append(
            Preprocessor.normalize("Usage: ", d['command']['cmd_line']))
        tool.authors.append(OWLUtils.join_keywords(d['authors']))
        for reference in d['references']:
            tool.references.append(reference)
        # keywords
        keywords.append(name.replace('_', ' '))
        OWLUtils.link_to_domain_concept(tool, keywords)

        # applicaiton category
        OWLUtils.application_category(tool, [d['keywords'][0]],
                                      d['keywords'][1], d['keywords'][2:])

        tool.description.append(OWLUtils.join_list(d['description']))
        if d['parameters']:
            for item, itemValue in d['parameters'].items():
                if item == 'inputs':
                    handle_inout(tool, itemValue, 'input')
                elif item == 'outputs':
                    handle_inout(tool, itemValue, 'output')
                elif item == 'options':
                    for optionItem in itemValue:
                        handle_options(tool, optionItem, onto)
Пример #2
0
def gen_shacl(json_data):
    for d in json_data:
        name = Preprocessor.toolname_underline(d['name'])
        name = re.sub("[()-*,/]_", " ", name).strip()
        if d['parameters']:
            for item, itemValue in d['parameters'].items():
                if item == 'options':
                    for optionItem in itemValue:
                        shape = URIRef(saga_uri + name.replace(" ", '') +
                                       'Shape')
                        graph.add((shape, RDF.type, sh.ShapeNode))
                        graph.add(
                            (shape, sh.TargetNode, URIRef(saga_uri + name)))
                        shapeGraph = BNode()
Пример #3
0
def map_to_owl(json_data):
	for d in json_data:
		toolClass = tool_class(d['category'])
		name = Preprocessor.toolname_underline(d['title'])
		tool = toolClass(name, prefLabel=locstr(d['title'], lang='en'))
		tool.isToolOfSoftware.append(cyber.Whitebox_Tools)
		tool.identifier = name
		tool.manualPageURL.append('https://github.com/jblindsay/whitebox-tools/blob/master/manual/WhiteboxToolsManual.md')
		tool.executable = 'whitebox_tools'
		tool.commandLine.append(d['parameter_commandline'][0])
		tool.description.append(locstr(d['description'], lang='en'))

		keywords = OWLUtils.to_keywords(d['description'])
		keywords.extend(d['title'].split(" "))
		OWLUtils.link_to_domain_concept(tool, keywords)

		handle_task(tool, d['category'], d['title'], d['description'])
		OWLUtils.application_category(tool, [], d['category'].replace(' Tools', ''), [])
		for parameter in d['parameter']:
			handle_parameter(tool, parameter)