Пример #1
0
def map_to_owl(json_data):
	for d in json_data:
		"""mapping json data to ontology properties"""
		# instance 实例
		name = Preprocessor.name_underline(d['name'])
		toolClass = tool_class(d['name'])
		tool = toolClass(name, prefLabel=locstr(d['name'], lang='en'))
		tool.isToolOfSoftware.append(cyber.TauDEM)
		tool.identifier = name
		description = OWLUtils.join_list(d['description'])
		keywords = OWLUtils.to_keywords(description)
		keywords.extend(name.replace('_', ' ').split(' '))
		# keywords=name.replace('_', ' ').split(' ')
		OWLUtils.link_to_domain_concept(tool, keywords)

		for k, v in d.items():
			# 外层, 参数
			if (k in ['parameters', 'options']) and type(v) == list:
				for i, item in enumerate(v):
					param = None
					# localname = v[i]['parameterName']
					localname = Preprocessor.space_2_underline(item['parameterName'])
					_label = localname.replace('_', ' ')
					if item['isInputFile']:
						param = TauDEMInput(localname, prefLabel=locstr(_label, lang='en'))
						# param = TauDEMInput(prefLabel=locstr(_label, lang='en'))
						# input geo data ? rule: format-> geoformat->geo data
						tool.input.append(param)
						handle_params(param, item)
						param.isInput = True
					elif item['isOutputFile']:  # localname.lower().startswith('output_', 0, len('output_')):
						param = TauDEMOutput(localname, prefLabel=locstr(_label, lang='en'))
						# param = TauDEMOutput(prefLabel=locstr(_label, lang='en'))
						tool.output.append(param)
						handle_params(param, item)
						param.isOutput = True
					else:
						param = TauDEMOption(localname, prefLabel=locstr(_label, lang='en'))
						# param = TauDEMOption(prefLabel=locstr(localname.replace('_', ' '), lang='en'))
						tool.option.append(param)
						handle_params(param, item)
					OWLUtils.link_to_domain_concept(param, _label)
					param.identifier = localname
			else:
				prop = get_property(k, DataProperty)
				if not v:
					continue
				if type(v) == list and len(v) > 0:
					v = ''.join(v)
				OWLUtils.set_data_property(tool, prop, v)
		# task
		handle_task(tool, name, d['name'], description)
		OWLUtils.application_category(tool, 'Geomorphometry', 'digital terrain analysis', 'hydrology')
Пример #2
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)
Пример #3
0
def map_to_owl(json_data):
	for d in json_data:
		name = d['name']
		toolClass = tool_class(name)
		name = Preprocessor.space_2_underline(name)
		tool = toolClass(name, prefLabel=locstr(name, lang='en'))
		tool.isToolOfSoftware.append(cyber.GDAL)
		tool.identifier = name
		tool.definition = d['summary']
		tool.manualPageURL.append(d['manual_url'])
		tool.executable = d['exec']
		tool.commandLine.append(d['syntax'])
		tool.description.append(locstr(d['description'], lang='en'))
		OWLUtils.application_category(tool, [], ['GIS Analysis'], [str(toolClass.name).replace('Programs', '')])
		keywords = OWLUtils.to_keywords(d['description'])
		OWLUtils.link_to_domain_concept(tool, keywords)
		for example in d['example']:
			tool.example.append(example)
		handle_task(tool, d['name'], d['description'])
		for parameter in d['parameters']:
			handle_parameter(tool, parameter)
		for option in d['options']:
			handle_options(tool, option, onto)