|
From: <ada...@us...> - 2013-09-27 12:53:56
|
Revision: 16949
http://sourceforge.net/p/gate/code/16949
Author: adamfunk
Date: 2013-09-27 12:53:53 +0000 (Fri, 27 Sep 2013)
Log Message:
-----------
Put all the constants in one place, so they are easier to find
Modified Paths:
--------------
gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java
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/PreAnnotation.java
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Tweet.java
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/TweetUtils.java
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java 2013-09-27 11:31:54 UTC (rev 16948)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/JSONTweetFormat.java 2013-09-27 12:53:53 UTC (rev 16949)
@@ -38,8 +38,6 @@
public class JSONTweetFormat extends TextualDocumentFormat {
private static final long serialVersionUID = 6878020036304333918L;
- public static final String TEXT_ATTRIBUTE = "text";
- public static final String TWEET_ANNOTATION_TYPE = "Tweet";
/** Default construction */
public JSONTweetFormat() { super();}
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java 2013-09-27 11:31:54 UTC (rev 16948)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java 2013-09-27 12:53:53 UTC (rev 16949)
@@ -50,9 +50,6 @@
private static final long serialVersionUID = 1443073039199794668L;
- public static final String[] DEFAULT_CONTENT_KEYS = {"text", "created_at", "user:name"};
- public static final String[] DEFAULT_FEATURE_KEYS = {"user:screen_name", "user:location",
- "id", "source", "truncated", "retweeted_status:id"};
public static void populateCorpus(final Corpus corpus, URL inputUrl, PopulationConfig config)
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java 2013-09-27 11:31:54 UTC (rev 16948)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PopulationConfig.java 2013-09-27 12:53:53 UTC (rev 16949)
@@ -70,8 +70,8 @@
public PopulationConfig() {
this.tweetsPerDoc = 0;
this.encoding = TweetUtils.DEFAULT_ENCODING;
- this.contentKeys = Arrays.asList(Population.DEFAULT_CONTENT_KEYS);
- this.featureKeys = Arrays.asList(Population.DEFAULT_FEATURE_KEYS);
+ this.contentKeys = Arrays.asList(TweetUtils.DEFAULT_CONTENT_KEYS);
+ this.featureKeys = Arrays.asList(TweetUtils.DEFAULT_FEATURE_KEYS);
}
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java 2013-09-27 11:31:54 UTC (rev 16948)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java 2013-09-27 12:53:53 UTC (rev 16949)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011--2012, The University of Sheffield.
+ * Copyright (c) 2011--2013, The University of Sheffield.
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
* software, licenced under the GNU Library General Public License,
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Tweet.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Tweet.java 2013-09-27 11:31:54 UTC (rev 16948)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Tweet.java 2013-09-27 12:53:53 UTC (rev 16949)
@@ -1,6 +1,4 @@
/*
- * Tweet.java
- *
* Copyright (c) 1995-2013, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
@@ -15,22 +13,11 @@
import gate.*;
import gate.util.*;
-import gate.corpora.*;
-
import java.util.*;
-
import org.apache.commons.lang.StringEscapeUtils;
-
import com.fasterxml.jackson.databind.JsonNode;
-// Jackson API
-// http://wiki.fasterxml.com/JacksonHome
-
-// Standard: RFC 4627
-// https://tools.ietf.org/html/rfc4627
-
-
public class Tweet {
private String string;
private long start;
@@ -81,7 +68,7 @@
while (keys.hasNext()) {
String key = keys.next();
- if (key.equals(JSONTweetFormat.TEXT_ATTRIBUTE)) {
+ if (key.equals(TweetUtils.DEFAULT_TEXT_ATTRIBUTE)) {
string = StringEscapeUtils.unescapeHtml(json.get(key).asText());
}
else {
@@ -89,7 +76,7 @@
}
}
- annotations.add(new PreAnnotation(0L, string.length(), JSONTweetFormat.TWEET_ANNOTATION_TYPE, features));
+ annotations.add(new PreAnnotation(0L, string.length(), TweetUtils.TWEET_ANNOTATION_TYPE, features));
}
@@ -128,7 +115,7 @@
}
// Create the main annotation and the content.
- this.annotations.add(new PreAnnotation(0, content.length(), JSONTweetFormat.TWEET_ANNOTATION_TYPE, annoFeatures));
+ this.annotations.add(new PreAnnotation(0, content.length(), TweetUtils.TWEET_ANNOTATION_TYPE, annoFeatures));
this.string = content.toString();
}
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/TweetUtils.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/TweetUtils.java 2013-09-27 11:31:54 UTC (rev 16948)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/TweetUtils.java 2013-09-27 12:53:53 UTC (rev 16949)
@@ -1,6 +1,4 @@
/*
- * TweetUtils.java
- *
* Copyright (c) 1995-2013, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
@@ -17,24 +15,34 @@
import java.io.IOException;
import java.util.*;
+
import org.apache.commons.lang.StringUtils;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
+/* REFERENCES
+ * Jackson API
+ * http://wiki.fasterxml.com/JacksonHome
+ * Standard: RFC 4627
+ * https://tools.ietf.org/html/rfc4627
+ * */
-// Jackson API
-// http://wiki.fasterxml.com/JacksonHome
-
-// Standard: RFC 4627
-// https://tools.ietf.org/html/rfc4627
-
public class TweetUtils {
public static final String PATH_SEPARATOR = ":";
public static final String MIME_TYPE = "text/x-json-twitter";
public static final String DEFAULT_ENCODING = "UTF-8";
+ public static final String TWEET_ANNOTATION_TYPE = "Tweet";
+ public static final String DEFAULT_TEXT_ATTRIBUTE = "text";
+
+ public static final String[] DEFAULT_CONTENT_KEYS = {DEFAULT_TEXT_ATTRIBUTE,
+ "created_at", "user:name"};
+ public static final String[] DEFAULT_FEATURE_KEYS = {"user:screen_name",
+ "user:location", "id", "source", "truncated", "retweeted_status:id"};
+
public static List<Tweet> readTweets(String string) throws IOException {
if (string.startsWith("[")) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|