Skip to content

Commit

Permalink
bugfix: the same entity in different spo rules has different alias
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsff committed Sep 11, 2024
1 parent f981abc commit 58f9584
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,25 @@ class ThinkerRuleParser extends RuleExprParser {
resultNode
}

private def isDefaultAlias(alias: String): Boolean = {
if (StringUtils.isNotEmpty(alias) && alias.toLowerCase().startsWith("anonymous")) {
return true
}
false
}

def get_concept_full_form(
concept_name: Concept_nameContext,
conceptAlias: String = ""): TriplePattern = {
val conceptEntity: Entity = constructConceptEntity(concept_name)
val entity_str = concept_name.getText
if (spoRuleToSpoSetMap.contains(entity_str)) {
val (s, p, o) = spoRuleToSpoSetMap(entity_str)
if (StringUtils.isNotBlank(conceptAlias)) {
if (!isDefaultAlias(conceptAlias) && !isDefaultAlias(conceptAlias)) {
throw new IllegalArgumentException(
"The same entity %s has different alias".format(entity_str))
}
if (!isDefaultAlias(conceptAlias)) {
o.asInstanceOf[Entity].setAlias(conceptAlias)
}
return new TriplePattern(new logic.graph.Triple(s, p, o))
Expand Down

0 comments on commit 58f9584

Please sign in to comment.