Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrigé l'erreur avec intervention_count #24

Merged
merged 5 commits into from
Apr 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions scrapers/parliament-mash/quebec-debates.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
library(dplyr)
status <<- 0
debate_count <<- 0
intervention_count <<- 0
total_intervention_count <<- 0
final_message <<- ""


Expand Down Expand Up @@ -158,6 +158,8 @@ list_urls <- doc_urls[grep("assemblee-nationale/4\\d-\\d/journal-debats", doc_ur
#
for (i in 1:length(list_urls)) {

intervention_count <<- 0
skipped_intervention <- 0
#if (opt$hub_mode != "skip") clessnhub::refresh_token(configuration$token, configuration$url)
if (opt$hub_mode != "skip") clessnhub::connect_with_token(Sys.getenv('HUB_TOKEN'))

Expand Down Expand Up @@ -400,6 +402,7 @@ for (i in 1:length(list_urls)) {
event_sentence_count <- clessnverse::countVecSentences(doc_text) - 1
speech_paragraph_count <- 0

skipped_intervention <- 0
for (j in 1:length(doc_text)) {
#cat(j, intervention_count, "\r")
cat(intervention_count, "\r")
Expand Down Expand Up @@ -468,6 +471,7 @@ for (i in 1:length(list_urls)) {
intervention_text <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", intervention_text, perl=TRUE)
matching_row <- NULL
intervention_count <<- intervention_count - 1
skipped_intervention <<- skipped_intervention + 1
next
}

Expand Down Expand Up @@ -885,15 +889,20 @@ for (i in 1:length(list_urls)) {
} # version finale

} #if (grepl("actualites-salle-presse", event_url))

if (intervention_count > 1) debate_count <- debate_count + 1
clessnverse::logit(scriptname, paste("intervention_count: ", intervention_count), logger)
clessnverse::logit(scriptname, paste("Skipped: ", skipped_intervention), logger)

if (intervention_count > 1) {
debate_count <- debate_count + 1
total_intervention_count <<- total_intervention_count + intervention_count
}

} #for (i in 1:nrow(result))

if (intervention_count < 0) intervention_count <- 0
if (total_intervention_count < 0) total_intervention_count <- 0

clessnverse::logit(scriptname, final_message, logger)
clessnverse::logit(scriptname, paste(debate_count, "debates were added to the hub totalling", intervention_count, "interventions"), logger)
clessnverse::logit(scriptname, paste(debate_count, "debates were added to the hub totalling", total_intervention_count, "interventions"), logger)
clessnverse::logit(scriptname, paste("reaching end of", scriptname, "script"), logger = logger)
logger <- clessnverse::logclose(logger)
quit(save="no", status = status)