rm(list = ls())
library(jsonlite)
library(ggplot2)
library(tidyr)
source("../helper/useful.R")

raw.data.path <- "../../production-results/"

## LOOP TO READ IN FILES
all.data <- data.frame()
files <- dir(raw.data.path,pattern="*.json")

for (file.name in files) {
  print(file.name)
  
  ## these are the two functions that are most meaningful
  json_file <- readLines(paste(raw.data.path,file.name,sep=""))
  json_file_str = paste(json_file, collapse = "")
  json_file_str = gsub(",}", "}", json_file_str)
  jso = jsonlite::fromJSON(json_file_str)
  jso1 <- data.frame(jso)
  jso1$subid <- substring(file.name, 1, 6)
  
  ## now here's where data get bound together
  all.data <- rbind(all.data, jso1)
}
## [1] "304SM51WA34HRGX90JNLUEAQV68SBE.json"
## [1] "30BUDKLTXDVESHBIYEC32B6JKLXE5M.json"
## [1] "30H4UDGLT2IGXFLEZR90DPG9KNPMP5.json"
## [1] "30LSNF239UVY9PUHCE0WPJ1ZS4C2IH.json"
## [1] "32RIADZISS4X6HC0L4DYM04KLGAS4V.json"
## [1] "333U7HK6I9FH7AC3RL5DX3732ATJDM.json"
## [1] "33PPO7FECVFLCZSX93KDL2S3PV0DI0.json"
## [1] "354GIDR5ZB6G6KANT17C0R8O9CE003.json"
## [1] "35BLDD71I6XT16HT0S8TRJ10LF7VZF.json"
## [1] "35L9RVQFCOI7X6SZPGSHVQVCBIHUHZ.json"
## [1] "35L9RVQFCOI7X6SZPGSHVQVCBILHUQ.json"
## [1] "36W0OB37HWEOJ5M9V3RPCIARD0WZHT.json"
## [1] "378XPAWRUCDNESPLPTTBV1KX4S7IA7.json"
## [1] "37W3JXSD6686B57TUGB6ZEBCMU4WYY.json"
## [1] "38YMOXR4MUZ4SLXNOXGEGNRJNKFW62.json"
## [1] "39GHHAVOMFR47ETAYA4KUZDXPX04JU.json"
## [1] "3A1COHJ8NJV9Z9LMMDRCZYDNERRH88.json"
## [1] "3C8HJ7UOP7UABJNKM0724NINUMXMZR.json"
## [1] "3E1QT0TDFP99V4W6SV9XZAE2E468IS.json"
## [1] "3EFVCAY5L395QFGCADUXBBT2RJW8J5.json"
## [1] "3FTF2T8WLRIRA4ZLM4JQ0XILDLK9WN.json"
## [1] "3G5W44VEU7IFUESCBW6X43ADUR9KGW.json"
## [1] "3GNA64GUZE43PK1N7573WSVX3M1Q5M.json"
## [1] "3GU1KF0O4I1KEOHH82JRZ95F8OMPBK.json"
## [1] "3I2PTA7R3TU673MQESB9YHEF0CWKQ1.json"
## [1] "3I2PTA7R3TU673MQESB9YHEF0EHQKW.json"
## [1] "3IUZPWIU1O7BR0ICQ1AFQ6W1OFWKWS.json"
## [1] "3JAOYWH7VI4BZANMIQCORM15FEI9LW.json"
## [1] "3JMSRU9HQIUVQBQX45UG690IX90VEB.json"
## [1] "3KB8R4ZV1E7E1BOI5JT450RN7XYGB6.json"
## [1] "3KIBXJ1WD5U3MR9AZFJ59CJFLDXKOG.json"
## [1] "3LJ7UR74RHD0Q4KVD8WCN6UEYH24NV.json"
## [1] "3MAOD8E57QARO685XJYHKHRCRANNX5.json"
## [1] "3MTMREQS4VI5FN9QEAXQWST5J32AW3.json"
## [1] "3N4BPTXIO8SYZWT7V1VE8IB43ZMUK4.json"
## [1] "3NGI5ARFTT5J1QZP65Q2TXS6MCTP1Z.json"
## [1] "3NXNZ5RS1AXCKPYKEWBE8HJ4KUB97L.json"
## [1] "3OCHAWUVGOKQG0N20661SPA8XH4XK0.json"
## [1] "3OWEPKL089CX9R2EF6UJQIEOPJU7NK.json"
## [1] "3PDJHANYK5GMVV2YTYUEFKHW8W26HC.json"
## [1] "3QEMNNSB2XZONFB1QCGGUD2UBFPD75.json"
## [1] "3R08VXYT7CVNWLBS77L6M1RFIVX7WA.json"
## [1] "3RYC5T2D73T7UVY64Z5HZOAJQAORPY.json"
## [1] "3TYCR1GOTCJQ515ZMO6N4A3YUH8LZP.json"
## [1] "3U84XHCDICDU7TYEGW76IT1N8TS4ZQ.json"
## [1] "3VSOLARPKB9UJ6XXCK8OV07OFSS39D.json"
## [1] "3W2LOLRXLBF6J41QR70937OKW0JKRR.json"
## [1] "3WMOAN2SRBXZKH3AX4XZWWURB11VN0.json"
## [1] "3WSELTNVR32DN65WJ5SF98M6F9LATE.json"
## [1] "3YGXWBAF70HHZ0N4OINY7V02ZDS4CH.json"
## [1] "3YMTUJH0DSGYLHPFA4IOW506NZP4TX.json"
## [1] "3Z4XG4ZF48R6LZL1RH9Y2K1H2H8X8F.json"
## [1] "3ZQIG0FLQEGP7BCOP5OMSF7I4D2WVP.json"
## [1] "3ZQIG0FLQEGP7BCOP5OMSF7I4D5VWR.json"
levels(all.data$answer.scale) <- c("hateA_alsoHateB", "hateA_butLoveB", "loveA_butHateB", "loveA_alsoLoveB", "someHate_alsoAllHate", "someHate_butNotAllHate", "someLove_butNotAllLove", "someLove_alsoAllLove", "training1", "training2")
levels(all.data$answer.judgment) <- c("No", "Maybe", "Yes")

