Пример #1
0
  public MLEDependencyGrammar(
      TagProjection tagProjection,
      TreebankLangParserParams tlpParams,
      boolean directional,
      boolean useDistance,
      boolean useCoarseDistance,
      Options op,
      Index<String> wordIndex,
      Index<String> tagIndex) {
    super(
        tlpParams.treebankLanguagePack(),
        tagProjection,
        directional,
        useDistance,
        useCoarseDistance,
        op,
        wordIndex,
        tagIndex);
    useSmoothTagProjection = op.useSmoothTagProjection;
    useUnigramWordSmoothing = op.useUnigramWordSmoothing;
    argCounter = new ClassicCounter<IntDependency>();
    stopCounter = new ClassicCounter<IntDependency>();
    double[] smoothParams = tlpParams.MLEDependencyGrammarSmoothingParams();
    smooth_aT_hTWd = smoothParams[0];
    smooth_aTW_hTWd = smoothParams[1];
    smooth_stop = smoothParams[2];
    interp = smoothParams[3];

    // cdm added Jan 2007 to play with dep grammar smoothing.  Integrate this better if we keep it!
    smoothTP = new BasicCategoryTagProjection(tlpParams.treebankLanguagePack());
  }
Пример #2
0
 /**
  * Determines method for print trees on output.
  *
  * @param tlpParams The treebank parser params
  * @return A suitable tree printing object
  */
 public TreePrint treePrint(TreebankLangParserParams tlpParams) {
   TreebankLanguagePack tlp = tlpParams.treebankLanguagePack();
   return new TreePrint(
       outputFormat,
       outputFormatOptions,
       tlp,
       tlpParams.headFinder(),
       tlpParams.typedDependencyHeadFinder());
 }
  /** For testing: loads a treebank and prints the trees. */
  public static void main(String[] args) {
    TreebankLangParserParams tlpp = new ChineseTreebankParserParams();
    System.out.println("Default encoding is: " + tlpp.diskTreebank().encoding());

    if (args.length < 2) {
      printlnErr(
          "Usage: edu.stanford.nlp.parser.lexparser.ChineseTreebankParserParams treesPath fileRange");
    } else {
      Treebank m = tlpp.diskTreebank();
      m.loadPath(args[0], new NumberRangesFileFilter(args[1], false));

      for (Tree t : m) {
        t.pennPrint(tlpp.pw());
      }
      System.out.println("There were " + m.size() + " trees.");
    }
  }
 public TransformTreeDependency(TreebankLangParserParams tlpParams, boolean forceCNF) {
   if (!Train.leftToRight) {
     binarizer = new TreeAnnotatorAndBinarizer(tlpParams, forceCNF, !Train.outsideFactor(), true);
   } else {
     binarizer =
         new TreeAnnotatorAndBinarizer(
             tlpParams.headFinder(),
             new LeftHeadFinder(),
             tlpParams,
             forceCNF,
             !Train.outsideFactor(),
             true);
   }
   if (Train.collinsPunc) {
     collinsPuncTransformer = new CollinsPuncTransformer(tlpParams.treebankLanguagePack());
   }
 }
Пример #5
0
 public MLEDependencyGrammar(
     TreebankLangParserParams tlpParams,
     boolean directional,
     boolean distance,
     boolean coarseDistance,
     boolean basicCategoryTagsInDependencyGrammar,
     Options op,
     Index<String> wordIndex,
     Index<String> tagIndex) {
   this(
       basicCategoryTagsInDependencyGrammar
           ? new BasicCategoryTagProjection(tlpParams.treebankLanguagePack())
           : new TestTagProjection(),
       tlpParams,
       directional,
       distance,
       coarseDistance,
       op,
       wordIndex,
       tagIndex);
 }