diff --git a/src/edu/stanford/nlp/sempre/cprune/CPruneFloatingParser.java b/src/edu/stanford/nlp/sempre/cprune/CPruneFloatingParser.java index 107615f..5535dcc 100644 --- a/src/edu/stanford/nlp/sempre/cprune/CPruneFloatingParser.java +++ b/src/edu/stanford/nlp/sempre/cprune/CPruneFloatingParser.java @@ -106,7 +106,7 @@ class MiniGrammar extends Grammar { public MiniGrammar(List 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(); } diff --git a/src/edu/stanford/nlp/sempre/tables/TableKnowledgeGraph.java b/src/edu/stanford/nlp/sempre/tables/TableKnowledgeGraph.java index eca3bc3..9300eb3 100644 --- a/src/edu/stanford/nlp/sempre/tables/TableKnowledgeGraph.java +++ b/src/edu/stanford/nlp/sempre/tables/TableKnowledgeGraph.java @@ -65,6 +65,8 @@ public class TableKnowledgeGraph extends KnowledgeGraph implements FuzzyMatchabl Map relationIdToTableColumn; // "fb:cell.palo_alto_ca" --> TableCellProperties object Map cellIdToTableCellProperties; + // "fb:part.palo_alto" --> String + Map 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)) { diff --git a/src/edu/stanford/nlp/sempre/tables/features/AnchorFeatureComputer.java b/src/edu/stanford/nlp/sempre/tables/features/AnchorFeatureComputer.java index a3dd20c..f0a44e9 100644 --- a/src/edu/stanford/nlp/sempre/tables/features/AnchorFeatureComputer.java +++ b/src/edu/stanford/nlp/sempre/tables/features/AnchorFeatureComputer.java @@ -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");