Search in sources :

Example 1 with ArabicTreeReaderFactory

use of edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory in project CoreNLP by stanfordnlp.

the class Preferences method lookupTreeReaderFactory.

static TreeReaderFactory lookupTreeReaderFactory(String trfName) {
    if (trfName.equalsIgnoreCase("ArabicTreeReaderFactory")) {
        return new ArabicTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("ArabicTreeReaderFactory.ArabicRawTreeReaderFactory")) {
        return new ArabicTreeReaderFactory.ArabicRawTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("CTBTreeReaderFactory")) {
        return new CTBTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("NoEmptiesCTBTreeReaderFactory")) {
        return new NoEmptiesCTBTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("Basic categories only (LabeledScoredTreeReaderFactory)")) {
        return new LabeledScoredTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("FrenchTreeReaderFactory")) {
        //PTB format
        return new FrenchTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("PennTreeReaderFactory")) {
        return new PennTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("StringLabeledScoredTreeReaderFactory")) {
        return new StringLabeledScoredTreeReaderFactory();
    } else if (trfName.equalsIgnoreCase("TregexTreeReaderFactory")) {
        return new TregexPattern.TRegexTreeReaderFactory();
    } else {
        //try to find the class
        try {
            Class<?> trfClass = Class.forName(trfName);
            TreeReaderFactory trf = (TreeReaderFactory) trfClass.newInstance();
            return trf;
        } catch (Exception e) {
            return new PennTreeReaderFactory();
        }
    }
}
Also used : ArabicTreeReaderFactory(edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory) StringLabeledScoredTreeReaderFactory(edu.stanford.nlp.trees.StringLabeledScoredTreeReaderFactory) FrenchTreeReaderFactory(edu.stanford.nlp.trees.international.french.FrenchTreeReaderFactory) NoEmptiesCTBTreeReaderFactory(edu.stanford.nlp.trees.international.pennchinese.NoEmptiesCTBTreeReaderFactory) CTBTreeReaderFactory(edu.stanford.nlp.trees.international.pennchinese.CTBTreeReaderFactory) NoEmptiesCTBTreeReaderFactory(edu.stanford.nlp.trees.international.pennchinese.NoEmptiesCTBTreeReaderFactory) PennTreeReaderFactory(edu.stanford.nlp.trees.PennTreeReaderFactory) FrenchTreeReaderFactory(edu.stanford.nlp.trees.international.french.FrenchTreeReaderFactory) CTBTreeReaderFactory(edu.stanford.nlp.trees.international.pennchinese.CTBTreeReaderFactory) StringLabeledScoredTreeReaderFactory(edu.stanford.nlp.trees.StringLabeledScoredTreeReaderFactory) NoEmptiesCTBTreeReaderFactory(edu.stanford.nlp.trees.international.pennchinese.NoEmptiesCTBTreeReaderFactory) PennTreeReaderFactory(edu.stanford.nlp.trees.PennTreeReaderFactory) TreeReaderFactory(edu.stanford.nlp.trees.TreeReaderFactory) LabeledScoredTreeReaderFactory(edu.stanford.nlp.trees.LabeledScoredTreeReaderFactory) ArabicTreeReaderFactory(edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory) StringLabeledScoredTreeReaderFactory(edu.stanford.nlp.trees.StringLabeledScoredTreeReaderFactory) LabeledScoredTreeReaderFactory(edu.stanford.nlp.trees.LabeledScoredTreeReaderFactory)

Example 2 with ArabicTreeReaderFactory

use of edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory in project CoreNLP by stanfordnlp.

the class MWETreeVisitorExternal method main.

/**
   * For debugging.
   * 
   * @param args
   */
public static void main(String[] args) {
    if (args.length != 1) {
        System.err.printf("Usage: java %s atb_tree_file > atb_tree_file.out%n", MWETreeVisitorExternal.class.getName());
        System.exit(-1);
    }
    TreeReaderFactory trf = new ArabicTreeReaderFactory();
    try {
        TreeReader tr = trf.newTreeReader(new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), "UTF-8")));
        TreeVisitor visitor = new MWETreeVisitorExternal();
        int treeId = 0;
        for (Tree tree; (tree = tr.readTree()) != null; ++treeId) {
            if (tree.value().equals("ROOT")) {
                // Skip over the ROOT tag
                tree = tree.firstChild();
            }
            visitor.visitTree(tree);
            System.out.println(tree.toString());
        }
        tr.close();
        System.err.printf("Processed %d trees.%n", treeId);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) FileNotFoundException(java.io.FileNotFoundException) TreeReader(edu.stanford.nlp.trees.TreeReader) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) ArabicTreeReaderFactory(edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory) TreeVisitor(edu.stanford.nlp.trees.TreeVisitor) BufferedReader(java.io.BufferedReader) Tree(edu.stanford.nlp.trees.Tree) TreeReaderFactory(edu.stanford.nlp.trees.TreeReaderFactory) ArabicTreeReaderFactory(edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory)

Aggregations

TreeReaderFactory (edu.stanford.nlp.trees.TreeReaderFactory)2 ArabicTreeReaderFactory (edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory)2 LabeledScoredTreeReaderFactory (edu.stanford.nlp.trees.LabeledScoredTreeReaderFactory)1 PennTreeReaderFactory (edu.stanford.nlp.trees.PennTreeReaderFactory)1 StringLabeledScoredTreeReaderFactory (edu.stanford.nlp.trees.StringLabeledScoredTreeReaderFactory)1 Tree (edu.stanford.nlp.trees.Tree)1 TreeReader (edu.stanford.nlp.trees.TreeReader)1 TreeVisitor (edu.stanford.nlp.trees.TreeVisitor)1 FrenchTreeReaderFactory (edu.stanford.nlp.trees.international.french.FrenchTreeReaderFactory)1 CTBTreeReaderFactory (edu.stanford.nlp.trees.international.pennchinese.CTBTreeReaderFactory)1 NoEmptiesCTBTreeReaderFactory (edu.stanford.nlp.trees.international.pennchinese.NoEmptiesCTBTreeReaderFactory)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1