Added a few more docstrings

This commit is contained in:
Panupong Pasupat 2017-08-31 00:06:31 -07:00
parent bc878e69e5
commit 212e28fc77
3 changed files with 15 additions and 0 deletions

View File

@ -152,6 +152,10 @@ public class CollaborativePruner {
customRules.get(patternString).addAll(parsedCustomRules);
}
/**
* Get called when a (consistent) formula is found.
* Update the consistent patterns.
*/
public static void updateConsistentPattern(ValueEvaluator evaluator, Example ex, Derivation deriv) {
String uid = ex.id;
if (ex.targetValue != null)

View File

@ -91,6 +91,9 @@ public class CustomGrammar extends Grammar {
return getIndexedSymbolicFormula(deriv, deriv.formula.toString());
}
/**
* Replace symbols (e.g., fb:row.row.name) with placeholders (e.g., Binary#1).
*/
public static String getIndexedSymbolicFormula(Derivation deriv, String formula) {
CPruneDerivInfo derivInfo = aggregateSymbols(deriv);
int index = 1;
@ -126,6 +129,9 @@ public class CustomGrammar extends Grammar {
return formula;
}
/**
* Cache the symbols in deriv.tempState[cprune].treeSymbols
*/
private static CPruneDerivInfo aggregateSymbols(Derivation deriv) {
Map<String, Object> tempState = deriv.getTempState();
if (tempState.containsKey("cprune")) {

View File

@ -1,5 +1,10 @@
package edu.stanford.nlp.sempre.cprune;
/**
* Represents the leaf node of the parse tree.
*
* Any sub-derivation whose category is in CustomGrammar.baseCategories becomes a Symbol.
*/
public class Symbol implements Comparable<Symbol> {
String category;
String formula;