public static Tweet parseTweet(JSONObject input) { // Example of a tweet in JSON format: // https://dev.twitter.com/docs/api/1/get/search // logger.info("parsing as twitter doc"); try { Tweet t = new Tweet(); JSONObject user; user = input.getJSONObject("user"); t.userID = user.getLong("id"); t.text = input.getString("text"); t.isRetweet = !input.isNull("retweeted_status"); t.setDoctype(DocumentType.TWIITER_DOC); if (input.has("coordinates") && !input.isNull("coordinates")) { JSONObject geo = (JSONObject) input.getJSONObject("coordinates"); if (geo.getString("type") == "Point") { JSONArray coords = geo.getJSONArray("coordinates"); GeoLabel.LonLatPair geotag = new GeoLabel.LonLatPair(); geotag.setLongitude(coords.getDouble(0)); geotag.setLatitude(coords.getDouble(1)); } } return t; } catch (JSONException e) { logger.error("Json exception in parsing tweet: " + input); logger.error(elog.toStringException(e)); throw new RuntimeException(e); } }