From 9eb23515a77a467c1aedb9df5dec40f7c38fb9c6 Mon Sep 17 00:00:00 2001 From: nruest Date: Fri, 10 Aug 2018 08:39:29 -0400 Subject: [PATCH] Add support for full_text in tweets; resolve #192. --- src/main/scala/io/archivesunleashed/util/TweetUtils.scala | 2 ++ src/test/scala/io/archivesunleashed/util/TweetUtilsTest.scala | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/main/scala/io/archivesunleashed/util/TweetUtils.scala b/src/main/scala/io/archivesunleashed/util/TweetUtils.scala index 6e631b15..991a40a6 100644 --- a/src/main/scala/io/archivesunleashed/util/TweetUtils.scala +++ b/src/main/scala/io/archivesunleashed/util/TweetUtils.scala @@ -36,6 +36,8 @@ object TweetUtils { def createdAt(): String = try { (tweet \ "created_at").extract[String] } catch { case e: Exception => ""} /** Get the status text. */ def text(): String = try { (tweet \ "text").extract[String] } catch { case e: Exception => ""} + /** Get the full_text. */ + def fullText(): String = try { (tweet \ "full_text").extract[String] } catch { case e: Exception => ""} /** Get the language code (ISO 639-1). */ def lang: String = try { (tweet \ "lang").extract[String] } catch { case e: Exception => ""} /** Get the username of the user who wrote the status. */ diff --git a/src/test/scala/io/archivesunleashed/util/TweetUtilsTest.scala b/src/test/scala/io/archivesunleashed/util/TweetUtilsTest.scala index 0cc173f9..e78bae73 100644 --- a/src/test/scala/io/archivesunleashed/util/TweetUtilsTest.scala +++ b/src/test/scala/io/archivesunleashed/util/TweetUtilsTest.scala @@ -31,6 +31,7 @@ class TweetUtilsTest extends FunSuite { var tweet:org.json4s.JValue = parse("""{"id_str":"123", "created_at":"20150702", "text": "some text", + "full_text": "some full text", "lang": "en", "user": { "screen_name": "twitteruser", @@ -42,6 +43,7 @@ class TweetUtilsTest extends FunSuite { assert(tweet.id() == "123") assert(tweet.createdAt() == "20150702") assert(tweet.text() == "some text") + assert(tweet.fullText() == "some full text") assert(tweet.lang == "en") assert(tweet.username() == "twitteruser") assert(tweet.isVerifiedUser()) @@ -53,6 +55,7 @@ class TweetUtilsTest extends FunSuite { var tweet:org.json4s.JValue = parse("""{"id_str": null, "created_at":null, "text": null, + "full_text": null, "lang": null, "user": { "screen_name": null, @@ -64,6 +67,7 @@ class TweetUtilsTest extends FunSuite { assert(tweet.id() == null) assert(tweet.createdAt() == null) assert(tweet.text() == null) + assert(tweet.fullText() == null) assert(tweet.lang == null) assert(tweet.username() == null) assert(!tweet.isVerifiedUser())