This commit is contained in:
baifuyu 2023-12-25 11:02:05 +08:00
parent 84a2266e52
commit 22d9cac97a
23 changed files with 38 additions and 38 deletions

View File

@ -26,7 +26,7 @@ public class PythonRecordConvertor {
}
BaseAdvancedRecord advancedRecord =
VertexRecordConvertor.toAdvancedRecord(spgType, recordId, pythonRecord.getProperties());
recordLinking.propertyLinking(advancedRecord);
recordLinking.linking(advancedRecord);
return advancedRecord;
}

View File

@ -59,7 +59,7 @@ public class RelationMappingProcessor extends BaseMappingProcessor<RelationMappi
BuilderRecord mappedRecord = mapping(record, mappingConfig.getMappingConfigs());
RelationRecord relationRecord = toSPGRecord(mappedRecord, relation);
recordLinking.propertyLinking(relationRecord);
recordLinking.linking(relationRecord);
return relationRecord;
}

View File

@ -38,7 +38,7 @@ public class SPGTypeMappingProcessor extends BaseMappingProcessor<SPGTypeMapping
private BaseSPGType spgType;
private RecordLinking recordLinking;
private RecordPredicting recordPredicating;
private RecordPredicting recordPredicting;
private SubjectFusing subjectFusing;
public SPGTypeMappingProcessor(String id, String name, SPGTypeMappingNodeConfig config) {
@ -59,8 +59,8 @@ public class SPGTypeMappingProcessor extends BaseMappingProcessor<SPGTypeMapping
this.subjectFusing = new SubjectFusingImpl(config.getSubjectFusingConfig());
this.subjectFusing.init(context);
this.recordPredicating = new RecordPredictingImpl(config.getPredictingConfigs());
this.recordPredicating.init(context);
this.recordPredicting = new RecordPredictingImpl(config.getPredictingConfigs());
this.recordPredicting.init(context);
}
@Override
@ -75,12 +75,12 @@ public class SPGTypeMappingProcessor extends BaseMappingProcessor<SPGTypeMapping
BuilderRecord mappedRecord = mapping(record, config.getMappingConfigs());
BaseAdvancedRecord advancedRecord = toSPGRecord(mappedRecord, spgType);
if (advancedRecord != null) {
recordLinking.propertyLinking(advancedRecord);
recordPredicating.propertyPredicating(advancedRecord);
recordLinking.linking(advancedRecord);
recordPredicting.predicting(advancedRecord);
advancedRecords.add(advancedRecord);
}
}
return (List) subjectFusing.subjectFusing(advancedRecords);
return (List) subjectFusing.fusing(advancedRecords);
}
@Override

View File

@ -69,12 +69,12 @@ public class SubGraphMappingProcessor extends BaseMappingProcessor<SubGraphMappi
BaseAdvancedRecord advancedRecord = toSPGRecord(mappedRecord, spgType);
if (advancedRecord != null) {
List<BaseAdvancedRecord> fusedRecords = subGraphFusing.subGraphFusing(advancedRecord);
fusedRecords.forEach(r -> recordLinking.propertyLinking(r));
recordPredicating.propertyPredicating(advancedRecord);
fusedRecords.forEach(r -> recordLinking.linking(r));
recordPredicating.predicting(advancedRecord);
advancedRecords.addAll(fusedRecords);
}
}
return (List) subjectFusing.subjectFusing(advancedRecords);
return (List) subjectFusing.fusing(advancedRecords);
}
@Override

View File

@ -82,7 +82,7 @@ public class ReasonProcessor extends BaseProcessor<ReasonProcessor.ReasonerNodeC
}
for (BaseRecord baseRecord : results) {
recordNormalizer.propertyLinking((BaseSPGRecord) baseRecord);
recordNormalizer.linking((BaseSPGRecord) baseRecord);
}
return results;
}

View File

@ -12,5 +12,5 @@ public interface EntityFusing {
void init(BuilderContext context) throws BuilderException;
/** Input a list of SPG records, fuse and return the final result. */
List<BaseAdvancedRecord> entityFusing(List<BaseAdvancedRecord> records) throws FusingException;
List<BaseAdvancedRecord> fusing(List<BaseAdvancedRecord> records) throws FusingException;
}

View File

