Question: ```
ArrayList storeList = new ArrayList<USCrimeClass>;
FileInputStream fstream = new FileInputStream(inFile);
try ( // Get the object of DataInputStream
           DataInputStream in = new DataInputStream(fstream)) {
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    // Read File Line By Line
    strLine = br.readLine();// skip first line
    while ((strLine = br.readLine()) != null) {
          // lines
          storeList.add(storeToCrimeObjin(strLine));
    }
    // Close the input stream

```

Answer: 
This would be a great use case for tidy data principles. Let's set up some example data (these are real tweets of mine).

```r
library(tidytext)
library(tidyverse)

tweets <- tribble(
    ~tweetID, ~TweetText,
    1, "Was Julie helping me because I don't know anything about Python package management? Yes, yes, she was.",
    2, "@darinself OMG, this is my favorite.",
    3, "@treycausey @ftrain THIS IS AMAZING.",
    4, "@nest No, no, not in error. Just the turkey!",
    5, "The @nest people should write a blog post about how many smoke alarms went off yesterday. (I know ours did.)")

```

Now we have some example data. In the code below, `unnest_tokens()` tokenizes the text, i.e. breaks it up into individual words (the tidytext package allows you to use a special tokenizer for tweets) and the `inner_join()` implements the sentiment analysis.

```r
tweet_sentiment <- tweets %>%
    unnest_tokens(word, TweetText, token = "tweets") %>%
    inner_join(get_sentiments("afinn"))
#> Joining, by = "word"

```

Now we can find the scores for each tweet. Take the original data set of tweets and `left_join()` on to it the `sum()` of the scores for each tweet. The handy function `replace_na()` from tidyr lets you replace the resulting `NA` values with zero.

```r
tweets %>%
    left_join(tweet_sentiment %>%
                  group_by(tweetID) %>%
                  summarise(score = sum(score))) %>%
    replace_na(list(score = 0))
#> Joining, by = "tweetID"
#> # A tibble: 5 x 3
#>   tweetID TweetText                                                  score
#>     <dbl> <chr>                                                      <dbl>
#> 1      1. Was Julie helping me because I don't know anything about …    4.
#> 2      2. @darinself OMG, this is my favorite.                          2.
#> 3      3. @treycausey @ftrain THIS IS AMAZING.                          4.
#> 4      4. @nest No, no, not in error. Just the turkey!                 -4.
#> 5      5. The @nest people should write a blog post about how many …    0.

```

Created on 2018-05-09 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0).

If you are interested in sentiment analysis and text mining, I invite you to check out the [extensive documentation and tutorials we have for tidytext](https://www.tidytextmining.com/).
For future reference:

```
Score_word <- function(x) {
  word_bool_vec <- get_sentiments("afinn")$word==x
  score <- get_sentiments("afinn")$score[word_bool_vec]
  return (score) }    

Score_tweet <- function(sentence) {
  words <- unlist(strsplit(sentence, " "))
  words <- as.vector(words)
  scores <- sapply(words, Score_word)
  scores <- unlist(scores)
  Score_tweet <- sum(scores)
  return (Score_tweet)
  }     

dsMyTweets$score<-apply(df, 1, Score_tweet)

```

This executes what I initially wanted! :)