Esempio n. 1
0
        internal virtual Tree ConvertTree(string treeText)
        {
            Options     op = new Options();
            IHeadFinder binaryHeadFinder = new BinaryHeadFinder(op.tlpParams.HeadFinder());
            Tree        tree             = Tree.ValueOf(treeText);

            Edu.Stanford.Nlp.Trees.Trees.ConvertToCoreLabels(tree);
            tree.PercolateHeadAnnotations(binaryHeadFinder);
            return(tree);
        }
Esempio n. 2
0
        public static IList <Tree> BinarizeTreebank(Treebank treebank, Options op)
        {
            TreeBinarizer binarizer = TreeBinarizer.SimpleTreeBinarizer(op.tlpParams.HeadFinder(), op.tlpParams.TreebankLanguagePack());
            BasicCategoryTreeTransformer basicTransformer = new BasicCategoryTreeTransformer(op.Langpack());
            CompositeTreeTransformer     transformer      = new CompositeTreeTransformer();

            transformer.AddTransformer(binarizer);
            transformer.AddTransformer(basicTransformer);
            treebank = treebank.Transform(transformer);
            IHeadFinder  binaryHeadFinder = new BinaryHeadFinder(op.tlpParams.HeadFinder());
            IList <Tree> binarizedTrees   = Generics.NewArrayList();

            foreach (Tree tree in treebank)
            {
                Edu.Stanford.Nlp.Trees.Trees.ConvertToCoreLabels(tree);
                tree.PercolateHeadAnnotations(binaryHeadFinder);
                // Index from 1.  Tools downstream expect index from 1, so for
                // uses internal to the srparser we have to renormalize the
                // indices, with the result that here we have to index from 1
                tree.IndexLeaves(1, true);
                binarizedTrees.Add(tree);
            }
            return(binarizedTrees);
        }