Spaces:
Running
Running
File size: 829 Bytes
09321b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from modelscope.utils.constant import Tasks
from .pipeline_tool import ModelscopePipelineTool
class TextAddressTool(ModelscopePipelineTool):
default_model = 'damo/mgeo_geographic_elements_tagging_chinese_base'
description = '地址解析服务,针对中文地址信息,识别出里面的元素,包括省、市、区、镇、社区、道路、路号、POI、楼栋号、户室号等'
name = 'modelscope_text-address'
parameters: list = [{
'name': 'input',
'description': '用户输入的地址信息',
'required': True
}]
task = Tasks.token_classification
def _parse_output(self, origin_result, *args, **kwargs):
final_result = {}
for e in origin_result['output']:
final_result[e['type']] = e['span']
return {'result': final_result}
|