@ -58,8 +58,8 @@ public class SubGraphFusingImpl implements SubGraphFusing {
continue;
}
List<BaseAdvancedRecord> advancedRecords = toAdvancedRecords(propertyRecord);
advancedRecords.forEach(recordLinking::propertyLinking);
List<BaseAdvancedRecord> fusedRecords = entityFusing.entityFusing(advancedRecords);
advancedRecords.forEach(recordLinking::linking);
List<BaseAdvancedRecord> fusedRecords = entityFusing.fusing(advancedRecords);
modifyPropertyRecord(propertyRecord, fusedRecords);
results.addAll(fusedRecords);
}

View File

@ -10,6 +10,6 @@ public interface SubjectFusing {
void init(BuilderContext context) throws BuilderException;
List<BaseAdvancedRecord> subjectFusing(List<BaseAdvancedRecord> advancedRecords)
List<BaseAdvancedRecord> fusing(List<BaseAdvancedRecord> advancedRecords)
throws FusingException;
}

View File

@ -21,8 +21,8 @@ public class SubjectFusingImpl implements SubjectFusing {
}
@Override
public List<BaseAdvancedRecord> subjectFusing(List<BaseAdvancedRecord> advancedRecords)
public List<BaseAdvancedRecord> fusing(List<BaseAdvancedRecord> advancedRecords)
throws FusingException {
return entityFusing.entityFusing(advancedRecords);
return entityFusing.fusing(advancedRecords);
}
}

View File

