Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
Last active December 10, 2023 08:48
Show Gist options
  • Save MattCowgill/1afc2888da4e05eec0f88d48867f9b31 to your computer and use it in GitHub Desktop.
Save MattCowgill/1afc2888da4e05eec0f88d48867f9b31 to your computer and use it in GitHub Desktop.
library(text)
library(tidyverse)
textrpp_install()
textrpp_initialize()
earnings_call_text <- "But we were very conscious that we wanted the skills back, we wanted the people back. And pleasingly, on pilots, on engineers, we - and a lot of our international cabin crew, we've gotten people back, they haven't been lost. We've had an issue with Jetstar cabin crew where people have gone on to other professions, and we've been retraining and recruiting in that space. But our biggest issue has been on head office staff where we've gotten big turnovers of people in some areas like the technology area."
pre_defined_topics <- c("hiring difficulties",
"labour costs increasing",
"transportation costs increasing",
"import costs increasing",
"general input costs increasing",
"final prices increasing",
"consumer demand increasing",
"supply shortages",
"labour costs decreasing",
"transportation costs decreasing",
"import costs decreasing",
"general input costs decreasing",
"final prices decreasing",
"consumer demand decreasing")
zs <- textZeroShot(earnings_call_text,
pre_defined_topics,
model = "facebook/bart-large-mnli",
multi_label = TRUE)
zs |>
as_tibble() |>
mutate(across(everything(), as.character)) |>
pivot_longer(cols = !sequence,
names_to = c("scores", "values"),
names_sep = "_x_") |>
pivot_wider(names_from = scores,
values_from = value) |>
arrange(desc(scores)) |>
select(labels, scores)
@MattCowgill
Copy link
Author

MattCowgill commented Dec 9, 2023

@MattCowgill
Copy link
Author

Screenshot 2023-12-09 at 2 55 23 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment