public final class MemoryTreebank extends Treebank implements FileProcessor, List<Tree>
MemoryTreebank
object stores a corpus of examples with
given tree structures in memory (as a List
).DEFAULT_TREE_FILE_SUFFIX
Constructor and Description |
---|
MemoryTreebank()
Create a new tree bank.
|
MemoryTreebank(int initialCapacity)
Create a new Treebank.
|
MemoryTreebank(int initialCapacity,
TreeReaderFactory trf)
Create a new tree bank.
|
MemoryTreebank(List<Tree> trees,
TreeReaderFactory trf,
String encoding)
Create a new tree bank.
|
MemoryTreebank(String encoding)
Create a new tree bank, set the encoding for file access
|
MemoryTreebank(TreeNormalizer tm)
Create a new tree bank, using a specific TreeNormalizer.
|
MemoryTreebank(TreeReaderFactory trf)
Create a new tree bank.
|
MemoryTreebank(TreeReaderFactory trf,
String encoding)
Create a new tree bank.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
Tree element) |
boolean |
add(Tree element) |
boolean |
addAll(int index,
Collection<? extends Tree> c) |
void |
apply(TreeVisitor tp)
Apply the TreeVisitor tp to all trees in the Treebank.
|
void |
clear()
Empty a
Treebank . |
Tree |
get(int i)
Get a tree by index from the Treebank.
|
int |
indexOf(Object o) |
Iterator<Tree> |
iterator()
Return an Iterator over Trees in the Treebank.
|
int |
lastIndexOf(Object o) |
ListIterator<Tree> |
listIterator() |
ListIterator<Tree> |
listIterator(int index) |
void |
load(Reader r)
Load a collection of parse trees from a Reader.
|
void |
load(Reader r,
String id)
Load a collection of parse trees from a Reader.
|
void |
loadPath(File path,
FileFilter filt)
Load trees from given directory.
|
void |
loadPath(String path,
FileFilter filt,
String srlFile) |
static void |
main(String[] args)
Loads treebank grammar from first argument and prints it.
|
void |
processFile(File file)
Load a collection of parse trees from the file of given name.
|
Tree |
remove(int index) |
Tree |
set(int index,
Tree element) |
int |
size()
Returns the size of the Treebank.
|
List<Tree> |
subList(int fromIndex,
int toIndex) |
Treebank |
transform(TreeTransformer treeTrans)
Return a MemoryTreebank where each
Tree in the current treebank has been transformed using the
TreeTransformer.
|
decimate, encoding, loadPath, loadPath, loadPath, loadPath, loadPath, remove, textualSummary, textualSummary, toString, treeReaderFactory
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAll, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
public MemoryTreebank()
LabeledScoredTreeReaderFactory
.
Compatibility note: Until Sep 2004, this used to create a Treebank
with a SimpleTreeReaderFactory, but this was changed as the old
default wasn't very useful, especially to naive users. This one now
uses a LabledScoredTreeReaderFactory with a no-op TreeNormalizer.public MemoryTreebank(TreeNormalizer tm)
LabeledScoredTreeReaderFactory
.
Compatibility note: Until Sep 2004, this used to create a Treebank
with a SimpleTreeReaderFactory, but this was changed as the old
default wasn't very useful, especially to naive users.public MemoryTreebank(String encoding)
encoding
- the encoding to use for file access.public MemoryTreebank(TreeReaderFactory trf)
trf
- the factory class to be called to create a new
TreeReader
public MemoryTreebank(TreeReaderFactory trf, String encoding)
trf
- the factory class to be called to create a new
TreeReader
encoding
- the encoding to use for file access.public MemoryTreebank(List<Tree> trees, TreeReaderFactory trf, String encoding)
trees
- The trees to put in the Treebank.trf
- the factory class to be called to create a new
TreeReader
encoding
- the encoding to use for file access.public MemoryTreebank(int initialCapacity)
initialCapacity
- The initial size of the underlying Collection,
(if a Collection-based storage mechanism is being provided)public MemoryTreebank(int initialCapacity, TreeReaderFactory trf)
initialCapacity
- The initial size of the underlying Collectiontrf
- the factory class to be called to create a new
TreeReader
public void clear()
Treebank
.public void loadPath(File path, FileFilter filt)
public void loadPath(String path, FileFilter filt, String srlFile)
public void processFile(File file)
FileProcessor
interface.processFile
in interface FileProcessor
file
- file to load a tree fromfor traversing directories
public void load(Reader r)
r
- The reader to read trees from. (If you want it buffered,
you should already have buffered it!)public void load(Reader r, String id)
r
- The reader to read trees from. (If you want it buffered,
you should already have buffered it!)id
- An ID for where these files come from (arbitrary, but
something like a filename. Can be null
for none.public Tree get(int i)
Treebank
feature set, and
so is only available with a MemoryTreebank
, but is
useful in allowing the latter to be used as a List
.public void apply(TreeVisitor tp)
public int size()
Treebank
public boolean add(Tree element)
add
in interface Collection<Tree>
add
in interface List<Tree>
add
in class AbstractCollection<Tree>
public boolean addAll(int index, Collection<? extends Tree> c)
public int lastIndexOf(Object o)
lastIndexOf
in interface List<Tree>
public ListIterator<Tree> listIterator()
listIterator
in interface List<Tree>
public ListIterator<Tree> listIterator(int index)
listIterator
in interface List<Tree>
public Treebank transform(TreeTransformer treeTrans)
public static void main(String[] args)
usage: java MemoryTreebank treebankFilesPath
args
- array of command-line arguments