Package org.opensextant.data.social
Class Tweet
java.lang.Object
org.opensextant.data.social.Message
org.opensextant.data.social.Tweet
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
M=male, F=female, T=transitional, transgender? Other? Gender is a string, could be an enum, but its no longer two values, I bet.static String
protected String
boolean
static final org.joda.time.format.DateTimeFormatter
static String
protected List<Tweet.Mention>
boolean
static String
static final org.joda.time.format.DateTimeFormatter
protected boolean
Is TweetStore the main repository of data?Fields inherited from class org.opensextant.data.social.Message
authorCC, authorGeo, authorID, authorLatLonText, authorLocation, authorName, authorProfileID, date, dateText, id, isASCII, isDST, isEnglish, lang, locationCC, OFFSET_HALF, rawbytes, sourceID, statusGeo, text, textNatural, timezone, UNSET_UTC_OFFSET, userLang, utcOffset, utcOffsetHours
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMention
(String uname, String uid) If adding mentions one at a time, then only mention IDS map is used.void
add any tag you like.void
void
static String
void
fromJSON
(jodd.json.JsonObject tw) If "base data" has been filled in by other method, e.g., TW4J or other formal API, then avoid parsing the basics here: id, text ,author*, date, lang, are checked if null.TODO: this is not clear.static int
getInteger
(jodd.json.JsonObject o, String k, int defVal) fully qualified Twitter user profiles: screen_name : user ID pairings.Found user screen_names, no user IDgetTags()
getURLs()
boolean
indicate if tweet has any Geo resolution at all, wether it was a given Lat/Lon or derived.boolean
indicate if tweet is geolocated by an accurate coordinate.static boolean
static boolean
static boolean
isValue
(jodd.json.JsonObject o) static String
"", null, or "null" checking.protected void
static String
Most commonly needed to parse TweetID from a GnipIDprotected String
Find a best ID from many possible places where ID, id, id_str, etc, reside.void
parseLanguage
(String lg) parseMentions
(String msg) From a tweet, get list of "@id"parseMentions
(jodd.json.JsonObject entities) Gets a entities.user_mentions from a normal Tweet.protected void
void
supports gnip.urls or topsy.urls fieldsvoid
setDate
(long d) Set the date and an the standard "CREATED_AT" date/time format.void
void
protected static void
Order of coordinates is for geo = (LON, LAT) in twitter objects.void
setPerson
(jodd.json.JsonObject tw_user) protected static void
static void
setStatusGeo
(jodd.json.JsonObject json, Tweet tw) TODO: investigate how close a user Profile geo compares with Status geo.void
setUser
(jodd.json.JsonObject tw_user) static boolean
setUserGeo
(jodd.json.JsonObject json, Tweet tw) toString()
Methods inherited from class org.opensextant.data.social.Message
getText, getTextNatural, setText, setTextNatural, setUTCOffset, toUTCOffsetHours, validateUTCOffset, validTZ
-
Field Details
-
SOURCE_TWITTER
-
ATTR_ID
- See Also:
-
ATTR_TEXT
- See Also:
-
ATTR_SCREEN_NAME
- See Also:
-
ATTR_AUTH_NAME
- See Also:
-
ATTR_PROFILE_ID
- See Also:
-
ATTR_DATE
- See Also:
-
ATTR_EPOCH
- See Also:
-
ATTR_LANG
- See Also:
-
ATTR_AUTH_LANG
- See Also:
-
ATTR_GENDER
- See Also:
-
ATTR_DESC
- See Also:
-
ATTR_RETWEET
- See Also:
-
ATTR_RETWEET_ID
- See Also:
-
ATTR_USES_GPS
- See Also:
-
ATTR_TZ
- See Also:
-
ATTR_UTC_OFFSET
- See Also:
-
ATTR_KLOUT
- See Also:
-
ATTR_URLS
- See Also:
-
ATTR_TAGS
- See Also:
-
ATTR_MENTIONS
- See Also:
-
timestamp_parser
public static final org.joda.time.format.DateTimeFormatter timestamp_parser -
iso_date_formatter
public static final org.joda.time.format.DateTimeFormatter iso_date_formatter -
geoEnabled
public boolean geoEnabled -
retweet
public boolean retweet -
retweetID
-
authorDesc
-
tweetStore
protected boolean tweetStoreIs TweetStore the main repository of data? -
entitiesKey
-
authorGender
M=male, F=female, T=transitional, transgender? Other? Gender is a string, could be an enum, but its no longer two values, I bet. -
LOCATION_FLD
-
COORD_FLD
-
mentions
-
mentionIDs
-
-
Constructor Details
-
Tweet
public Tweet() -
Tweet
-
Tweet
-
-
Method Details
-
isGeolocated
public boolean isGeolocated()indicate if tweet is geolocated by an accurate coordinate.- Returns:
-
isGeoinferenced
public boolean isGeoinferenced()indicate if tweet has any Geo resolution at all, wether it was a given Lat/Lon or derived. Careful -- authorGeo and statusGeo are both mutable. If you geocode them directly while still on the Tweet instance, they will look like they were part of the given data.- Returns:
-
setGeoMethod
-
getGeoMethod
TODO: this is not clear.- Returns:
-
applyGenericRules
public void applyGenericRules() -
fixNull
-
setDate
public void setDate(long d) Set the date and an the standard "CREATED_AT" date/time format.- Parameters:
d
- epoch
-
getISOTimestamp
-
parseId
Most commonly needed to parse TweetID from a GnipID- Parameters:
gnipId
-- Returns:
-
parseIds
Find a best ID from many possible places where ID, id, id_str, etc, reside.- Parameters:
tw
-- Returns:
- Throws:
MessageParseException
-
fromJSON
If "base data" has been filled in by other method, e.g., TW4J or other formal API, then avoid parsing the basics here: id, text ,author*, date, lang, are checked if null. Only if null will they each be found in JSON and parsed. throws MessageParseException- Throws:
MessageParseException
-
parseDate
-
parseText
- Throws:
MessageParseException
-
parseLanguage
-
parseURLs
supports gnip.urls or topsy.urls fields- Parameters:
jsonArray
-
-
setUserGeo
- Parameters:
json
-tw
-- Returns:
- true if a location metadata was found and set.
-
setStatusGeo
TODO: investigate how close a user Profile geo compares with Status geo.- Parameters:
json
-tw
-
-
setPlace
- Parameters:
p
-aPlace
-
-
setLatLon
Order of coordinates is for geo = (LON, LAT) in twitter objects. for coordinates = (LAT, LON) see http://support.gnip.com/articles/filtering-twitter-data-by-location.html- Parameters:
p
-hasCoord
-latFirst
- true if type of Point has lat as first field.
-
isValue
public static boolean isValue(jodd.json.JsonObject o) - Parameters:
o
-- Returns:
-
isValue
-
optString
"", null, or "null" checking.- Parameters:
o
-k
-- Returns:
-
getInteger
-
isValue
-
setUser
public void setUser(jodd.json.JsonObject tw_user) -
setPerson
public void setPerson(jodd.json.JsonObject tw_user) -
addTag
add any tag you like. could be hash tags or entities -
addURL
-
getTags
-
getURLs
-
getMentions
Found user screen_names, no user ID- Returns:
- list of found screen names
-
getMentionIDs
fully qualified Twitter user profiles: screen_name : user ID pairings. Multiple screen names could be associated with the same user ID (although not likley in a single tweet)- Returns:
- map
-
addMention
If adding mentions one at a time, then only mention IDS map is used. if profile uid is null, then screen_name, U = null will be mapped- Parameters:
uname
-uid
-
-
parseMentions
Gets a entities.user_mentions from a normal Tweet.- Parameters:
entities
-- Returns:
- map of screen_name to user profile ID
-
parseMentions
From a tweet, get list of "@id"- Parameters:
msg
- tweet or other text- Returns:
-
toString
-
setLanguage
-