Class Tweet

java.lang.Object
org.opensextant.data.social.Message
org.opensextant.data.social.Tweet

public class Tweet extends Message
  • Field Details

  • Constructor Details

    • Tweet

      public Tweet()
    • Tweet

      public Tweet(String sid)
    • Tweet

      public Tweet(String _id, String text, Date tm)
  • 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

      public void setGeoMethod(String m)
    • getGeoMethod

      public String getGeoMethod()
      TODO: this is not clear.
      Returns:
    • applyGenericRules

      public void applyGenericRules()
    • fixNull

      public static String fixNull(String v)
    • setDate

      public void setDate(long d)
      Set the date and an the standard "CREATED_AT" date/time format.
      Parameters:
      d - epoch
    • getISOTimestamp

      public String getISOTimestamp()
    • parseId

      public static String parseId(String gnipId)
      Most commonly needed to parse TweetID from a GnipID
      Parameters:
      gnipId -
      Returns:
    • parseIds

      protected String parseIds(Map<?,?> tw) throws MessageParseException
      Find a best ID from many possible places where ID, id, id_str, etc, reside.
      Parameters:
      tw -
      Returns:
      Throws:
      MessageParseException
    • fromJSON

      public void fromJSON(jodd.json.JsonObject tw) throws MessageParseException
      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

      protected void parseDate(Map<?,?> tw)
    • parseText

      protected void parseText(Map<?,?> tw) throws MessageParseException
      Throws:
      MessageParseException
    • parseLanguage

      public void parseLanguage(String lg)
    • parseURLs

      public void parseURLs(List<?> jsonArray)
      supports gnip.urls or topsy.urls fields
      Parameters:
      jsonArray -
    • setUserGeo

      public static boolean setUserGeo(jodd.json.JsonObject json, Tweet tw)
      Parameters:
      json -
      tw -
      Returns:
      true if a location metadata was found and set.
    • setStatusGeo

      public static void setStatusGeo(jodd.json.JsonObject json, Tweet tw)
      TODO: investigate how close a user Profile geo compares with Status geo.
      Parameters:
      json -
      tw -
    • setPlace

      protected static void setPlace(Place p, jodd.json.JsonObject aPlace)
      Parameters:
      p -
      aPlace -
    • setLatLon

      protected static void setLatLon(Place p, jodd.json.JsonObject hasCoord, boolean latFirst)
      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

      public static boolean isValue(List<?> o)
    • optString

      public static String optString(jodd.json.JsonObject o, String k)
      "", null, or "null" checking.
      Parameters:
      o -
      k -
      Returns:
    • getInteger

      public static int getInteger(jodd.json.JsonObject o, String k, int defVal)
    • isValue

      public static boolean isValue(String o)
    • setUser

      public void setUser(jodd.json.JsonObject tw_user)
    • setPerson

      public void setPerson(jodd.json.JsonObject tw_user)
    • addTag

      public void addTag(String t)
      add any tag you like. could be hash tags or entities
    • addURL

      public void addURL(String url)
    • getTags

      public Collection<String> getTags()
    • getURLs

      public Collection<String> getURLs()
    • getMentions

      public Collection<String> getMentions()
      Found user screen_names, no user ID
      Returns:
      list of found screen names
    • getMentionIDs

      public List<Tweet.Mention> 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

      public void addMention(String uname, String uid)
      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

      public List<Tweet.Mention> parseMentions(jodd.json.JsonObject entities)
      Gets a entities.user_mentions from a normal Tweet.
      Parameters:
      entities -
      Returns:
      map of screen_name to user profile ID
    • parseMentions

      public static Set<String> parseMentions(String msg)
      From a tweet, get list of "@id"
      Parameters:
      msg - tweet or other text
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setLanguage

      public void setLanguage(String l)