Example #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')
Example #2
0
def handle_task(tool, task_name, des):
	config = OWLUtils.get_config(module_path + '/config.ini')
	category = tool_class(task_name)
	task_cls = config.get('task', category.name)
	task_name = Preprocessor.space_2_underline(task_name.replace(".py", ""))
	if not task[task_name + "_task"]:
		task_ins = task[task_cls](task_name + "_task", prefLabel=locstr(task_name + " task", lang='en'))
		task_ins.isAtomicTask = True
		task_ins.identifier = task_name
	else:
		task_ins = task[task_name + "_task"]
	if (task_ins in tool.usedByTask) is False:
		tool.usedByTask.append(task_ins)
	if (tool in tool.processingTool) is False:
		task_ins.processingTool.append(tool)
	task_ins.description.append(locstr(des, lang='en'))
Example #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)