Filter out participants and clean up.

d <- all.data %>%
  select(subid, answer.scale, answer.judgment) %>%
  rename(judgment = answer.judgment) %>%
  filter(answer.scale != "training1" & answer.scale != "training2") %>%
  separate(answer.scale, into = c("utterance", "inference"), sep = "_") 

d$inference <- as.factor(d$inference)

d <- d %>%
  mutate(bound = factor(substring(inference, 1, 3),
                           levels = c("als", "but"),
                           labels = c("also  (lower)", "but not  (upper)")),
         scale = factor(as.numeric(grepl("some", utterance)), 
                        levels = c(0, 1), 
                        labels = c("ad-hoc","scalar")),
         utt_valence = factor(as.numeric(grepl("love", utterance, 
                                               ignore.case=TRUE)), 
                            levels = c(0, 1), 
                            labels = c("hate", "love")),
         inf_valence = factor(as.numeric(grepl("love", inference, 
                                               ignore.case=TRUE)), 
                            levels = c(0, 1), 
                            labels = c("hate", "love")),
         condition = str_c(utt_valence, "-", inf_valence))

Scalar inferences

Prediction - “but not all” infrence should be cancelled in the face-threatening context (hate-hate). In contrast, should be stronger in the love-love hypothesis

Not sure what the prediction is for the “also all” condition. Should probably be the flip?

qplot(judgment, fill = condition, position = "dodge", 
      data = filter(d, scale == "scalar")) + 
  facet_grid(~bound)

plot of chunk unnamed-chunk-3

We find little support for this hypothesis, but there is a trend in this direction, perhaps.

Ad hocs

Prediction - in face-threatening context, inference should be cancelled. So:

qplot(judgment, fill = bound, position = "dodge", 
      data = filter(d, scale == "ad-hoc")) + 
  facet_grid(~condition)

plot of chunk unnamed-chunk-4

These predictions aren’t exactly satisfied, but certainly the number of “maybes” is very different in the love scenarios than the hate scenarios.

```