Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalRunner的疑问 #422

Open
ganhb opened this issue Dec 16, 2024 · 0 comments
Open

LocalRunner的疑问 #422

ganhb opened this issue Dec 16, 2024 · 0 comments
Assignees

Comments

@ganhb
Copy link

ganhb commented Dec 16, 2024

你们好:
我在看LocalRunnerTest的testCreateConceptInstance 有几个问题,望解答。

问题一

我尝试把代码定义的整理成schema文件,内容如下:

namespace Test

TaxOfUserFeature(用户角色分类):EntityType

UserFeature(用户角色):EntityType
	properties:
		newedge(某种边):TaxOfUserFeature

User(用户):EntityType
	properties:
		nightTrader(某个标识):Text
		belongTo(属于): UserFeature
	relations:
		belongTo(白领):UserFeature
			rule:[[
			    Define (s:Test.User)-[p:belongTo]->(o:`Test.UserFeature`/`白领`) {
			    GraphStructure {
			        (s)
			    }
			    Rule {
			        r1("属于教师") = s.nightTrader == 1
			        r2("属于程序员") = s.nightTrader == 2
			        r3("属于医生") = s.nightTrader == 3
			        s_r1 = rule_value(r1, "教师", "")
			        s_r2 = rule_value(r2, "程序员", s_r1)
			        s_r3 = rule_value(r3, "医生", s_r2)
			        R: s_r3 != ""
			    }
			    Action {
			        sub_concept = createNodeInstance(
			            type=Test.UserFeature,
			            value={
			                id=concat("白领-", s_r3)
			            }
			        )
			        createEdgeInstance(
			            src=s,
			            dst=sub_concept,
			            type=belongTo,
			            value={
			                __to_id_type__='Test.UserFeature'
			                __from_id_type__='Test.User'
			            }
			        )
			    }
			}
			]]
		belongTo(学生):UserFeature
			rule:[[
			    Define (s:Test.User)-[p:belongTo]->(o:`Test.UserFeature`/`学生`) {
			    GraphStructure {
			        (s)
			    }
			    Rule {
			        r1("就读幼儿园") = s.nightTrader == 1
			        r2("就读小学") = s.nightTrader == 2
			        r3("就读中学") = s.nightTrader == 3
			        s_r1 = rule_value(r1, "就读幼儿园", "")
			        s_r2 = rule_value(r2, "就读小学", s_r1)
			        s_r3 = rule_value(r3, "就读中学", s_r2)
			        R: s_r3 != ""
			    }
			    Action {
			        sub_concept = createNodeInstance(
			            type=Test.UserFeature,
			            value={
			                id=concat("学生-", s_r3)
			            }
			        )
			        createEdgeInstance(
			            src=s,
			            dst=sub_concept,
			            type=belongTo,
			            value={
			                __to_id_type__='Test.UserFeature'
			                __from_id_type__='Test.User'
			            }
			        )
			    }
			}
			]]	

其中LocalRunnerTest的testCreateConceptInstance 对于

    schema.put(
        "Test.User_belongTo_Test.UserFeature",
        Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet()));

  xxx.addEdge(
            "Test.User",
            "belongTo",
            "Test.UserFeature/白领",
            Direction.OUT,
            Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet())

xxx.addEdge(
            "Test.User",
            "belongTo",
            "Test.UserFeature/学生",
            Direction.OUT,
            Convert2ScalaUtil.toScalaImmutableSet(Sets.newHashSet())

我分别给它映射成(感觉有问题)

	properties:
		belongTo(属于): UserFeature
	relations:
		belongTo(白领):UserFeature
	        belongTo(学生):UserFeature

我看完文档声明式Schema,我感觉不对,希望指导下正确格式应该是什么?

问题二

在实例mock数据中TestFanxiqianGraphLoader

constructionVertex(
      String bizId, String type, Object... kvs) {

type是否是实例和概念的联系,上述例子相当于
id:张三 instanceOf Test:User

问题三

在进行规则推理时候,能否可以在没有实例图的情况下(仅有概念图)进行的推理?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants