Fixed bug in feature

This commit is contained in:
Panupong Pasupat 2017-08-31 03:41:19 -07:00
parent 212e28fc77
commit 3e7c052621
3 changed files with 14 additions and 6 deletions

View File

@ -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();
}

View File

@ -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)) {

View File

@ -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");