|
From: <ada...@us...> - 2013-09-27 17:52:27
|
Revision: 16951
http://sourceforge.net/p/gate/code/16951
Author: adamfunk
Date: 2013-09-27 17:52:24 +0000 (Fri, 27 Sep 2013)
Log Message:
-----------
Finally the load/save config options work.
GUI still needs a little tidying.
Modified Paths:
--------------
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationDialogWrapper.java
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java 2013-09-27 13:20:34 UTC (rev 16950)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java 2013-09-27 17:52:24 UTC (rev 16951)
@@ -32,7 +32,6 @@
public class Population extends ResourceHelper {
private static final long serialVersionUID = 1443073039199794668L;
-
public static void populateCorpus(final Corpus corpus, URL inputUrl, PopulationConfig config)
@@ -68,20 +67,20 @@
int tweetCounter = 0;
Document document = newDocument(inputUrl, tweetCounter, digits);
StringBuilder content = new StringBuilder();
- Map<PreAnnotation, Integer> annotanda = new HashMap<PreAnnotation, Integer>();
+ Map<PreAnnotation, Integer> annotandaOffsets = new HashMap<PreAnnotation, Integer>();
for (Tweet tweet : tweets) {
if ( (tweetsPerDoc > 0) && (tweetCounter > 0) && ((tweetCounter % tweetsPerDoc) == 0) ) {
- closeDocument(document, content, annotanda, corpus);
+ closeDocument(document, content, annotandaOffsets, corpus);
document = newDocument(inputUrl, tweetCounter, digits);
content = new StringBuilder();
- annotanda = new HashMap<PreAnnotation, Integer>();
+ annotandaOffsets = new HashMap<PreAnnotation, Integer>();
}
int startOffset = content.length();
content.append(tweet.getString());
for (PreAnnotation preAnn : tweet.getAnnotations()) {
- annotanda.put(preAnn, startOffset);
+ annotandaOffsets.put(preAnn, startOffset);
}
content.append('\n');
@@ -89,7 +88,7 @@
} // end of Tweet loop
if (content.length() > 0) {
- closeDocument(document, content, annotanda, corpus);
+ closeDocument(document, content, annotandaOffsets, corpus);
}
else {
Factory.deleteResource(document);
@@ -118,12 +117,12 @@
}
- private static void closeDocument(Document document, StringBuilder content, Map<PreAnnotation, Integer> annotanda, Corpus corpus) throws InvalidOffsetException {
+ private static void closeDocument(Document document, StringBuilder content, Map<PreAnnotation, Integer> annotandaOffsets, Corpus corpus) throws InvalidOffsetException {
DocumentContent contentImpl = new DocumentContentImpl(content.toString());
document.setContent(contentImpl);
AnnotationSet originalMarkups = document.getAnnotations(Gate.ORIGINAL_MARKUPS_ANNOT_SET_NAME);
- for (PreAnnotation preAnn : annotanda.keySet()) {
- preAnn.toAnnotation(originalMarkups, annotanda.get(preAnn));
+ for (PreAnnotation preAnn : annotandaOffsets.keySet()) {
+ preAnn.toAnnotation(originalMarkups, annotandaOffsets.get(preAnn));
}
corpus.add(document);
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java 2013-09-27 13:20:34 UTC (rev 16950)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java 2013-09-27 17:52:24 UTC (rev 16951)
@@ -147,8 +147,9 @@
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int chosen = chooser.showOpenDialog(this.wrapper.dialog);
if (chosen == JFileChooser.APPROVE_OPTION) {
- wrapper.config = PopulationConfig.load(chooser.getSelectedFile());
- wrapper.updateGui();
+ File file = chooser.getSelectedFile();
+ System.out.println("Loading " + file.getAbsolutePath());
+ wrapper.setNewConfig(PopulationConfig.load(chooser.getSelectedFile()));
}
}
}
@@ -169,6 +170,7 @@
int chosen = chooser.showSaveDialog(this.wrapper.dialog);
if (chosen == JFileChooser.APPROVE_OPTION) {
try {
+ wrapper.updateConfig();
wrapper.config.saveXML(chooser.getSelectedFile());
}
catch(IOException e1) {
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationDialogWrapper.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationDialogWrapper.java 2013-09-27 13:20:34 UTC (rev 16950)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationDialogWrapper.java 2013-09-27 17:52:24 UTC (rev 16951)
@@ -95,8 +95,8 @@
configPersistenceBox.add(Box.createHorizontalGlue());
// TODO keep these commented out on svn until reloading works properly
- //dialog.add(configPersistenceBox);
- //dialog.add(Box.createVerticalStrut(5));
+ dialog.add(configPersistenceBox);
+ dialog.add(Box.createVerticalStrut(5));
dialog.add(new JSeparator(SwingConstants.HORIZONTAL));
dialog.add(Box.createVerticalStrut(2));
@@ -141,6 +141,11 @@
}
+ protected void setNewConfig(PopulationConfig newConfig) {
+ this.config = newConfig;
+ this.updateGui();
+ }
+
protected void updateConfig() {
this.config.setTweetsPerDoc(this.checkbox.isSelected() ? 1 : 0);
this.config.setContentKeys(this.contentKeysEditor.getValues());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|