@ -17,7 +17,7 @@ public class NewInstanceFusing implements EntityFusing {
public void init(BuilderContext context) throws BuilderException {}
@Override
public List<BaseAdvancedRecord> entityFusing(List<BaseAdvancedRecord> records)
public List<BaseAdvancedRecord> fusing(List<BaseAdvancedRecord> records)
throws FusingException {
return records;
}

View File

@ -49,7 +49,7 @@ public class OperatorFusing implements EntityFusing {
}
@Override
public List<BaseAdvancedRecord> entityFusing(List<BaseAdvancedRecord> records)
public List<BaseAdvancedRecord> fusing(List<BaseAdvancedRecord> records)
throws FusingException {
List<Map<String, Object>> pythonRecords =
CollectionsUtils.listMap(records, r -> PythonRecordConvertor.toPythonRecord(r).toMap());

View File

@ -11,5 +11,5 @@ public interface PropertyLinking {
void init(BuilderContext context) throws BuilderException;
/** Input an SPG property record and link the property value. */
void propertyLinking(BasePropertyRecord record) throws LinkingException;
void linking(BasePropertyRecord record) throws LinkingException;
}

View File

@ -9,7 +9,7 @@ public interface RecordLinking {
void init(BuilderContext context) throws BuilderException;
void propertyLinking(BaseSPGRecord spgRecord) throws LinkingException;
void linking(BaseSPGRecord spgRecord) throws LinkingException;
void setDefaultPropertyLinking(PropertyLinking defaultPropertyLinking);
}

View File

@ -53,20 +53,20 @@ public class RecordLinkingImpl implements RecordLinking {
}
@Override
public void propertyLinking(BaseSPGRecord spgRecord) throws LinkingException {
public void linking(BaseSPGRecord spgRecord) throws LinkingException {
for (BasePropertyRecord propertyRecord : spgRecord.getProperties()) {
if (propertyRecord.isSemanticProperty()) {
PropertyLinking propertyLinking = semanticPropertyLinking.get(propertyRecord.getName());
if (propertyLinking != null) {
// we use user-defined normalizer to normalize property value
propertyLinking.propertyLinking(propertyRecord);
propertyLinking.linking(propertyRecord);
} else {
// we use default normalizer to normalize property value
defaultPropertyLinking.propertyLinking(propertyRecord);
defaultPropertyLinking.linking(propertyRecord);
}
} else {
// we use basic normalizer to normalize property value
basicPropertyLinking.propertyLinking(propertyRecord);
basicPropertyLinking.linking(propertyRecord);
}
}
}

View File

@ -13,7 +13,7 @@ public class BasicPropertyLinking implements PropertyLinking {
public void init(BuilderContext context) throws BuilderException {}
@Override
public void propertyLinking(BasePropertyRecord record) throws LinkingException {
public void linking(BasePropertyRecord record) throws LinkingException {
SPGTypeRef objectTypeRef = record.getObjectTypeRef();
if (!objectTypeRef.isBasicType()) {
throw new IllegalStateException();

View File

@ -18,7 +18,7 @@ public class IdEqualsLinking implements PropertyLinking {
public void init(BuilderContext context) throws BuilderException {}
@Override
public void propertyLinking(BasePropertyRecord record) throws LinkingException {
public void linking(BasePropertyRecord record) throws LinkingException {
SPGTypeRef objectTypeRef = record.getObjectTypeRef();
if (!objectTypeRef.isAdvancedType()) {
throw new IllegalStateException();

View File

@ -37,7 +37,7 @@ public class OperatorLinking implements PropertyLinking {
}
@Override
public void propertyLinking(BasePropertyRecord record) throws LinkingException {
public void linking(BasePropertyRecord record) throws LinkingException {
List<String> rawValues = record.getRawValues();
List<String> ids = new ArrayList<>(rawValues.size());

View File

@ -29,7 +29,7 @@ public class SearchBasedLinking implements PropertyLinking {
}
@Override
public void propertyLinking(BasePropertyRecord record) throws LinkingException {
public void linking(BasePropertyRecord record) throws LinkingException {
SPGTypeRef objectTypeRef = record.getObjectTypeRef();
List<String> rawValues = record.getRawValues();

View File

@ -12,5 +12,5 @@ public interface PropertyPredicting {
void init(BuilderContext context) throws BuilderException;
/** Input an SPG property record and predict the property value. */
List<BaseAdvancedRecord> propertyPredicting(BaseAdvancedRecord record) throws PredictingException;
List<BaseAdvancedRecord> predicting(BaseAdvancedRecord record) throws PredictingException;
}

View File

@ -9,5 +9,5 @@ public interface RecordPredicting {
void init(BuilderContext context) throws BuilderException;
void propertyPredicating(BaseAdvancedRecord advancedRecord) throws PredictingException;
void predicting(BaseAdvancedRecord advancedRecord) throws PredictingException;
}

View File

@ -39,7 +39,7 @@ public class RecordPredictingImpl implements RecordPredicting {
}
@Override
public void propertyPredicating(BaseAdvancedRecord advancedRecord) throws PredictingException {
public void predicting(BaseAdvancedRecord advancedRecord) throws PredictingException {
Map<String, Property> propertyMap = advancedRecord.getSpgType().getPropertyMap();
for (Map.Entry<String, PropertyPredicting> entry : semanticPropertyPredicating.entrySet()) {
String propertyKey = entry.getKey();
@ -50,7 +50,7 @@ public class RecordPredictingImpl implements RecordPredicting {
continue;
}
List<BaseAdvancedRecord> predictedRecords = predicting.propertyPredicting(advancedRecord);
List<BaseAdvancedRecord> predictedRecords = predicting.predicting(advancedRecord);
if (CollectionUtils.isEmpty(predictedRecords)) {
continue;
}

View File

@ -50,7 +50,7 @@ public class OperatorPredicting implements PropertyPredicting {
}
@Override
public List<BaseAdvancedRecord> propertyPredicting(BaseAdvancedRecord record)
public List<BaseAdvancedRecord> predicting(BaseAdvancedRecord record)
throws PredictingException {
Map<String, Object> pythonRecord = PythonRecordConvertor.toPythonRecord(record).toMap();
InvokeResultWrapper<List<PythonRecord>> invokeResultWrapper = null;

View File

@ -18,7 +18,7 @@ class BasicPropertyNormalizerTest extends Specification {
def propertyRecord = new SPGPropertyRecord(property, new SPGPropertyValue(rawValue))
expect:
normalizer.propertyLinking(propertyRecord)
normalizer.linking(propertyRecord)
propertyRecord.getValue().getStds() == expectValues
where:
@ -33,7 +33,7 @@ class BasicPropertyNormalizerTest extends Specification {
def propertyRecord = new SPGPropertyRecord(property, new SPGPropertyValue(rawValue))
when:
normalizer.propertyLinking(propertyRecord)
normalizer.linking(propertyRecord)
propertyRecord.getValue().getStds()
then:
@ -50,7 +50,7 @@ class BasicPropertyNormalizerTest extends Specification {
def subPropertyRecord = new SPGSubPropertyRecord(subProperty, new SPGPropertyValue(rawValue))
expect:
normalizer.propertyLinking(subPropertyRecord)
normalizer.linking(subPropertyRecord)
subPropertyRecord.getValue().getStds() == expectValues
where: