Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with final scalastyle assessments: Issue 212 #249

Merged
merged 5 commits into from
Aug 9, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
A few more fixes.
  • Loading branch information
greebie committed Aug 1, 2018
commit bfe2b6e469f4dda13eb5b30f873aee11dfc6f256
13 changes: 9 additions & 4 deletions src/main/scala/io/archivesunleashed/app/NERCombinedJson.scala
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ class NERCombinedJson extends Serializable {
val tmpPath = new Path(tmpFile)

// Merge part-files into single file.
FileUtil.copyMerge(hdfs, srcPath, hdfs, tmpPath, false, hadoopConfig, null)
FileUtil.copyMerge(hdfs, srcPath, hdfs, tmpPath, false, hadoopConfig, "")

// Read file of JSON arrays, write into single JSON array of arrays.
val fsInStream = hdfs.open(tmpPath)
@@ -71,9 +71,14 @@ class NERCombinedJson extends Serializable {
// now is a file of JSON
val outFile = new BufferedWriter(new OutputStreamWriter(fsOutStream))
outFile.write("[")
val line = inFile.readLine()
if (line != null) outFile.write(line)
Iterator.continually(inFile.readLine()).takeWhile(_ != null).foreach(s => {outFile.write(", " + s)})
val line: Option[String] = Option(inFile.readLine())
line match {
case Some(line) =>
outFile.write(line)
case None =>
}
Iterator.continually(inFile.readLine()).takeWhile(Option(_) != None)
.foreach(s => {outFile.write(", " + s)})
outFile.write("]")
outFile.close()

10 changes: 5 additions & 5 deletions src/main/scala/io/archivesunleashed/util/TweetUtils.scala
Original file line number Diff line number Diff line change
@@ -31,15 +31,15 @@ object TweetUtils {
val user = "user"
implicit lazy val formats = org.json4s.DefaultFormats
/** Get Twitter status id. */
def id(): String = try { (tweet \ "id_str").extract[String] } catch { case e: Exception => null}
def id(): String = try { (tweet \ "id_str").extract[String] } catch { case e: Exception => ""}
/** Get the date a status was created. */
def createdAt(): String = try { (tweet \ "created_at").extract[String] } catch { case e: Exception => null}
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 => null}
def text(): String = try { (tweet \ "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 => null}
def lang: String = try { (tweet \ "lang").extract[String] } catch { case e: Exception => ""}
/** Get the username of the user who wrote the status. */
def username(): String = try { (tweet \ user \ "screen_name").extract[String] } catch { case e: Exception => null}
def username(): String = try { (tweet \ user \ "screen_name").extract[String] } catch { case e: Exception => ""}
/** Check if user of status is "verified" (true or false). */
def isVerifiedUser(): Boolean = try { (tweet \ user \ "verified").extract[Boolean] } catch { case e: Exception => false}
/** Get the number of followers the user has. */