mirror of https://github.com/percyliang/sempre
Added a few more docstrings
This commit is contained in:
parent
bc878e69e5
commit
212e28fc77
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue