0

我正在尝试为 WKS 实例上传一组自定义实体类型和子类型。

这是您可以定义实体和子实体的部分中的 WKS 界面视图。

这是您可以定义实体和子实体的部分中的 WKS 界面视图

上传按钮请求一个 json 文件。

我之前手动创建了一个集合,并下载了 json 文件。

它的第一行如下:

{"entityTypes":[{**"id":"78361798-b77e-4728-9b6a-f56539c12bcd"**,"label":"Calificativo","sireProp":{"mentionType":null,"subtypes":["Bueno_extremo","Bueno_moderado","Regular","Malo_moderado","Malo_extremo"],"roles":["78361798-b77e-4728-9b6a-f56539c12bcd"],"clazz":null,"color":null,"hotkey":null,"backGroundColor":null,"active":true,"roleOnly":false},"creationDate":1583241330349,"source":null,"modifiedDate":0,"typeType":null,"typeClass":null,"typeVersion":null,"typeDesc":null,"typeSuperType":null,"typeSuperTypeId":null,"typeCreateDate":null,"typeUpdateDate":null,"typeProvenance":null,"alchemyAPITypes":null,"nluAPITypes":null},{**"id":"daecb92b-0ce7-4a47-942a-68b50d0cb2fd"**,"label":"TV","sireProp":{"mentionType":null,"subtypes":["Decodificador","Servicio_de_tv"],"roles":

一般来说,内容结构是清晰的,但实体集和内容都有 ID。

不知道有没有办法提前知道,或者生成这些id,这样我就可以生成整个json,里面有我要使用的类型和子类型,然后上传。

我尝试使用“”代替 ID,但收到错误消息并且不允许上传。

4

2 回答 2

1

WKS 不支持根据文档导入与从 WKS 工作区导出的不同的自定义 json 文件。但是,据我尝试,UUID 可能是一个有效的id字段值,由以下 bash 命令生成。

$ uuidgen | tr '[:upper:]' '[:lower:]'
于 2020-03-31T01:33:36.533 回答
0

此 Python 脚本生成一个 json 文件,其格式为 WKS 可理解:

import uuid
import json

# Generate IDs
ent_id,lbl01_id = uuid.uuid4(), uuid.uuid4()

json_out = {}
json_out.update({
                "entityTypes":[{
                    "id":str(lbl01_id), "label":"Calificativo",
                    "sireProp":
                        {
                        "mentionType":None,
                        "subtypes":["Bueno_extremo", "Bueno_moderado", "Regular", "Malo_moderado", "Malo_extremo"],
                        "roles":[str(lbl01_id)], "clazz":None, # Roles relates to self & other labels, if any
                        "color":None, "hotkey":None, "backGroundColor":None, "active":True, "roleOnly":False
                        },
                    "creationDate":1583241330349, "source":None, "modifiedDate":1583247016579, "typeType":None,
                    "typeClass":None, "typeVersion":None, "typeDesc":None, "typeSuperType":None, "typeSuperTypeId":None,
                    "typeCreateDate":None, "typeUpdateDate":None, "typeProvenance":None, "alchemyAPITypes":None,
                    "nluAPITypes":None
                    }],
                "sireInfo":{
                    "entityProp":{
                        "mentionType":[{"color":"white", "hotkey":"1", "backGroundColor":"#AA00FF", "name":"NAM"},
                                       {"color":"black", "hotkey":"2", "backGroundColor":"#00FF7F", "name":"NOM"},
                                       {"color":"black", "hotkey":"3", "backGroundColor":"#AAFFFF", "name":"PRO"},
                                       {"color":"white", "hotkey":"4", "backGroundColor":"gray", "name":"NONE"}],
                        "subtypes":None,
                        "roles":None,
                        "clazz":[{"color":"#A5A5A5", "hotkey":"3", "backGroundColor":"white", "name":"SPC"},
                                 {"color":"black", "hotkey":"2", "backGroundColor":"#00FF7F", "name":"NEG"},
                                 {"color":"black", "hotkey":"1", "backGroundColor":"#AAFFFF", "name":"GEN"}],
                        "color":None,
                        "hotkey":None,
                        "backGroundColor":None,
                        "active":True,
                        "roleOnly":False
                        },
                    "relationProp":{
                        "tense":[{"name":"PAST"}, {"name":"PRESENT"}, {"name":"FUTURE"}, {"name":"UNSPECIFIED"}],
                        "modality":[{"name":"ASSERTED"}, {"name":"OTHER"}],
                        "clazz":[{"name":"SPECIFIC"}, {"name":"NEG"}, {"name":"OTHER"}],
                        "backGroundColor":None, "color":None, "hotkey":None, "active":True}
                    },
                "functionalEntityTypes":[
                    {"id":"CATCH_ALL_ENTITY_ID", "label":"*",
                    "sireProp":{
                        "mentionType":None, "subtypes":None, "roles":None, "clazz":None, "color":None,
                        "hotkey":None, "backGroundColor":None, "active":True, "roleOnly":False},
                    "creationDate":1487227572757, "source":None, "modifiedDate":0, "typeType":None,
                    "typeClass":None, "typeVersion":None, "typeDesc":None, "typeSuperType":None,
                    "typeSuperTypeId":None, "typeCreateDate":None, "typeUpdateDate":None, "typeProvenance":None,
                    "alchemyAPITypes":None, "nluAPITypes":None
                    }],
                "pid":str(ent_id), "modified_date":1583247016579, "kgimported":False
                })

with open('json_file.json', 'w') as outfile:
    json.dump(json_out, outfile)

这只会生成 1 个实体;要生成更多,就在“id”和“nluAPITypes”之间,与要添加的实体一样多。

这里也可以包含“relationshipTypes”

于 2020-04-01T12:29:28.550 回答