mirror of https://github.com/percyliang/sempre
Fixed bug in feature
This commit is contained in:
parent
212e28fc77
commit
3e7c052621
|
|
@ -106,7 +106,7 @@ class MiniGrammar extends Grammar {
|
|||
public MiniGrammar(List<Rule> rules) {
|
||||
this.rules.addAll(rules);
|
||||
LogInfo.begin_track("MiniGrammar Rules");
|
||||
for (Rule rule : rules) LogInfo.logs("%s", rule);
|
||||
for (Rule rule : rules) LogInfo.logs("%s %s", rule, rule.isAnchored() ? "[A]" : "[F]");
|
||||
LogInfo.end_track();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ public class TableKnowledgeGraph extends KnowledgeGraph implements FuzzyMatchabl
|
|||
Map<String, TableColumn> relationIdToTableColumn;
|
||||
// "fb:cell.palo_alto_ca" --> TableCellProperties object
|
||||
Map<String, TableCellProperties> cellIdToTableCellProperties;
|
||||
// "fb:part.palo_alto" --> String
|
||||
Map<String, String> partIdToOriginalString;
|
||||
|
||||
FuzzyMatcher fuzzyMatcher;
|
||||
public ExecutorCache executorCache;
|
||||
|
|
@ -143,9 +145,14 @@ public class TableKnowledgeGraph extends KnowledgeGraph implements FuzzyMatchabl
|
|||
// Collect cell properties for public access
|
||||
cellProperties = new HashSet<>(cellIdToTableCellProperties.values());
|
||||
cellParts = new HashSet<>();
|
||||
for (TableCellProperties properties : cellProperties)
|
||||
for (Value part : properties.metadata.get(TableTypeSystem.CELL_PART_VALUE))
|
||||
cellParts.add((NameValue) part);
|
||||
partIdToOriginalString = new HashMap<>();
|
||||
for (TableCellProperties properties : cellProperties) {
|
||||
for (Value part : properties.metadata.get(TableTypeSystem.CELL_PART_VALUE)) {
|
||||
NameValue partNameValue = (NameValue) part;
|
||||
cellParts.add(partNameValue);
|
||||
partIdToOriginalString.put(partNameValue.id, partNameValue.description);
|
||||
}
|
||||
}
|
||||
// Precompute normalized strings for fuzzy matching
|
||||
fuzzyMatcher = FuzzyMatcher.getFuzzyMatcher(this);
|
||||
executorCache = opts.individualExecutorCache ? new ExecutorCache() : null;
|
||||
|
|
@ -615,6 +622,8 @@ public class TableKnowledgeGraph extends KnowledgeGraph implements FuzzyMatchabl
|
|||
if (nameValueId.startsWith("!")) nameValueId = nameValueId.substring(1);
|
||||
if (cellIdToTableCellProperties.containsKey(nameValueId))
|
||||
return cellIdToTableCellProperties.get(nameValueId).originalString;
|
||||
if (partIdToOriginalString.containsKey(nameValueId))
|
||||
return partIdToOriginalString.get(nameValueId);
|
||||
if (relationIdToTableColumn.containsKey(nameValueId))
|
||||
return relationIdToTableColumn.get(nameValueId).originalString;
|
||||
if (nameValueId.startsWith(TableTypeSystem.CELL_SPECIFIC_TYPE_PREFIX)) {
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ public class AnchorFeatureComputer implements FeatureComputer {
|
|||
|
||||
private void extractMatchingFeatures(TableKnowledgeGraph graph,
|
||||
Derivation deriv, String phrase, NameValue predicate) {
|
||||
LogInfo.logs("%s -> %s", phrase, predicate);
|
||||
// Type of match
|
||||
String predicateString = graph.getOriginalString(predicate);
|
||||
LogInfo.logs("%s -> %s = %s", phrase, predicate, predicateString);
|
||||
predicateString = StringNormalizationUtils.simpleNormalize(predicateString).toLowerCase();
|
||||
if (predicateString.equals(phrase)) {
|
||||
deriv.addFeature("a-e", "exact");
|
||||
|
|
|
|||
Loading…
Reference in New Issue