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

feat(schema): support maintenance of simplified DSL #335

Merged
merged 34 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bbcfa53
feat(schema): fix schema preload bug
matthewhyx Mar 22, 2024
40a3f78
Merge remote-tracking branch 'upstream/master'
matthewhyx Mar 22, 2024
ad20765
Merge branch 'master' of github.com:OpenSPG/openspg
matthewhyx Apr 28, 2024
04d80f2
feat(schema): support defining reasoning rule
matthewhyx May 9, 2024
82589f1
feat(schema): fix schema preload bug
matthewhyx May 9, 2024
1bfa7ed
feat(schema): support maintain reasoning rule
matthewhyx May 10, 2024
56ad88c
feat(schema): support maintain reasoning rule
matthewhyx May 10, 2024
c7903d2
Merge branch 'master' of github.com:OpenSPG/openspg into schema_concl…
wangsff May 11, 2024
b754d10
fix(schema): fix check dsl syntax
wangsff May 11, 2024
467c516
feat(schema): support maintain reasoning rule
matthewhyx May 11, 2024
596ee97
feat(schema): support maintain reasoning rule
matthewhyx May 13, 2024
16362b3
fix(reasoner): fix findAllTypesAllowIsolateVertex (#249)
ChengyaoWen May 16, 2024
85c0187
feat(reasoner): support trace execution info (#237)
royzhao May 21, 2024
f942360
feat(reasoner): support spo inference (#280)
fishjoy Jun 12, 2024
408b6e0
feat(reasoner): upgrade thinker dsl (#314)
wangsff Jul 1, 2024
097b127
fix(reasoner): fix bugs for concept expand & add runtime trace data (…
royzhao Jul 1, 2024
b56df31
fix(reasoner): fix bugs in cast_type (#276)
ChengyaoWen Jul 1, 2024
a2d3fc0
fix(reasoner): fix bugs for edge limit (#301)
royzhao Jul 1, 2024
f71ee6a
fix(reasoner): fix udf json_get (#317)
ChengyaoWen Jul 9, 2024
e1d814c
fix(reasoner): fix unit test in hypertension (#321)
fishjoy Jul 12, 2024
329814b
feat(schema): support maintain reasoning rule
matthewhyx Jul 12, 2024
cde6995
fix(reasoner): fix findAllTypesAllowIsolateVertex (#249)
ChengyaoWen May 16, 2024
a25ce5e
feat(reasoner): support trace execution info (#237)
royzhao May 21, 2024
bfa462f
feat(reasoner): support spo inference (#280)
fishjoy Jun 12, 2024
67a0f5c
feat(reasoner): upgrade thinker dsl (#314)
wangsff Jul 1, 2024
e8a7a1d
fix(reasoner): fix bugs for concept expand & add runtime trace data (…
royzhao Jul 1, 2024
25970d4
fix(reasoner): fix bugs in cast_type (#276)
ChengyaoWen Jul 1, 2024
1d3abb0
fix(reasoner): fix bugs for edge limit (#301)
royzhao Jul 1, 2024
87cbe1e
fix(reasoner): fix udf json_get (#317)
ChengyaoWen Jul 9, 2024
25a4c2f
fix(reasoner): fix unit test in hypertension (#321)
fishjoy Jul 12, 2024
c405390
Merge branch 'schema_conclude_rule' of github.com:OpenSPG/openspg int…
matthewhyx Aug 5, 2024
296ea89
resolve conflict
matthewhyx Aug 5, 2024
8f6e434
format
fishjoy Aug 8, 2024
9680a63
Merge branch 'refs/heads/master' into schema_conclude_rule
fishjoy Aug 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.antgroup.openspg.builder.model.record.BaseRecord;
import com.antgroup.openspg.builder.model.record.BaseSPGRecord;
import com.antgroup.openspg.core.schema.model.semantic.DynamicTaxonomySemantic;
import com.antgroup.openspg.core.schema.model.semantic.LogicalCausationSemantic;
import com.antgroup.openspg.core.schema.model.semantic.TripleSemantic;
import com.antgroup.openspg.core.schema.model.type.ConceptList;
import com.antgroup.openspg.reasoner.catalog.impl.OpenSPGCatalog;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertexId;
Expand Down Expand Up @@ -106,7 +106,7 @@ private List<BaseSPGRecord> reasoning(BaseAdvancedRecord record, ConceptList con
}

// then run causal reasoning logic
for (LogicalCausationSemantic leadTo : conceptList.getLogicalCausation()) {
for (TripleSemantic leadTo : conceptList.getLogicalCausation()) {
spgRecords = causalConceptReasoner.reason(spgRecords, leadTo);
}
return spgRecords;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import com.antgroup.openspg.builder.model.record.property.SPGPropertyRecord;
import com.antgroup.openspg.builder.model.record.property.SPGPropertyValue;
import com.antgroup.openspg.core.schema.model.semantic.DynamicTaxonomySemantic;
import com.antgroup.openspg.core.schema.model.semantic.LogicalCausationSemantic;
import com.antgroup.openspg.core.schema.model.semantic.SystemPredicateEnum;
import com.antgroup.openspg.core.schema.model.semantic.TripleSemantic;
import com.antgroup.openspg.core.schema.model.type.ConceptList;
import com.antgroup.openspg.reasoner.common.graph.vertex.IVertexId;
import com.antgroup.openspg.reasoner.graphstate.GraphState;
Expand All @@ -37,25 +37,22 @@
import org.apache.commons.collections4.CollectionUtils;
import scala.Tuple2;

public class CausalConceptReasoner implements ConceptReasoner<LogicalCausationSemantic> {
public class CausalConceptReasoner implements ConceptReasoner<TripleSemantic> {

@Setter private InductiveConceptReasoner inductiveConceptReasoner;
@Setter private BuilderCatalog builderCatalog;
@Setter private Catalog catalog;
@Setter private GraphState<IVertexId> graphState;

@Override
public List<BaseSPGRecord> reason(
List<BaseSPGRecord> records, LogicalCausationSemantic conceptSemantic) {
public List<BaseSPGRecord> reason(List<BaseSPGRecord> records, TripleSemantic conceptSemantic) {
List<BaseSPGRecord> results = new ArrayList<>(records);
propagate(records, conceptSemantic, results);
return results;
}

private void propagate(
List<BaseSPGRecord> spgRecords,
LogicalCausationSemantic conceptSemantic,
List<BaseSPGRecord> results) {
List<BaseSPGRecord> spgRecords, TripleSemantic conceptSemantic, List<BaseSPGRecord> results) {
List<BaseAdvancedRecord> toPropagated = new ArrayList<>();
for (BaseSPGRecord spgRecord : spgRecords) {
if (!(spgRecord instanceof BaseAdvancedRecord)) {
Expand Down Expand Up @@ -102,15 +99,15 @@ private void propagate(
nextSpgRecords = inductiveConceptReasoner.reason(nextSpgRecords, belongTo);
}

for (LogicalCausationSemantic nextLeadTo :
for (TripleSemantic nextLeadTo :
conceptList.getLogicalCausation(conceptSemantic.getObjectIdentifier())) {
propagate(nextSpgRecords, nextLeadTo, results);
}
}
}
}

private List<BaseSPGRecord> leadTo(BaseAdvancedRecord record, LogicalCausationSemantic leadTo) {
private List<BaseSPGRecord> leadTo(BaseAdvancedRecord record, TripleSemantic leadTo) {
LocalReasonerTask reasonerTask = new LocalReasonerTask();

reasonerTask.setCatalog(catalog);
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
<artifactId>reasoner-local-runner</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.reasoner</groupId>
<artifactId>reasoner-thinker</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.antgroup.openspg.reasoner</groupId>
<artifactId>reasoner-cloudext-warehouse</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
class SupplyChain:
class Company(SPGTypeHelper):
class fundTrans(RelationHelper):
transAmt = PropertyHelper("transAmt")
transDate = PropertyHelper("transDate")
transAmt = PropertyHelper("transAmt")

cashflowDiff6Month = PropertyHelper("cashflowDiff6Month")
name = PropertyHelper("name")
fundTrans3MonthIn = PropertyHelper("fundTrans3MonthIn")
cashflowDiff3Month = PropertyHelper("cashflowDiff3Month")
cashflowDiff1Month = PropertyHelper("cashflowDiff1Month")
description = PropertyHelper("description")
fundTrans1MonthIn = PropertyHelper("fundTrans1MonthIn")
totalTransInAmt = PropertyHelper("totalTransInAmt")
fundTrans1Month = PropertyHelper("fundTrans1Month")
id = PropertyHelper("id")
fundTrans6MonthIn = PropertyHelper("fundTrans6MonthIn")
description = PropertyHelper("description")
name = PropertyHelper("name")
fundTrans6Month = PropertyHelper("fundTrans6Month")
totalTransInAmt = PropertyHelper("totalTransInAmt")
fundTrans1MonthIn = PropertyHelper("fundTrans1MonthIn")
cashflowDiff6Month = PropertyHelper("cashflowDiff6Month")
product = PropertyHelper("product")
fundTrans3Month = PropertyHelper("fundTrans3Month")
cashflowDiff3Month = PropertyHelper("cashflowDiff3Month")
fundTrans3MonthIn = PropertyHelper("fundTrans3MonthIn")
fundTrans6MonthIn = PropertyHelper("fundTrans6MonthIn")

mainSupply = RelationHelper("mainSupply")
belongToIndustry = RelationHelper("belongToIndustry")
Expand All @@ -52,95 +52,95 @@ class fundTrans(RelationHelper):
class CompanyEvent(SPGTypeHelper):

leadTo = PropertyHelper("leadTo")
name = PropertyHelper("name")
eventTime = PropertyHelper("eventTime")
description = PropertyHelper("description")
subject = PropertyHelper("subject")
id = PropertyHelper("id")
trend = PropertyHelper("trend")
description = PropertyHelper("description")
name = PropertyHelper("name")
belongTo = PropertyHelper("belongTo")
trend = PropertyHelper("trend")
index = PropertyHelper("index")
subject = PropertyHelper("subject")
eventTime = PropertyHelper("eventTime")

class Index(SPGTypeHelper):

name = PropertyHelper("name")
stdId = PropertyHelper("stdId")
alias = PropertyHelper("alias")
description = PropertyHelper("description")
id = PropertyHelper("id")
description = PropertyHelper("description")
name = PropertyHelper("name")
stdId = PropertyHelper("stdId")

class Industry(SPGTypeHelper):

name = PropertyHelper("name")
stdId = PropertyHelper("stdId")
alias = PropertyHelper("alias")
description = PropertyHelper("description")
id = PropertyHelper("id")
description = PropertyHelper("description")
name = PropertyHelper("name")
stdId = PropertyHelper("stdId")

class Person(SPGTypeHelper):

certNo = PropertyHelper("certNo")
age = PropertyHelper("age")
legalRepresentative = PropertyHelper("legalRepresentative")
name = PropertyHelper("name")
description = PropertyHelper("description")
id = PropertyHelper("id")
age = PropertyHelper("age")
description = PropertyHelper("description")
name = PropertyHelper("name")

class Product(SPGTypeHelper):

name = PropertyHelper("name")
hasSupplyChain = PropertyHelper("hasSupplyChain")
description = PropertyHelper("description")
id = PropertyHelper("id")
belongToIndustry = PropertyHelper("belongToIndustry")
description = PropertyHelper("description")
name = PropertyHelper("name")
belongTo = PropertyHelper("belongTo")
belongToIndustry = PropertyHelper("belongToIndustry")
hasSupplyChain = PropertyHelper("hasSupplyChain")

class ProductChainEvent(SPGTypeHelper):

name = PropertyHelper("name")
eventTime = PropertyHelper("eventTime")
description = PropertyHelper("description")
subject = PropertyHelper("subject")
id = PropertyHelper("id")
trend = PropertyHelper("trend")
description = PropertyHelper("description")
name = PropertyHelper("name")
belongTo = PropertyHelper("belongTo")
trend = PropertyHelper("trend")
index = PropertyHelper("index")
subject = PropertyHelper("subject")
eventTime = PropertyHelper("eventTime")

leadTo = RelationHelper("leadTo")

class TaxOfCompanyEvent(SPGTypeHelper):

name = PropertyHelper("name")
stdId = PropertyHelper("stdId")
alias = PropertyHelper("alias")
description = PropertyHelper("description")
id = PropertyHelper("id")
description = PropertyHelper("description")
name = PropertyHelper("name")
stdId = PropertyHelper("stdId")

class TaxOfProdEvent(SPGTypeHelper):

name = PropertyHelper("name")
stdId = PropertyHelper("stdId")
alias = PropertyHelper("alias")
description = PropertyHelper("description")
id = PropertyHelper("id")
description = PropertyHelper("description")
name = PropertyHelper("name")
stdId = PropertyHelper("stdId")

leadTo = RelationHelper("leadTo")

class TaxOfProduct(SPGTypeHelper):

name = PropertyHelper("name")
stdId = PropertyHelper("stdId")
alias = PropertyHelper("alias")
description = PropertyHelper("description")
id = PropertyHelper("id")
description = PropertyHelper("description")
name = PropertyHelper("name")
stdId = PropertyHelper("stdId")

class Trend(SPGTypeHelper):

name = PropertyHelper("name")
stdId = PropertyHelper("stdId")
alias = PropertyHelper("alias")
description = PropertyHelper("description")
id = PropertyHelper("id")
description = PropertyHelper("description")
name = PropertyHelper("name")
stdId = PropertyHelper("stdId")

Company = Company("SupplyChain.Company")
CompanyEvent = CompanyEvent("SupplyChain.CompanyEvent")
Expand Down
Loading
Loading