Title: | Identify Text Written by Large Language Models using 'GPTZero' |
Version: | 0.0.1 |
Description: | An R interface to the 'GPTZero' API (https://gptzero.me/docs). Allows users to classify text into human and computer written with probabilities. Formats the data into data frames where each sentence is an observation. Paragraph-level and document-level predictions are organized to align with the sentences. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
URL: | https://github.com/christopherkenny/gptzeror, https://christophertkenny.com/gptzeror/ |
BugReports: | https://github.com/christopherkenny/gptzeror/issues |
Imports: | cli, curl, dplyr, httr2, lifecycle, tidyr |
Suggests: | httptest2, testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2023-06-02 17:05:39 UTC; chris |
Author: | Christopher T. Kenny
|
Maintainer: | Christopher T. Kenny <christopherkenny@fas.harvard.edu> |
Repository: | CRAN |
Date/Publication: | 2023-06-05 08:30:02 UTC |
gptzeror: Identify Text Written by Large Language Models using 'GPTZero'
Description
An R interface to the 'GPTZero' API (https://gptzero.me/docs). Allows users to classify text into human and computer written with probabilities. Formats the data into data frames where each sentence is an observation. Paragraph-level and document-level predictions are organized to align with the sentences.
Author(s)
Maintainer: Christopher T. Kenny christopherkenny@fas.harvard.edu (ORCID)
See Also
Useful links:
Report bugs at https://github.com/christopherkenny/gptzeror/issues
Predict if a file was generated by AI
Description
Predict if a file was generated by AI
Usage
gptzero_predict_file(file)
Arguments
file |
file to upload |
Value
a tibble of sentence-level assessments
Examples
# Requires API Key
abstr <- 'Congressional district lines in many U.S. states are drawn by partisan
actors, raising concerns about gerrymandering. To separate the partisan effects
of redistricting from the effects of other factors including geography and
redistricting rules, we compare possible party compositions of the U.S. House
under the enacted plan to those under a set of alternative simulated plans
that serve as a non-partisan baseline. We find that partisan gerrymandering
is widespread in the 2020 redistricting cycle, but most of the electoral bias
it creates cancels at the national level, giving Republicans two additional
seats on average. Geography and redistricting rules separately contribute a
moderate pro-Republican bias. Finally, we find that partisan gerrymandering
reduces electoral competition and makes the partisan composition of the U.S. House
less responsive to shifts in the national vote.'
abstr <- gsub('\\n', ' ', abstr) # remove the "\n"s
fake_abstr <- 'The 2020 congressional redistricting process in the United States
has been marked by widespread partisan gerrymandering, which has led to concerns
about its impact on electoral outcomes and democratic representation. This paper
examines the effects of partisan gerrymandering on electoral competition in the
2020 congressional elections. Using data from previous election cycles and
simulations of the 2020 elections, we find that while partisan gerrymandering
mostly cancels out at the national level, it reduces competition in individual
districts, making them less competitive and reducing voter choice. We also find
that the impact of gerrymandering on electoral outcomes varies significantly
by state and political party, suggesting that redistricting can have significant
implications for democratic representation and political power in the United
States. The findings of this study have important implications for policymakers,
as well as advocates of fair and democratic elections.'
fake_abstr <- gsub('\\n', ' ', fake_abstr) # remove the "\n"s
tf_abstr <- tempfile(fileext = '.txt')
cat(abstr, file = tf_abstr)
tf_fake <- tempfile(fileext = '.txt')
cat(fake_abstr, file = tf_fake)
gptzero_predict_file(tf_abstr)
gptzero_predict_file(tf_fake)
Predict if text was generated by AI
Description
Predict if text was generated by AI
Usage
gptzero_predict_text(text)
Arguments
text |
text to upload |
Value
a tibble of sentence-level assessments
Examples
# Requires API Key
abstr <- 'Congressional district lines in many U.S. states are drawn by partisan
actors, raising concerns about gerrymandering. To separate the partisan effects
of redistricting from the effects of other factors including geography and
redistricting rules, we compare possible party compositions of the U.S. House
under the enacted plan to those under a set of alternative simulated plans
that serve as a non-partisan baseline. We find that partisan gerrymandering
is widespread in the 2020 redistricting cycle, but most of the electoral bias
it creates cancels at the national level, giving Republicans two additional
seats on average. Geography and redistricting rules separately contribute a
moderate pro-Republican bias. Finally, we find that partisan gerrymandering
reduces electoral competition and makes the partisan composition of the U.S. House
less responsive to shifts in the national vote.'
abstr <- gsub('\\n', ' ', abstr) # remove the "\n"s
gptzero_predict_text(abstr)
Add GPTZero API key to .Renviron.
Description
Add GPTZero API key to .Renviron.
Usage
gptzero_set_key(key, overwrite = FALSE, install = FALSE)
Arguments
key |
Character. API key to add to add. |
overwrite |
Defaults to FALSE. Boolean. Should existing |
install |
Defaults to FALSE. Boolean. Should this be added '~/.Renviron' file? |
Value
key, invisibly
Examples
## Not run:
gptzero_set_key('1234')
## End(Not run)
Check or Get GPTZero API Key
Description
Check or Get GPTZero API Key
Usage
gptzero_has_key()
gptzero_get_key()
Value
logical if has
, key invisibly if get
Examples
gptzero_has_key()