kbenoit / LIWCalike

R package to extend quanteda to mimic LIWC
36 stars 6 forks source link

Error in dictionary counts #7

Closed HaiyanLW closed 6 years ago

HaiyanLW commented 6 years ago

Error found in dictionary counts:

> txt <- c("The red-shirted lawyer gave her ex-boyfriend $300 out of pity :(.")
> myDict <- dictionary(list(people = c("lawyer", "boyfriend"),
                          colorFixed = "red",
                           colorGlob = "red*",
                           mwe = "out of"))
> liwcalike(txt, myDict, what = "word")
  docname Segment WC meanSentenceLength Sixltr   Dic people colorFixed colorGlob   mwe
1   text1       1 18                 12  11.11 27.78  11.11      5.556     5.556 5.556
  AllPunc Period Comma Colon SemiC QMark Exclam  Dash Quote Apostro Parenth OtherP
1   27.78  5.556     0 5.556     0     0      0 11.11     0       0       0  11.11

if text2 is added, dictionary counts for text1 changed:

> txt <- c("The red-shirted lawyer gave her ex-boyfriend $300 out of pity :(.",
           "The green-shirted lawyer gave her $300 out of pity :(.")
> liwcalike(txt, myDict, what = "word")
  docname Segment WC WPS Sixltr   Dic people colorFixed colorGlob   mwe AllPunc
1   text1       1 18  12 11.111 27.78 11.111      5.556     6.667 6.667   27.78
2   text2       2 15  10  6.667 13.33  5.556      0.000     0.000 6.667   26.67
  Period Comma Colon SemiC QMark Exclam   Dash Quote Apostro Parenth OtherP
1  5.556     0 5.556     0     0      0 11.111     0       0       0  11.11
2  6.667     0 6.667     0     0      0  6.667     0       0       0  13.33