W_A <- c(1, 0, 1)
W_B <- c(0, 1, 2)
cosine_similarity <- sum(W_A * W_B) / (sqrt(sum(W_A^2)) * sqrt(sum(W_B^2)))
cosine_similarity[1] 0.6324555
POP77142 Quantitative Text Analysis for Social Scientists
federalist.csv file on Blackboard.NA in the author column).# A tibble: 6 × 4
paper_number paper_numeric author text
<chr> <dbl> <chr> <chr>
1 No. 1 1 hamilton "AFTER an unequivocal experience of the i…
2 No. 2 2 jay "WHEN the people of America reflect that …
3 No. 3 3 jay "IT IS not a new observation that the peo…
4 No. 4 4 jay "MY LAST paper assigned several reasons w…
5 No. 5 5 jay "QUEEN ANNE, in her letter of the 1st Jul…
6 No. 6 6 hamilton "THE three last numbers of this paper hav…
ireland_ge_2020-24_manifestos.csv containing the manifestos for 2020 and 2024 General elections.spc_tbl_ [17 × 3] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
$ party: chr [1:17] "AO" "FF" "FG" "GR" ...
$ year : num [1:17] 2024 2024 2024 2024 2024 ...
$ text : chr [1:17] "Our\nCommon Sense\n Manifesto 2024\n\n Opening statement\nIn the last year Aontú has come of ag"| __truncated__ "MOVING FORWARD. TOGETHER.\n\nAG BOGADH AR AGHAIDH. LE CHÉILE.\nGeneral Election Manifesto 2024\n\n\n\n\n "| __truncated__ "General Election 2024\n M A N I F E S TO\n 1\n\nFINE GAEL | GENERAL ELECTION MANIFESTO"| __truncated__ "towards\n2030\na decade of change\nvolume II\nGreen Party Manifesto 2024\n\n\n\n\n greens\n "| __truncated__ ...
- attr(*, "spec")=
.. cols(
.. party = col_character(),
.. year = col_double(),
.. text = col_character()
.. )
- attr(*, "problems")=<externalptr>