MCPcopy Create free account
hub / github.com/GateNLP/gate-core / CorpusImpl

Class CorpusImpl

src/main/java/gate/corpora/CorpusImpl.java:63–813  ·  view source on GitHub ↗

Corpora are sets of Document. They are ordered by lexicographic collation on Url.

Source from the content-addressed store, hash-verified

61 * collation on Url.
62 */
63@CreoleResource(name = "GATE Corpus", comment = "GATE transient corpus.", interfaceName = "gate.Corpus", icon = "corpus-trans", helpURL = "http://gate.ac.uk/userguide/sec:developer:loadlr")
64public class CorpusImpl extends AbstractLanguageResource implements Corpus,
65 CreoleListener,
66 CustomDuplication {
67
68 public CorpusImpl() {
69 supportList = Collections.synchronizedList(new VerboseList());
70 Gate.getCreoleRegister().addCreoleListener(this);
71 }
72
73 /**
74 * Gets the names of the documents in this corpus.
75 *
76 * @return a {@link List} of Strings representing the names of the
77 * documents in this corpus.
78 */
79 @Override
80 public List<String> getDocumentNames() {
81 ArrayList<String> res = new ArrayList<String>(supportList.size());
82 for(Object document : supportList) {
83 res.add(((Document)document).getName());
84 }
85 return res;
86 }
87
88 /**
89 * Gets the name of a document in this corpus.
90 *
91 * @param index the index of the document
92 * @return a String value representing the name of the document at
93 * <tt>index</tt> in this corpus.
94 */
95 @Override
96 public String getDocumentName(int index) {
97 return supportList.get(index).getName();
98 }
99
100 /**
101 * This method does not make sense for transient corpora, so it does
102 * nothing.
103 */
104 @Override
105 public void unloadDocument(Document doc) {
106 return;
107 }
108
109 /**
110 * The underlying list that holds the documents in this corpus.
111 */
112 protected List<Document> supportList = null;
113
114 /**
115 * A proxy list that stores the actual data in an internal list and
116 * forwards all operations to that one but it also fires the
117 * appropriate corpus events when necessary. It also does some type
118 * checking so only Documents are accepted as corpus members.
119 */
120 protected class VerboseList extends AbstractList<Document> implements Serializable {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected