Skip to content

Commit

Permalink
nndep: support cPOS / unlabeled / preModel / noPunc options
Browse files Browse the repository at this point in the history
  • Loading branch information
Danqi Chen authored and Stanford NLP committed Jan 26, 2015
1 parent af28653 commit d7473c0
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 130 deletions.
2 changes: 1 addition & 1 deletion src/edu/stanford/nlp/parser/nndep/ArcStandard.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean canApply(Configuration c, String t) {
int h = t.startsWith("L") ? c.getStack(0) : c.getStack(1);
if (h < 0) return false;
if (h == 0 && !label.equals(rootLabel)) return false;
if (h > 0 && label.equals(rootLabel)) return false;
//if (h > 0 && label.equals(rootLabel)) return false;
}

int nStack = c.getStackSize();
Expand Down
2 changes: 0 additions & 2 deletions src/edu/stanford/nlp/parser/nndep/Classifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;


/**
* Neural network classifier which powers a transition-based dependency
* parser.
Expand Down Expand Up @@ -744,5 +743,4 @@ private static void addInPlace(double[] a1, double[] a2) {
for (int i = 0; i < a1.length; i++)
a1[i] += a2[i];
}

}
22 changes: 22 additions & 0 deletions src/edu/stanford/nlp/parser/nndep/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,23 @@ public class Config
*/
public boolean saveIntermediate = true;


/**
* Train a labeled parser if labeled = true, and a unlabeled one otherwise.
*/
public boolean unlabeled = false;

/**
* Use coarse POS instead of fine-grained POS if cPOS = true.
*/
public boolean cPOS = false;

/**
* Exclude punctuations in evaluation if noPunc = true.
*/
public boolean noPunc = true;

/**
* Describes language-specific properties necessary for training and
* testing. By default,
* {@link edu.stanford.nlp.trees.PennTreebankLanguagePack} will be
Expand Down Expand Up @@ -206,6 +222,9 @@ private void setProperties(Properties props) {
evalPerIter = PropertiesUtils.getInt(props, "evalPerIter", evalPerIter);
clearGradientsPerIter = PropertiesUtils.getInt(props, "clearGradientsPerIter", clearGradientsPerIter);
saveIntermediate = PropertiesUtils.getBool(props, "saveIntermediate", saveIntermediate);
unlabeled = PropertiesUtils.getBool(props, "unlabeled", unlabeled);
cPOS = PropertiesUtils.getBool(props, "cPOS", cPOS);
noPunc = PropertiesUtils.getBool(props, "noPunc", noPunc);

// Runtime parsing options
sentenceDelimiter = PropertiesUtils.getString(props, "sentenceDelimiter", sentenceDelimiter);
Expand Down Expand Up @@ -253,5 +272,8 @@ public void printParameters() {
System.err.printf("evalPerIter = %d%n", evalPerIter);
System.err.printf("clearGradientsPerIter = %d%n", clearGradientsPerIter);
System.err.printf("saveItermediate = %b%n", saveIntermediate);
System.err.printf("unlabeled = %b%n", unlabeled);
System.err.printf("cPOS = %b%n", cPOS);
System.err.printf("noPunc = %b%n", noPunc);
}
}
Loading

0 comments on commit d7473c0

Please sign in to comment.