├── .Rproj.user ├── 13C1E41B │ ├── cpp-definition-cache │ ├── sources │ │ ├── prop │ │ │ ├── 70748252 │ │ │ ├── 3A554BED │ │ │ ├── 81F15E49 │ │ │ ├── 98362BB0 │ │ │ ├── 9C17EFEB │ │ │ ├── C49A433B │ │ │ ├── EF665877 │ │ │ ├── FC7E3854 │ │ │ ├── D45C3F3F │ │ │ ├── 92F868AD │ │ │ ├── B92ACAA8 │ │ │ └── INDEX │ │ └── s-7995746f │ │ │ ├── lock_file │ │ │ ├── 42A53D5D-contents │ │ │ ├── 42A53D5D │ │ │ ├── AB3CF3D0 │ │ │ ├── AB3CF3D0-contents │ │ │ └── 1B121EF6-contents │ ├── saved_source_markers │ ├── pcs │ │ ├── source-pane.pper │ │ ├── workbench-pane.pper │ │ ├── debug-breakpoints.pper │ │ ├── files-pane.pper │ │ ├── source-window.pper │ │ └── windowlayoutstate.pper │ ├── console06 │ │ ├── INDEX001 │ │ ├── BBE25B02.env │ │ └── BBE25B02 │ └── persistent-state └── shared │ └── notebooks │ ├── patch-chunk-names │ ├── D348B128-README │ └── 1 │ │ ├── s │ │ └── chunks.json │ │ └── 13C1E41B7995746f │ │ └── chunks.json │ └── paths ├── LICENSE ├── .Rbuildignore ├── .Rprofile ├── R ├── utils.R ├── stf_thesaurus.R ├── stf_help_view.R ├── stfstj.R ├── stf_acompanhamento.R ├── stf_thesaurusDF.R ├── stf_opinion.R ├── stj_mono_metadata.R ├── stj_opinion_metadata.R ├── stf__opinion_metadata.R └── stf_mono_metadata.R ├── NAMESPACE ├── .travis.yml ├── man ├── stf_thesaurus.Rd ├── stf_help_view.Rd ├── stf_thesaurusDF.Rd ├── stj_opinion_metadata.Rd ├── stf_mono_metadata.Rd ├── stj_mono_metadata.Rd ├── stf_opinion_metadata.Rd ├── stf_opinion.Rd └── stj_metadata.Rd ├── DESCRIPTION ├── appveyor.yml ├── LICENSE.md ├── README.md └── README.Rmd /.Rproj.user/13C1E41B/cpp-definition-cache: -------------------------------------------------------------------------------- 1 | [ 2 | ] -------------------------------------------------------------------------------- /.Rproj.user/shared/notebooks/patch-chunk-names: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/70748252: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/s-7995746f/lock_file: -------------------------------------------------------------------------------- 1 | 19233 -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/saved_source_markers: -------------------------------------------------------------------------------- 1 | {"active_set":"","sets":[]} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2017 2 | COPYRIGHT HOLDER: Associação Brasileira de Jurimetria 3 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/pcs/source-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "activeTab" : 0, 3 | "activeTabSourceWindow1" : 0 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/3A554BED: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "6,0", 3 | "scrollLine" : "1" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/81F15E49: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "9,0", 3 | "scrollLine" : "1" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/98362BB0: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "32,0", 3 | "scrollLine" : "24" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/9C17EFEB: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "6,0", 3 | "scrollLine" : "0" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/C49A433B: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "16,0", 3 | "scrollLine" : "11" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/EF665877: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "7,9", 3 | "scrollLine" : "2" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/FC7E3854: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "4,28", 3 | "scrollLine" : "3" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/shared/notebooks/D348B128-README/1/s/chunks.json: -------------------------------------------------------------------------------- 1 | {"chunk_definitions":[],"doc_write_time":1520301949} -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/D45C3F3F: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "111,0", 3 | "scrollLine" : "105" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/shared/notebooks/D348B128-README/1/13C1E41B7995746f/chunks.json: -------------------------------------------------------------------------------- 1 | {"chunk_definitions":[],"doc_write_time":1520301949} -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/pcs/workbench-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "TabSet1" : 4, 3 | "TabSet2" : 0, 4 | "TabZoom" : { 5 | } 6 | } -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^README\.Rmd$ 5 | ^README-.*\.png$ 6 | ^LICENSE\.md$ 7 | ^appveyor\.yml$ 8 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/pcs/debug-breakpoints.pper: -------------------------------------------------------------------------------- 1 | { 2 | "debugBreakpointsState" : { 3 | "breakpoints" : [ 4 | ] 5 | } 6 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/92F868AD: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "6,15", 3 | "scrollLine" : "0", 4 | "tempName" : "Untitled2" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/B92ACAA8: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "0,0", 3 | "scrollLine" : "0", 4 | "tempName" : "Untitled2" 5 | } -------------------------------------------------------------------------------- /.Rprofile: -------------------------------------------------------------------------------- 1 | Sys.setenv(PATH=paste("/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","/usr/local/texlive/2017/bin/x86_64-linux",sep=":")) 2 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/pcs/files-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "path" : "~/pacotes/pacotes2", 3 | "sortOrder" : [ 4 | { 5 | "ascending" : true, 6 | "columnIndex" : 2 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | # Extracts dates in Portuguese formats from strings and convert them to class Date. 2 | pt_time_extract<-function(string){ 3 | string %>% 4 | stringr::str_extract("\\d{2}/\\d{2}/\\d+") %>% 5 | lubridate::dmy() 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/s-7995746f/42A53D5D-contents: -------------------------------------------------------------------------------- 1 | library(stfstj) 2 | 3 | pesquisa_livre<-"TELEFONICA+ADJ+BRASIL" 4 | 5 | urls<-stf_urls(pesquisa_livre) 6 | 7 | base<-stf_metadados(urls) 8 | 9 | acordaos<-stf_acordaos(base[1,c(17,9)]) 10 | 11 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/pcs/source-window.pper: -------------------------------------------------------------------------------- 1 | { 2 | "sourceWindowGeometry" : { 3 | "wqoe0qvfe3jg1" : { 4 | "height" : 658, 5 | "ordinal" : 1, 6 | "width" : 1342, 7 | "x" : -7, 8 | "y" : 23 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /.Rproj.user/shared/notebooks/paths: -------------------------------------------------------------------------------- 1 | /home/rstudio/pacotes/stfstj/.travis.yml="3DA17931" 2 | /home/rstudio/pacotes/stfstj/DESCRIPTION="735807E5" 3 | /home/rstudio/pacotes/stfstj/NAMESPACE="1A830E67" 4 | /home/rstudio/pacotes/stfstj/R/stf_acompanhamento.R="487EA65A" 5 | /home/rstudio/pacotes/stfstj/R/stfstj.R="51E277AC" 6 | /home/rstudio/pacotes/stfstj/README.Rmd="D348B128" 7 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(stf_acompanhamento) 4 | export(stf_help_view) 5 | export(stf_mono_metadata) 6 | export(stf_opinion) 7 | export(stf_opinion_metadata) 8 | export(stf_thesaurus) 9 | export(stj_mono_metadata) 10 | export(stj_opinion_metadata) 11 | importFrom(dplyr,"%>%") 12 | importFrom(purrr,"%||%") 13 | importFrom(utils,URLencode) 14 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/pcs/windowlayoutstate.pper: -------------------------------------------------------------------------------- 1 | { 2 | "left" : { 3 | "panelheight" : 538, 4 | "splitterpos" : 245, 5 | "topwindowstate" : "NORMAL", 6 | "windowheight" : 612 7 | }, 8 | "right" : { 9 | "panelheight" : 538, 10 | "splitterpos" : 369, 11 | "topwindowstate" : "NORMAL", 12 | "windowheight" : 612 13 | } 14 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/console06/INDEX001: -------------------------------------------------------------------------------- 1 | [{"allow_restart":true,"alt_buffer":false,"autoclose":1,"buffered_output":"\n\n\n","caption":"Terminal 1","channel_id":"5596","channel_mode":1,"child_procs":false,"cols":80,"cwd":"~/pacotes/stfstj","exit_code":null,"handle":"BBE25B02","interaction_mode":2,"max_output_lines":1000,"restarted":true,"rows":11,"shell_type":7,"show_on_output":false,"terminal_sequence":1,"title":"rstudio@s2assessoria: ~/pacotes/stfstj","track_env":true,"zombie":false}] -------------------------------------------------------------------------------- /R/stf_thesaurus.R: -------------------------------------------------------------------------------- 1 | #' Function stf_thesaurus 2 | #' 3 | #' This function displays STF's thesaurus. 4 | #' @keywords stf, thesaurus 5 | #' @return This function has only side effect, it doesn't return anything. 6 | #' @examples 7 | #' \dontrun{ 8 | #' stf_thesaurus() 9 | #' } 10 | 11 | #' @export 12 | stf_thesaurus<-function(){ 13 | url<-"http://www.stf.jus.br/portal/jurisprudencia/pesquisarVocabularioJuridico.asp" 14 | getOption("viewer")(url) 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | 7 | 8 | # Prevents Travis timeout for building 9 | 10 | before_install: 11 | - sudo apt-get --yes --force-yes update -qq 12 | 13 | addons: 14 | apt: 15 | packages: 16 | - libtesseract-dev 17 | - libleptonica-dev 18 | - tesseract-ocr-eng 19 | - tesseract-ocr-por 20 | - libpoppler-cpp-dev 21 | - libxml2-dev 22 | 23 | 24 | -------------------------------------------------------------------------------- /man/stf_thesaurus.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stf_thesaurus.R 3 | \name{stf_thesaurus} 4 | \alias{stf_thesaurus} 5 | \title{Function stf_thesaurus} 6 | \usage{ 7 | stf_thesaurus() 8 | } 9 | \value{ 10 | This function has only side effect, it doesn't return anything. 11 | } 12 | \description{ 13 | This function displays STF's thesaurus. 14 | } 15 | \examples{ 16 | \dontrun{ 17 | stf_thesaurus() 18 | } 19 | } 20 | \keyword{stf,} 21 | \keyword{thesaurus} 22 | -------------------------------------------------------------------------------- /man/stf_help_view.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stf_help_view.R 3 | \name{stf_help_view} 4 | \alias{stf_help_view} 5 | \title{Function stf_help_view} 6 | \usage{ 7 | stf_help_view() 8 | } 9 | \value{ 10 | This function has only side effect, it doesn't return anything. 11 | } 12 | \description{ 13 | This function displays STF's help page on Rstudio viewer pane. 14 | } 15 | \examples{ 16 | \dontrun{ 17 | stf_help_view() 18 | } 19 | } 20 | \keyword{help} 21 | \keyword{stf,} 22 | -------------------------------------------------------------------------------- /R/stf_help_view.R: -------------------------------------------------------------------------------- 1 | #' Function stf_help_view 2 | #' 3 | #' This function displays STF's help page on Rstudio viewer pane. 4 | #' @keywords stf, help 5 | #' @return This function has only side effect, it doesn't return anything. 6 | #' @examples 7 | #' \dontrun{ 8 | #' stf_help_view() 9 | #' } 10 | 11 | #' @export 12 | stf_help_view<-function(){ 13 | url<-"http://www.stf.jus.br/portal/cms/verTexto.asp?servico=jurisprudenciaPesquisaGeral&pagina=ajudaPesquisaJurisprudencia&popup=S" 14 | getOption("viewer")(url) 15 | 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /R/stfstj.R: -------------------------------------------------------------------------------- 1 | #' \code{stfstj} package 2 | #' 3 | #' Baixar dados do STF e do STJ 4 | #' 5 | #' 6 | #' @docType package 7 | #' @name stfstj 8 | #' @importFrom dplyr %>% 9 | #' @importFrom purrr %||% 10 | #' @importFrom utils URLencode 11 | NULL 12 | 13 | ## quiets concerns of R CMD check re: the .'s that appear in pipelines 14 | if(getRversion() >= "2.15.1") 15 | utils::globalVariables(c(".", ".x", "y", "z", "field", "phrase", 16 | "search_time","pages","h","path", 17 | "parts_names", "stf_urls")) 18 | -------------------------------------------------------------------------------- /man/stf_thesaurusDF.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stf_thesaurusDF.R 3 | \name{stf_thesaurusDF} 4 | \alias{stf_thesaurusDF} 5 | \title{Function stf_thesaurusDF} 6 | \usage{ 7 | stf_thesaurusDF(letter = "", term = "") 8 | } 9 | \arguments{ 10 | \item{letter}{specify the letter} 11 | 12 | \item{term}{specify the word or phrase to be searched} 13 | } 14 | \value{ 15 | Dataframe with the thesaurus 16 | } 17 | \description{ 18 | This function returns a data frame with STF thesaurus 19 | } 20 | \keyword{stj,} 21 | \keyword{thesaurus} 22 | -------------------------------------------------------------------------------- /R/stf_acompanhamento.R: -------------------------------------------------------------------------------- 1 | #' Function stf_acompanhamento 2 | #' 3 | #' Essa função retorna a tabela com o andamento processual da jurispruência buscada com a função stf_metadados.R 4 | #' @param url url dos andamentos 5 | #' @keywords stf, jurisprudência, andamento processual 6 | #' @return tabela com os andamentos processuais 7 | #' @export 8 | stf_acompanhamento <- function(url) { 9 | xp <- "//table[@class='resultadoAndamentoProcesso']" 10 | url %>% 11 | xml2::read_html() %>% 12 | rvest::html_nodes(xpath = xp) %>% 13 | rvest::html_table() %>% 14 | magrittr::extract2(1) 15 | } 16 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/prop/INDEX: -------------------------------------------------------------------------------- 1 | ~%2Fpacotes%2Fstfstj%2F.travis.yml="B92ACAA8" 2 | ~%2Fpacotes%2Fstfstj%2FDESCRIPTION="EF665877" 3 | ~%2Fpacotes%2Fstfstj%2FNAMESPACE="70748252" 4 | ~%2Fpacotes%2Fstfstj%2FR%2Fstf_acompanhamento.R="9C17EFEB" 5 | ~%2Fpacotes%2Fstfstj%2FR%2Fstf_acordaos.R="98362BB0" 6 | ~%2Fpacotes%2Fstfstj%2FR%2Fstf_inteiro_teor.R="C49A433B" 7 | ~%2Fpacotes%2Fstfstj%2FR%2Fstf_metadados.R="FC7E3854" 8 | ~%2Fpacotes%2Fstfstj%2FR%2Fstf_monocratica.R="3A554BED" 9 | ~%2Fpacotes%2Fstfstj%2FR%2Fstf_urls.R="81F15E49" 10 | ~%2Fpacotes%2Fstfstj%2FR%2Fstfstj.R="92F868AD" 11 | ~%2Fpacotes%2Fstfstj%2FREADME.Rmd="D45C3F3F" 12 | -------------------------------------------------------------------------------- /man/stj_opinion_metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stj_opinion_metadata.R 3 | \name{stj_opinion_metadata} 4 | \alias{stj_opinion_metadata} 5 | \title{Gets metadada from Brazilian Federal High Court precedents} 6 | \usage{ 7 | stj_opinion_metadata(open_search, phrase = TRUE) 8 | } 9 | \arguments{ 10 | \item{open_search}{Words to be searched} 11 | 12 | \item{phrase}{logical, if TRUE, default, the search parameter will be treated as phrase.} 13 | } 14 | \value{ 15 | Data frame with the metadata 16 | } 17 | \description{ 18 | Gets metadada from Brazilian Federal High Court precedents 19 | } 20 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: stfstj 2 | Date: 2017-11-16 3 | Title: Extração dos dados do STF e do STJ 4 | Version: 0.1.0 5 | Author: Associação Brasileira de Jurimetria 6 | Maintainer: The package maintainer 7 | Description: Funções para extrair dados jurisprudenciais dos tribunais superiores (STF,STJ). 8 | License: MIT + file LICENSE 9 | Encoding: UTF-8 10 | LazyData: true 11 | Depends: 12 | R (>= 3.4.2) 13 | Imports: 14 | httr, 15 | stringr, 16 | lubridate, 17 | purrr, 18 | dplyr, 19 | magrittr, 20 | xml2, 21 | rvest, 22 | pdftools, 23 | tesseract, 24 | assertthat, 25 | abjutils, 26 | tibble 27 | RoxygenNote: 6.0.1 28 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/s-7995746f/42A53D5D: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "", 4 | "created" : 1511314152211.000, 5 | "dirty" : true, 6 | "encoding" : "", 7 | "folds" : "", 8 | "hash" : "0", 9 | "id" : "42A53D5D", 10 | "lastKnownWriteTime" : 3180141808686473843, 11 | "last_content_update" : 1520301662856, 12 | "path" : null, 13 | "project_path" : null, 14 | "properties" : { 15 | "cursorPosition" : "9,0", 16 | "scrollLine" : "0", 17 | "tempName" : "Untitled1" 18 | }, 19 | "relative_order" : 1, 20 | "source_on_save" : false, 21 | "source_window" : "", 22 | "type" : "r_source" 23 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/s-7995746f/AB3CF3D0: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "", 4 | "created" : 1520301938452.000, 5 | "dirty" : false, 6 | "encoding" : "UTF-8", 7 | "folds" : "", 8 | "hash" : "3006083623", 9 | "id" : "AB3CF3D0", 10 | "lastKnownWriteTime" : 1520302001, 11 | "last_content_update" : 1520302001349, 12 | "path" : "~/pacotes/stfstj/README.Rmd", 13 | "project_path" : "README.Rmd", 14 | "properties" : { 15 | "cursorPosition" : "111,0", 16 | "scrollLine" : "105" 17 | }, 18 | "relative_order" : 2, 19 | "source_on_save" : false, 20 | "source_window" : "", 21 | "type" : "r_markdown" 22 | } -------------------------------------------------------------------------------- /man/stf_mono_metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stf_mono_metadata.R 3 | \name{stf_mono_metadata} 4 | \alias{stf_mono_metadata} 5 | \title{Returns metadada from Brazilian Supreme Court monocratic decisions} 6 | \usage{ 7 | stf_mono_metadata(open_search, parties_names = TRUE) 8 | } 9 | \arguments{ 10 | \item{open_search}{Words to be searched} 11 | 12 | \item{parties_names}{Logical. If TRUE (default), it will attempt to fix 13 | parties prefixes.} 14 | } 15 | \value{ 16 | Dataframe with the metadata 17 | } 18 | \description{ 19 | Returns metadada from Brazilian Supreme Court monocratic decisions 20 | } 21 | \keyword{metadata} 22 | \keyword{precedents,} 23 | \keyword{stf,} 24 | -------------------------------------------------------------------------------- /man/stj_mono_metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stj_mono_metadata.R 3 | \name{stj_mono_metadata} 4 | \alias{stj_mono_metadata} 5 | \title{Get metadata from Brazilian highest Federal Court's (STJ) monocratic decisions} 6 | \usage{ 7 | stj_mono_metadata(open_search, phrase = TRUE) 8 | } 9 | \arguments{ 10 | \item{open_search}{search parameter} 11 | 12 | \item{phrase}{logical, if TRUE, default, the search parameter will be treated as phrase.} 13 | } 14 | \value{ 15 | data frame with the metadata 16 | } 17 | \description{ 18 | Get metadata from Brazilian highest Federal Court's (STJ) monocratic decisions 19 | } 20 | \examples{ 21 | family_doctors<- stj_mono_metadata("m\\u00e9dico de fam\\u00edlia") 22 | } 23 | -------------------------------------------------------------------------------- /man/stf_opinion_metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stf__opinion_metadata.R 3 | \name{stf_opinion_metadata} 4 | \alias{stf_opinion_metadata} 5 | \title{Returns metadada from Brazilian Supreme Court precedents} 6 | \usage{ 7 | stf_opinion_metadata(open_search, dt_start, dt_end, parties_names = TRUE) 8 | } 9 | \arguments{ 10 | \item{open_search}{Words to be searched} 11 | 12 | \item{dt_start}{start date in the format "dd/mm/yyy"} 13 | 14 | \item{dt_end}{end date in the format "dd/mm/yyyy"} 15 | 16 | \item{parties_names}{Logical. If TRUE (default), it will attempt to fix 17 | the parties prefixes.} 18 | } 19 | \value{ 20 | Dataframe with the metadata 21 | } 22 | \description{ 23 | Returns metadada from Brazilian Supreme Court precedents 24 | } 25 | \keyword{metadata} 26 | \keyword{precedents,} 27 | \keyword{stf,} 28 | -------------------------------------------------------------------------------- /man/stf_opinion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stf_opinion.R 3 | \name{stf_opinion} 4 | \alias{stf_opinion} 5 | \title{Reads the pdfs with the panel's opinion text according to the metadata 6 | obtained by the stf_opinion_metadata function.} 7 | \usage{ 8 | stf_opinion(df) 9 | } 10 | \arguments{ 11 | \item{df}{data frame with at least two columns, one with the url, 12 | and the other, named electronico, with a logical vector informing whether the pdf is 13 | a text(TRUE) or an image(FALSE).} 14 | } 15 | \value{ 16 | vector with the whole content of the opinions. 17 | } 18 | \description{ 19 | Reads the pdfs with the panel's opinion text according to the metadata 20 | obtained by the stf_opinion_metadata function. 21 | } 22 | \keyword{court} 23 | \keyword{opinion,} 24 | \keyword{precedents,} 25 | \keyword{stf,} 26 | \keyword{supreme} 27 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | cache: 14 | - C:\RLibrary 15 | 16 | # Adapt as necessary starting from here 17 | 18 | build_script: 19 | - travis-tool.sh install_deps 20 | 21 | test_script: 22 | - travis-tool.sh run_tests 23 | 24 | on_failure: 25 | - 7z a failure.zip *.Rcheck\* 26 | - appveyor PushArtifact failure.zip 27 | 28 | artifacts: 29 | - path: '*.Rcheck\**\*.log' 30 | name: Logs 31 | 32 | - path: '*.Rcheck\**\*.out' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.fail' 36 | name: Logs 37 | 38 | - path: '*.Rcheck\**\*.Rout' 39 | name: Logs 40 | 41 | - path: '\*_*.tar.gz' 42 | name: Bits 43 | 44 | - path: '\*_*.zip' 45 | name: Bits 46 | -------------------------------------------------------------------------------- /man/stj_metadata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stj_metadata.R 3 | \name{stj_metadata} 4 | \alias{stj_metadata} 5 | \title{Function stj_metadata} 6 | \usage{ 7 | stj_metadata(open_search, database = "acordaos", phrase = FALSE, 8 | start_date = "", end_date = "") 9 | } 10 | \arguments{ 11 | \item{open_search}{Words to be searched} 12 | 13 | \item{database}{Character string with one of these seven options:"acordaos","sumulas", 14 | "monocraticas',"informativo" 15 | Default is "acordaos".} 16 | 17 | \item{phrase}{Logical. If TRUE, it will deparse the sentence.} 18 | 19 | \item{start_date}{Optional. Character string in the 20 | format: "dd/mm/yyyy" with the start of period to search for.} 21 | 22 | \item{end_date}{Optional. Character string in the 23 | format: "dd/mm/yyyy" with the end of period to search for.} 24 | } 25 | \value{ 26 | Dataframe with the metadata 27 | } 28 | \description{ 29 | This function returns metadada from Brazilian Federal High Court precedents 30 | } 31 | \keyword{metadata} 32 | \keyword{precedents,} 33 | \keyword{stj,} 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2017 Your name goes here 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/stf_thesaurusDF.R: -------------------------------------------------------------------------------- 1 | #' Function stf_thesaurusDF 2 | #' 3 | #' This function returns a data frame with STF thesaurus 4 | #' @param letter specify the letter 5 | #' @param term specify the word or phrase to be searched 6 | #' @keywords stj, thesaurus 7 | #' @return Dataframe with the thesaurus 8 | 9 | 10 | stf_thesaurusDF<-function(letter="",term=""){ 11 | url1<-"http://www.stf.jus.br/portal/jurisprudencia/pesquisarVocabularioJuridico.asp" 12 | url2<-"http://www.stf.jus.br/portal/jurisprudencia/listarTesauro.asp" 13 | term<-deparse(term) 14 | if(length(letter)==1){ 15 | 16 | httr::POST(url2,body=list(passaletra=letter, 17 | txtPesquisaLivre=term), 18 | encode="form", 19 | httr::add_headers(`Referer`=url1)) %>% 20 | httr::content() %>% 21 | rvest::html_node(xpath="//table") %>% 22 | rvest::html_table(header=FALSE,fill=T) 23 | }else{ 24 | letter %>% 25 | purrr::map_dfr(~{ 26 | httr::POST(url2,body=list(passaletra=.x, 27 | txtPesquisaLivre=term), 28 | encode="form", 29 | httr::add_headers(`Referer`=url1)) %>% 30 | httr::content() %>% 31 | rvest::html_node(xpath="//table") %>% 32 | rvest::html_table(header=FALSE,fill=T) 33 | }) 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /R/stf_opinion.R: -------------------------------------------------------------------------------- 1 | #' Reads the pdfs with the panel's opinion text according to the metadata 2 | #' obtained by the stf_opinion_metadata function. 3 | #' 4 | #' @param df data frame with at least two columns, one with the url, 5 | #' and the other, named electronico, with a logical vector informing whether the pdf is 6 | #' a text(TRUE) or an image(FALSE). 7 | #' 8 | #' @keywords stf, precedents, opinion, supreme court 9 | #' 10 | #' @return vector with the whole content of the opinions. 11 | #' 12 | #' @export 13 | stf_opinion <- function(df) { 14 | stopifnot(is.logical(df$eletronico)) 15 | diretorio <- getwd() 16 | setwd(tempdir()) 17 | tmp_file <- tempfile(pattern = "inteiro", fileext = ".pdf") 18 | on.exit(setwd(diretorio), unlink(tmp_file)) 19 | file <- purrr::map2(df$url_inteiro_teor, df$eletronico, purrr::possibly(~{ 20 | if (.y == TRUE) { 21 | pdftools::pdf_text(.x) 22 | } else { 23 | httr::GET(.x,httr::write_disk(path=tmp_file,overwrite=TRUE)) 24 | files <- pdftools::pdf_convert(tmp_file,dpi=400) 25 | files %>% 26 | purrr::map(~{ 27 | .x %>% 28 | tesseract::ocr(engine=tesseract::tesseract("por")) 29 | }) 30 | 31 | } 32 | },NA_character_,quiet=FALSE)) 33 | 34 | file %>% purrr::map_chr(~stringr::str_c(.x,sep="\n",collapse="")) 35 | } 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /R/stj_mono_metadata.R: -------------------------------------------------------------------------------- 1 | #' Get metadata from Brazilian highest Federal Court's (STJ) monocratic decisions 2 | #' 3 | #' @param open_search search parameter 4 | #' @param phrase logical, if TRUE, default, the search parameter will be treated as phrase. 5 | #' 6 | #' @return data frame with the metadata 7 | #' @export 8 | #' 9 | #' @examples 10 | #' family_doctors<- stj_mono_metadata("m\u00e9dico de fam\u00edlia") 11 | 12 | stj_mono_metadata <- function(open_search,phrase=TRUE){ 13 | 14 | open_search<-abjutils::rm_accent(open_search) 15 | 16 | if (phrase == TRUE) { 17 | open_search <- deparse(open_search) 18 | } 19 | 20 | 21 | url1 <- "http://www.stj.jus.br/SCON/" 22 | url2 <- "http://www.stj.jus.br/SCON/pesquisar.jsp" 23 | h <- httr::GET(url1) 24 | 25 | content<-httr::GET("http://www.stj.jus.br", 26 | path = "/SCON/decisoes/toc.jsp", 27 | query = list(tipo_visualizacao = "", 28 | livre = open_search, 29 | b = "DTXT", 30 | p = "true", 31 | l = 10, 32 | t = 'JURIDICO', 33 | i = 1), 34 | httr::add_headers(`Referer` = url2)) %>% 35 | httr::content() 36 | 37 | 38 | ## Get the number of pages to loop over each one and add them to the data.frame 39 | pages <- content %>% 40 | xml2::xml_find_first(xpath = '//div[@id="infopesquisa"]/span[@class="labellinha"]/following-sibling::span[1]') %>% 41 | xml2::xml_text() %>% 42 | as.numeric() 43 | 44 | ## Might be important to inform the exact request time in Brasilia 45 | ## in order to allow others to replicate the research. 46 | 47 | search_time<-lubridate::now(tz="America/Sao_Paulo") 48 | 49 | df<- seq(1,pages,10) %>% 50 | purrr::map_dfr(~{ 51 | res2 <- httr::GET("http://www.stj.jus.br", 52 | path = "/SCON/decisoes/toc.jsp", 53 | query = list(tipo_visualizacao = "", 54 | livre = open_search, 55 | b = "DTXT", 56 | p = "true", 57 | l = 10, 58 | t = 'JURIDICO', 59 | i = .x), 60 | httr::add_headers(`Referer` = url1)) 61 | 62 | page<-.x 63 | 64 | principal <- res2 %>% 65 | httr::content() 66 | 67 | processo <- principal %>% 68 | xml2::xml_find_all("//div/h4[contains(.,'Processo')]/following-sibling::p[1]") %>% 69 | xml2::xml_text() %>% 70 | stringr::str_trim() 71 | 72 | 73 | relator <- principal%>% 74 | xml2::xml_find_all("//div/h4[text()='Relator(a)']/following-sibling::p[1]") %>% 75 | xml2::xml_text() %>% 76 | stringr::str_extract("(?<=Ministr[ao]\\s).*") 77 | 78 | 79 | 80 | data_publicacao <- principal %>% 81 | xml2::xml_find_all("//div/h4[text()='Data da Publica\u00e7\u00e3o']/following-sibling::p[1]") %>% 82 | xml2::xml_text() %>% 83 | lubridate::dmy() 84 | 85 | 86 | decisao <- principal%>% 87 | xml2::xml_find_all("//div/h4[text()='Decis\u00e3o']/following-sibling::pre[1]") %>% 88 | xml2::xml_text() 89 | 90 | tibble::tibble(page,processo,relator,data_publicacao,decisao) 91 | }) 92 | 93 | df<-dplyr::bind_cols(search_time=rep(search_time,nrow(df)),df) 94 | } -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/console06/BBE25B02.env: -------------------------------------------------------------------------------- 1 | { 2 | "CLICOLOR_FORCE" : "1", 3 | "DISPLAY" : ":0", 4 | "EDITOR" : "vi", 5 | "GIT_ASKPASS" : "rpostback-askpass", 6 | "HISTCONTROL" : "ignoreboth", 7 | "HOME" : "/home/rstudio", 8 | "LANG" : "pt_BR.UTF-8", 9 | "LD_LIBRARY_PATH" : "/usr/lib/R/lib::/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/jre/lib/amd64/server", 10 | "LESSCLOSE" : "/usr/bin/lesspipe %s %s", 11 | "LESSOPEN" : "| /usr/bin/lesspipe %s", 12 | "LN_S" : "ln -s", 13 | "LOGNAME" : "rstudio", 14 | "LS_COLORS" : "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:", 15 | "MAKE" : "make", 16 | "PAGER" : "/usr/bin/pager", 17 | "PATH" : "/home/rstudio/bin:/home/rstudio/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:bin/msys-ssh-1000-18:/snap/bin", 18 | "PROMPT_COMMAND" : "echo -ne \"\\033]0;${PWD/#${HOME}/~}\\007\"", 19 | "PWD" : "/home/rstudio/pacotes/stfstj", 20 | "RMARKDOWN_MATHJAX_PATH" : "/usr/lib/rstudio-server/resources/mathjax-26", 21 | "RSTUDIO" : "1", 22 | "RSTUDIO_CONSOLE_COLOR" : "256", 23 | "RSTUDIO_CONSOLE_WIDTH" : "77", 24 | "RSTUDIO_HTTP_REFERER" : "http://165.227.184.135:8787/", 25 | "RSTUDIO_PANDOC" : "/usr/lib/rstudio-server/bin/pandoc", 26 | "RSTUDIO_PROJ_NAME" : "stfstj", 27 | "RSTUDIO_SESSION_ID" : "7995746f", 28 | "RSTUDIO_SESSION_STREAM" : "rstudio-d", 29 | "RSTUDIO_TERM" : "BBE25B02", 30 | "RSTUDIO_USER_IDENTITY" : "rstudio", 31 | "RSTUDIO_WINUTILS" : "bin/winutils", 32 | "RS_RPOSTBACK_PATH" : "/usr/lib/rstudio-server/bin/rpostback", 33 | "R_BROWSER" : "xdg-open", 34 | "R_BZIPCMD" : "/bin/bzip2", 35 | "R_DOC_DIR" : "/usr/share/R/doc", 36 | "R_GZIPCMD" : "/bin/gzip -n", 37 | "R_HOME" : "/usr/lib/R", 38 | "R_INCLUDE_DIR" : "/usr/share/R/include", 39 | "R_LIBS_SITE" : "/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library", 40 | "R_LIBS_USER" : "", 41 | "R_PAPERSIZE" : "letter", 42 | "R_PAPERSIZE_USER" : "letter", 43 | "R_PDFVIEWER" : "/usr/bin/xdg-open", 44 | "R_PLATFORM" : "x86_64-pc-linux-gnu", 45 | "R_PRINTCMD" : "/usr/bin/lpr", 46 | "R_RD4PDF" : "times,inconsolata,hyper", 47 | "R_SESSION_TMPDIR" : "/tmp/RtmpElqmZd", 48 | "R_SHARE_DIR" : "/usr/share/R/share", 49 | "R_SYSTEM_ABI" : "linux,gcc,gxx,gfortran,?", 50 | "R_TEXI2DVICMD" : "/usr/bin/texi2dvi", 51 | "R_UNZIPCMD" : "/usr/bin/unzip", 52 | "R_ZIPCMD" : "/usr/bin/zip", 53 | "SED" : "/bin/sed", 54 | "SHLVL" : "1", 55 | "SSH_ASKPASS" : "rpostback-askpass", 56 | "TAR" : "/bin/tar", 57 | "TERM" : "xterm-256color", 58 | "USER" : "rstudio" 59 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Travis-CI Build Status](https://travis-ci.org/jjesusfilho/stfstj.svg?branch=master)](https://travis-ci.org/jjesusfilho/stfstj) [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jjesusfilho/stfstj?branch=master&svg=true)](https://ci.appveyor.com/project/jjesusfilho/stfstj) 2 | 3 | stfstj 4 | ====== 5 | 6 | The goal of package stfstj is to download data from the Brazilian Supreme Court (STF) and Superior Court of Justice (STJ) decisions. 7 | 8 | Installation 9 | ------------ 10 | 11 | You can install stfstj from github with: 12 | 13 | ``` r 14 | # install.packages("devtools") 15 | devtools::install_github("courtsbr/stfstj") 16 | ``` 17 | 18 | You also have to make sure the packages [tesseract](https://github.com/ropensci/tesseract) and [pdftools](https://github.com/ropensci/pdftools) are installed as well as their dependencies. 19 | 20 | You also have to download the `tesseract` trained data for Portuguese. You can find directions for Linux, Mac-OS and Windows [here](https://github.com/tesseract-ocr/tesseract/wiki) 21 | 22 | Usage for STF 23 | ------------- 24 | 25 | ### Read metadata 26 | 27 | Suppose you want to download the metadata from the Brazilian Supreme Court panel opinions with the expression "excesso de prazo". You can run this function: 28 | 29 | ``` r 30 | df<-stf_opinion_metadata(open_search="excesso de prazo") 31 | ``` 32 | 33 | Or simply: 34 | 35 | ``` r 36 | df<-stf_opinion_metadata("excesso adj2 prazo") 37 | ``` 38 | 39 | By using "adj2" you are telling the search engine that "prazo" is one word apart from "excesso". 40 | 41 | If you want to search for monocratic decisions, you can use another functio: 42 | 43 | ``` r 44 | df<-stf__mono_metadata("excesso adj2 prazo") 45 | ``` 46 | 47 | In order to find all the options, use the help function: 48 | 49 | ``` r 50 | ?stf_opinion_metadata() 51 | ``` 52 | 53 | Suppose now that you want to read all cases where "Telefônica" is a party. You can add the suffix ".PART." to the search: 54 | 55 | ``` r 56 | telefonicaDF<-stf_opinion_metadata("telefonica.PART.") 57 | ``` 58 | 59 | If you want to see all the possible suffixes, the function `stf_help_view()` will load the help page on the Rstudio viewer pane: 60 | 61 | ``` r 62 | stf_help_view() 63 | ``` 64 | 65 | ### Download whole opinion text (inteiro teor): 66 | 67 | Once you have imported the metadata, you can use the same data frame to import the whole decision. Beware that decisions published before 2011 and even some of that year are in pdf image, not text. Those decisions are converted to `png` and submmited to OCR in order to be read. The limitation is that it might take a long time to read all opinions. 68 | 69 | ### Vocabulary correspondence 70 | 71 | The table below shows a rough translation of the Brazilian Supreme Court's opinion's elements to US English: 72 | 73 | | Portuguese | English | 74 | |----------------------|-----------------------| 75 | | Acórdão | Opinion | 76 | | Ementa | Syllabus | 77 | | Relator | Reporter | 78 | | Ministro | Justice | 79 | | Órgão julgador | Judicial panel | 80 | | Decisão | Decision | 81 | | Processo | Docket number | 82 | | Parte | Party | 83 | | Acompanhamento | Docket sheet | 84 | | Classe | Petition type | 85 | | Prover/conceder | Reverse | 86 | | Desprover/denegar | Affirm | 87 | | Anular decisão | Remand | 88 | | Origem | Original jurisdiction | 89 | | Data da distribuição | Argued date | 90 | | Data do julgamento | Decision's date | 91 | 92 | ### Read the full opinion text (inteiro teor): 93 | 94 | Once you have imported the metadata, you can use the same data frame to import the full opinion's text. Beware that opinions published before 2011 and even some of that year are in pdf image, not in text. Those opinions are downloaded, converted to `png`, and subsequently submmited to OCR in order to be read. 95 | 96 | The limitation is that it takes a considerable amount of time to read the opinion's text. Without parallelization, one opinion can take up to 4 minutes to be read. As an example, 2000 opinions might take over five days to be read. 97 | 98 | ``` r 99 | decisionTelefonica<-stf_opinion(telefonicaDF[1,]). 100 | # Downloads just the first decision from the dataset imported above. 101 | ``` 102 | -------------------------------------------------------------------------------- /R/stj_opinion_metadata.R: -------------------------------------------------------------------------------- 1 | #' Gets metadada from Brazilian Federal High Court precedents 2 | #' 3 | #' @param open_search Words to be searched 4 | #' @param phrase logical, if TRUE, default, the search parameter will be treated as phrase. 5 | 6 | #' @return Data frame with the metadata 7 | #' @export 8 | stj_opinion_metadata <- function(open_search,phrase=TRUE){ 9 | 10 | abjutils::rm_accent(open_search) 11 | 12 | if (phrase == TRUE) { 13 | open_search <- deparse(open_search) 14 | } 15 | 16 | #open_search <- utils::URLencode(open_search) 17 | 18 | url1 <- "http://www.stj.jus.br/SCON/" 19 | url2 <- "http://www.stj.jus.br/SCON/pesquisar.jsp" 20 | h <- httr::GET(url1) 21 | 22 | 23 | ####corpo_fim#### 24 | 25 | 26 | 27 | 28 | content<-httr::GET("http://www.stj.jus.br", 29 | path = "/SCON/decisoes/toc.jsp", 30 | query = list(tipo_visualizacao = "", 31 | livre = open_search, 32 | b = "ACOR", 33 | p = "true", 34 | l = 10, 35 | t = 'JURIDICO', 36 | i = 1), 37 | httr::add_headers(`Referer` = url2)) %>% 38 | httr::content() 39 | 40 | 41 | ## Get the number of pages to loop over each one and add them to the data.frame 42 | pages <- content %>% 43 | xml2::xml_find_first(xpath = '//div[@id="infopesquisa"]/span[@class="labellinha"]/following-sibling::span[1]') %>% 44 | xml2::xml_text() %>% 45 | as.numeric() 46 | 47 | ## Might be important to inform the exact request time in Brasilia 48 | ## in order to allow others to replicate the research. 49 | 50 | search_time<-lubridate::now(tz="America/Sao_Paulo") 51 | 52 | df<- seq(1,pages,10) %>% 53 | purrr::map_dfr(~{ 54 | res2 <- httr::GET("http://www.stj.jus.br", 55 | path = "/SCON/jurisprudencia/toc.jsp", 56 | query = list(tipo_visualizacao = "", 57 | livre = open_search, 58 | b = "ACOR", 59 | p = "true", 60 | l = 10, 61 | t = 'JURIDICO', 62 | i = .x), 63 | httr::add_headers(`Referer` = url2)) 64 | 65 | page<-.x 66 | 67 | principal <- res2 %>% 68 | httr::content() 69 | 70 | processo <- principal %>% 71 | xml2::xml_find_all("//div[@class='docTexto']/text()[following-sibling::br][1]") %>% 72 | xml2::xml_text() %>% 73 | stringr::str_trim() 74 | 75 | 76 | origem <- processo %>% 77 | stringr::str_extract("\\w{2}$") 78 | 79 | classe <- principal %>% 80 | xml2::xml_find_all("//div[@class='docTexto']/text()[following-sibling::br][2]") %>% 81 | xml2::xml_text() %>% 82 | stringr::str_trim() 83 | 84 | processo_stj <- principal %>% 85 | xml2::xml_find_all("//div[@class='docTexto']/text()[preceding-sibling::br][2]") %>% 86 | xml2::xml_text() %>% 87 | stringr::str_trim() 88 | 89 | relator <- principal %>% 90 | xml2::xml_find_all("//div/h4[text()='Relator(a)']/following-sibling::pre[@class='docTexto']") %>% 91 | xml2::xml_text() %>% 92 | stringr::str_extract("(?<=Ministr[ao]\\s).*(?=\\s\\()") 93 | 94 | orgao_julgador <- principal %>% 95 | xml2::xml_find_all("//div/h4[text()='\u00D3rg\u00E3o Julgador']/following-sibling::pre[@class='docTexto']") %>% 96 | xml2::xml_text() 97 | 98 | data_julgamento <- principal %>% 99 | xml2::xml_find_all("//div/h4[text()='Data do Julgamento']/following-sibling::pre[@class='docTexto']") %>% 100 | xml2::xml_text() %>% 101 | lubridate::dmy() 102 | 103 | publicacao <- principal %>% 104 | xml2::xml_find_all("//div/h4[text()='Data da Publica\u00E7\u00E3o/Fonte']/following-sibling::pre[@class='docTexto']") %>% 105 | xml2::xml_text() 106 | 107 | fonte <- publicacao %>% stringr::str_extract("\\w+") 108 | 109 | data_publicacao <- pt_time_extract(publicacao) 110 | 111 | ementa <- principal %>% 112 | xml2::xml_find_all("//div/h4[text()='Ementa']/following-sibling::pre[@class='docTexto']") %>% 113 | xml2::xml_text() 114 | 115 | decisao <- principal %>% 116 | xml2::xml_find_all("//div/h4[text()='Ac\u00F3rd\u00E3o']/following-sibling::pre[@class='docTexto']") %>% 117 | xml2::xml_text() 118 | 119 | tibble::tibble(page,processo,origem,classe,processo_stj,relator,orgao_julgador,data_julgamento,fonte,data_publicacao,ementa,decisao) 120 | }) 121 | 122 | df<-dplyr::bind_cols(search_time=rep(search_time,nrow(df)),df) 123 | } 124 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: 3 | md_document: 4 | variant: markdown_github 5 | --- 6 | 7 | [![Travis-CI Build Status](https://travis-ci.org/jjesusfilho/stfstj.svg?branch=master)](https://travis-ci.org/jjesusfilho/stfstj) 8 | [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jjesusfilho/stfstj?branch=master&svg=true)](https://ci.appveyor.com/project/jjesusfilho/stfstj) 9 | 10 | 11 | ```{r, echo = FALSE} 12 | knitr::opts_chunk$set( 13 | collapse = TRUE, 14 | comment = "#>", 15 | fig.path = "README-" 16 | ) 17 | ``` 18 | 19 | # stfstj 20 | 21 | The goal of package stfstj is to download data from the Brazilian Supreme Court (STF) and Superior Court of Justice (STJ) decisions. 22 | 23 | ## Installation 24 | 25 | You can install stfstj from github with: 26 | 27 | ```{r gh-installation, eval = FALSE} 28 | # install.packages("devtools") 29 | devtools::install_github("courtsbr/stfstj") 30 | ``` 31 | 32 | You also have to make sure the packages [tesseract](https://github.com/ropensci/tesseract) and [pdftools](https://github.com/ropensci/pdftools) are installed as well as their dependencies. 33 | 34 | You also have to download the `tesseract` trained data for Portuguese. You can find directions for Linux, Mac-OS and Windows [here](https://github.com/tesseract-ocr/tesseract/wiki) 35 | 36 | ## Usage for STF 37 | 38 | ### Read metadata 39 | 40 | Suppose you want to download the metadata from the Brazilian Supreme Court panel opinions with the expression "excesso de prazo". You can run this function: 41 | 42 | ```{r example1,eval=FALSE} 43 | df<-stf_opinion_metadata(open_search="excesso de prazo") 44 | ``` 45 | 46 | Or simply: 47 | 48 | ```{r example2,eval=FALSE} 49 | df<-stf_opinion_metadata("excesso adj2 prazo") 50 | ``` 51 | 52 | By using "adj2" you are telling the search engine that "prazo" is one word apart from "excesso". 53 | 54 | If you want to search for monocratic decisions, you can use another functio: 55 | 56 | ```{r example3,eval=FALSE} 57 | df<-stf__mono_metadata("excesso adj2 prazo") 58 | ``` 59 | 60 | In order to find all the options, use the help function: 61 | 62 | ```{r example4,eval=FALSE} 63 | ?stf_opinion_metadata() 64 | ``` 65 | 66 | Suppose now that you want to read all cases where "Telefônica" is a party. You can add the suffix ".PART." to the search: 67 | 68 | ```{r example5,eval=FALSE} 69 | telefonicaDF<-stf_opinion_metadata("telefonica.PART.") 70 | ``` 71 | 72 | If you want to see all the possible suffixes, the function `stf_help_view()` will load the help page on the Rstudio viewer pane: 73 | 74 | ```{r example6,eval=FALSE} 75 | stf_help_view() 76 | ``` 77 | 78 | ### Download whole opinion text (inteiro teor): 79 | 80 | Once you have imported the metadata, you can use the same data frame to import the whole decision. Beware that decisions published before 2011 and even some of that year are in pdf image, not text. Those decisions are converted to `png` and submmited to OCR in order to be read. 81 | The limitation is that it might take a long time to read all opinions. 82 | 83 | ### Vocabulary correspondence 84 | 85 | The table below shows a rough translation of the Brazilian Supreme Court's opinion's elements to US English: 86 | 87 | |Portuguese |English | 88 | |--------------------|---------------------| 89 | |Acórdão |Opinion | 90 | |Ementa |Syllabus | 91 | |Relator |Reporter | 92 | |Ministro |Justice | 93 | |Órgão julgador |Judicial panel | 94 | |Decisão |Decision | 95 | |Processo |Docket number | 96 | |Parte |Party | 97 | |Acompanhamento |Docket sheet | 98 | |Classe |Petition type | 99 | |Prover/conceder |Reverse | 100 | |Desprover/denegar |Affirm | 101 | |Anular decisão |Remand | 102 | |Origem |Original jurisdiction| 103 | |Data da distribuição|Argued date | 104 | |Data do julgamento |Decision's date | 105 | 106 | 107 | ### Read the full opinion text (inteiro teor): 108 | 109 | Once you have imported the metadata, you can use the same data frame to import the full opinion's text. Beware that opinions published before 2011 and even some of that year are in pdf image, not in text. Those opinions are downloaded, converted to `png`, and subsequently submmited to OCR in order to be read. 110 | 111 | The limitation is that it takes a considerable amount of time to read the opinion's text. Without parallelization, one opinion can take up to 4 minutes to be read. As an example, 2000 opinions might take over five days to be read. 112 | 113 | ```{r example7,eval=FALSE} 114 | decisionTelefonica<-stf_opinion(telefonicaDF[1,]). 115 | # Downloads just the first decision from the dataset imported above. 116 | ``` 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/s-7995746f/AB3CF3D0-contents: -------------------------------------------------------------------------------- 1 | --- 2 | output: 3 | md_document: 4 | variant: markdown_github 5 | --- 6 | 7 | [![Travis-CI Build Status](https://travis-ci.org/jjesusfilho/stfstj.svg?branch=master)](https://travis-ci.org/jjesusfilho/stfstj) 8 | [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jjesusfilho/stfstj?branch=master&svg=true)](https://ci.appveyor.com/project/jjesusfilho/stfstj) 9 | 10 | 11 | ```{r, echo = FALSE} 12 | knitr::opts_chunk$set( 13 | collapse = TRUE, 14 | comment = "#>", 15 | fig.path = "README-" 16 | ) 17 | ``` 18 | 19 | # stfstj 20 | 21 | The goal of package stfstj is to download data from the Brazilian Supreme Court (STF) and Superior Court of Justice (STJ) decisions. 22 | 23 | ## Installation 24 | 25 | You can install stfstj from github with: 26 | 27 | ```{r gh-installation, eval = FALSE} 28 | # install.packages("devtools") 29 | devtools::install_github("courtsbr/stfstj") 30 | ``` 31 | 32 | You also have to make sure the packages [tesseract](https://github.com/ropensci/tesseract) and [pdftools](https://github.com/ropensci/pdftools) are installed as well as their dependencies. 33 | 34 | You also have to download the `tesseract` trained data for Portuguese. You can find directions for Linux, Mac-OS and Windows [here](https://github.com/tesseract-ocr/tesseract/wiki) 35 | 36 | ## Usage for STF 37 | 38 | ### Read metadata 39 | 40 | Suppose you want to download the metadata from the Brazilian Supreme Court panel opinions with the expression "excesso de prazo". You can run this function: 41 | 42 | ```{r example1,eval=FALSE} 43 | df<-stf_opinion_metadata(open_search="excesso de prazo") 44 | ``` 45 | 46 | Or simply: 47 | 48 | ```{r example2,eval=FALSE} 49 | df<-stf_opinion_metadata("excesso adj2 prazo") 50 | ``` 51 | 52 | By using "adj2" you are telling the search engine that "prazo" is one word apart from "excesso". 53 | 54 | If you want to search for monocratic decisions, you can use another functio: 55 | 56 | ```{r example3,eval=FALSE} 57 | df<-stf__mono_metadata("excesso adj2 prazo") 58 | ``` 59 | 60 | In order to find all the options, use the help function: 61 | 62 | ```{r example4,eval=FALSE} 63 | ?stf_opinion_metadata() 64 | ``` 65 | 66 | Suppose now that you want to read all cases where "Telefônica" is a party. You can add the suffix ".PART." to the search: 67 | 68 | ```{r example5,eval=FALSE} 69 | telefonicaDF<-stf_opinion_metadata("telefonica.PART.") 70 | ``` 71 | 72 | If you want to see all the possible suffixes, the function `stf_help_view()` will load the help page on the Rstudio viewer pane: 73 | 74 | ```{r example6,eval=FALSE} 75 | stf_help_view() 76 | ``` 77 | 78 | ### Download whole opinion text (inteiro teor): 79 | 80 | Once you have imported the metadata, you can use the same data frame to import the whole decision. Beware that decisions published before 2011 and even some of that year are in pdf image, not text. Those decisions are converted to `png` and submmited to OCR in order to be read. 81 | The limitation is that it might take a long time to read all opinions. 82 | 83 | ### Vocabulary correspondence 84 | 85 | The table below shows a rough translation of the Brazilian Supreme Court's opinion's elements to US English: 86 | 87 | |Portuguese |English | 88 | |--------------------|---------------------| 89 | |Acórdão |Opinion | 90 | |Ementa |Syllabus | 91 | |Relator |Reporter | 92 | |Ministro |Justice | 93 | |Órgão julgador |Judicial panel | 94 | |Decisão |Decision | 95 | |Processo |Docket number | 96 | |Parte |Party | 97 | |Acompanhamento |Docket sheet | 98 | |Classe |Petition type | 99 | |Prover/conceder |Reverse | 100 | |Desprover/denegar |Affirm | 101 | |Anular decisão |Remand | 102 | |Origem |Original jurisdiction| 103 | |Data da distribuição|Argued date | 104 | |Data do julgamento |Decision's date | 105 | 106 | 107 | ### Read the full opinion text (inteiro teor): 108 | 109 | Once you have imported the metadata, you can use the same data frame to import the full opinion's text. Beware that opinions published before 2011 and even some of that year are in pdf image, not in text. Those opinions are downloaded, converted to `png`, and subsequently submmited to OCR in order to be read. 110 | 111 | The limitation is that it takes a considerable amount of time to read the opinion's text. Without parallelization, one opinion can take up to 4 minutes to be read. As an example, 2000 opinions might take over five days to be read. 112 | 113 | ```{r example7,eval=FALSE} 114 | decisionTelefonica<-stf_opinion(telefonicaDF[1,]). 115 | # Downloads just the first decision from the dataset imported above. 116 | ``` 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/sources/s-7995746f/1B121EF6-contents: -------------------------------------------------------------------------------- 1 | --- 2 | output: 3 | md_document: 4 | variant: markdown_github 5 | --- 6 | 7 | [![Travis-CI Build Status](https://travis-ci.org/jjesusfilho/stfstj.svg?branch=master)](https://travis-ci.org/jjesusfilho/stfstj) 8 | [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jjesusfilho/stfstj?branch=master&svg=true)](https://ci.appveyor.com/project/jjesusfilho/stfstj) 9 | 10 | 11 | ```{r, echo = FALSE} 12 | knitr::opts_chunk$set( 13 | collapse = TRUE, 14 | comment = "#>", 15 | fig.path = "README-" 16 | ) 17 | ``` 18 | 19 | # stfstj 20 | 21 | The goal of package stfstj is to download data from the Brazilian Supreme Court (STF) and Superior Court of Justice (STJ) decisions. 22 | 23 | ## Installation 24 | 25 | You can install stfstj from github with: 26 | 27 | ```{r gh-installation, eval = FALSE} 28 | # install.packages("devtools") 29 | devtools::install_github("courtsbr/stfstj") 30 | ``` 31 | 32 | You also have to make sure the packages [tesseract](https://github.com/ropensci/tesseract) and [pdftools](https://github.com/ropensci/pdftools) are installed as well as their dependencies. 33 | 34 | You also have to download the `tesseract` trained data for Portuguese. You can find directions for Linux, Mac-OS and Windows [here](https://github.com/tesseract-ocr/tesseract/wiki) 35 | 36 | ## Usage for STF 37 | 38 | ### Read metadata 39 | 40 | <<<<<<< HEAD 41 | Suppose you want to download the metadata from the Brazilian Supreme Court panel opinions with the expression "excesso de prazo". You can run this function: 42 | ======= 43 | Suppose you want to download the metadata from cases' opinions with the expression "excesso de prazo" ("beyond reasonable time"). You can proceed as follows: 44 | >>>>>>> a071f94bed4b3d364eba0338454c05d8f5331b2e 45 | 46 | ```{r example1,eval=FALSE} 47 | df<-stf_opinion_metadata(open_search="excesso de prazo") 48 | ``` 49 | 50 | Or simply: 51 | 52 | ```{r example2,eval=FALSE} 53 | df<-stf_opinion_metadata("excesso adj2 prazo") 54 | ``` 55 | 56 | By using "adj2" you are telling the search engine that "prazo" is one word apart from "excesso". 57 | 58 | If you want to search for monocratic decisions, you can use another functio: 59 | 60 | ```{r example3,eval=FALSE} 61 | df<-stf__mono_metadata("excesso adj2 prazo") 62 | ``` 63 | 64 | In order to find all the options, use the help function: 65 | 66 | ```{r example4,eval=FALSE} 67 | ?stf_opinion_metadata() 68 | ``` 69 | 70 | Suppose now that you want to read all cases where "Telefônica" is a party. You can add the suffix ".PART." to the search: 71 | 72 | ```{r example5,eval=FALSE} 73 | telefonicaDF<-stf_opinion_metadata("telefonica.PART.") 74 | ``` 75 | 76 | If you want to see all the possible suffixes, the function `stf_help_view()` will load the help page on the Rstudio viewer pane: 77 | 78 | ```{r example6,eval=FALSE} 79 | stf_help_view() 80 | ``` 81 | 82 | <<<<<<< HEAD 83 | ### Download whole opinion text (inteiro teor): 84 | 85 | Once you have imported the metadata, you can use the same data frame to import the whole decision. Beware that decisions published before 2011 and even some of that year are in pdf image, not text. Those decisions are converted to `png` and submmited to OCR in order to be read. 86 | The limitation is that it might take a long time to read all opinions. 87 | ======= 88 | ### Vocabulary correspondence 89 | 90 | The table below shows a rough translation of the Brazilian Supreme Court's opinion's elements to US English: 91 | 92 | |Portuguese |English | 93 | |--------------------|---------------------| 94 | |Acórdão |Opinion | 95 | |Ementa |Syllabus | 96 | |Relator |Reporter | 97 | |Ministro |Justice | 98 | |Órgão julgador |Judicial panel | 99 | |Decisão |Decision | 100 | |Processo |Docket number | 101 | |Parte |Party | 102 | |Acompanhamento |Docket sheet | 103 | |Classe |Petition type | 104 | |Prover/conceder |Reverse | 105 | |Desprover/denegar |Affirm | 106 | |Anular decisão |Remand | 107 | |Origem |Original jurisdiction| 108 | |Data da distribuição|Argued date | 109 | |Data do julgamento |Decision's date | 110 | 111 | 112 | ### Read the full opinion text (inteiro teor): 113 | 114 | Once you have imported the metadata, you can use the same data frame to import the full opinion's text. Beware that opinions published before 2011 and even some of that year are in pdf image, not in text. Those opinions are downloaded, converted to `png`, and subsequently submmited to OCR in order to be read. 115 | 116 | The limitation is that it takes a considerable amount of time to read the opinion's text. Without parallelization, one opinion can take up to 4 minutes to be read. As an example, 2000 opinions might take over five days to be read. 117 | >>>>>>> a071f94bed4b3d364eba0338454c05d8f5331b2e 118 | 119 | ```{r example7,eval=FALSE} 120 | decisionTelefonica<-stf_opinion(telefonicaDF[1,]). 121 | # Downloads just the first decision from the dataset imported above. 122 | ``` 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/persistent-state: -------------------------------------------------------------------------------- 1 | build-last-errors="[]" 2 | build-last-errors-base-dir="~/pacotes/stfstj/" 3 | build-last-outputs="[{\"output\":\"==> devtools::check(document = FALSE)\\n\\n\",\"type\":0},{\"output\":\"Setting env vars --------------------------------------------------------------\\n\",\"type\":1},{\"output\":\"CFLAGS : -Wall -pedantic\\n\",\"type\":1},{\"output\":\"CXXFLAGS: -Wall -pedantic\\n\",\"type\":1},{\"output\":\"Building stfstj ---------------------------------------------------------------\\n\",\"type\":1},{\"output\":\"'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet \\\\\\n\",\"type\":1},{\"output\":\" CMD build '/home/rstudio/pacotes/stfstj' --no-resave-data --no-manual \\n\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"* checking for file ‘/home/rstudio/pacotes/stfstj/DESCRIPTION’ ... OK\\n\",\"type\":1},{\"output\":\"* preparing ‘stfstj’:\\n\",\"type\":1},{\"output\":\"* checking DESCRIPTION meta-information ... OK\\n\",\"type\":1},{\"output\":\"* checking for LF line-endings in source and make files and shell scripts\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"* checking for empty or unneeded directories\\n\",\"type\":1},{\"output\":\"* building ‘stfstj_0.1.0.tar.gz’\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"Setting env vars --------------------------------------------------------------\\n\",\"type\":1},{\"output\":\"_R_CHECK_CRAN_INCOMING_USE_ASPELL_: TRUE\\n\",\"type\":1},{\"output\":\"_R_CHECK_CRAN_INCOMING_ : FALSE\\n\",\"type\":1},{\"output\":\"_R_CHECK_FORCE_SUGGESTS_ : FALSE\\n\",\"type\":1},{\"output\":\"Checking stfstj ---------------------------------------------------------------\\n\",\"type\":1},{\"output\":\"'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet \\\\\\n\",\"type\":1},{\"output\":\" CMD check '/tmp/RtmpVmRHQ6/stfstj_0.1.0.tar.gz' --as-cran --timings \\\\\\n\",\"type\":1},{\"output\":\" --no-manual \\n\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"* using log directory ‘/home/rstudio/pacotes/stfstj.Rcheck’\\n\",\"type\":1},{\"output\":\"* using R version 3.4.2 (2017-09-28)\\n\",\"type\":1},{\"output\":\"* using platform: x86_64-pc-linux-gnu (64-bit)\\n\",\"type\":1},{\"output\":\"* using session charset: UTF-8\\n\",\"type\":1},{\"output\":\"* using options ‘--no-manual --as-cran’\\n\",\"type\":1},{\"output\":\"* checking for file ‘stfstj/DESCRIPTION’ ... OK\\n\",\"type\":1},{\"output\":\"* this is package ‘stfstj’ version ‘0.1.0’\\n\",\"type\":1},{\"output\":\"* package encoding: UTF-8\\n\",\"type\":1},{\"output\":\"* checking package namespace information ... OK\\n\",\"type\":1},{\"output\":\"* checking package dependencies ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking if this is a source package ... OK\\n\",\"type\":1},{\"output\":\"* checking if there is a namespace ... OK\\n\",\"type\":1},{\"output\":\"* checking for executable files ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking for hidden files and directories ... OK\\n\",\"type\":1},{\"output\":\"* checking for portable file names ... OK\\n\",\"type\":1},{\"output\":\"* checking for sufficient/correct file permissions ... OK\\n\",\"type\":1},{\"output\":\"* checking whether package ‘stfstj’ can be installed ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking installed package size ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking package directory ... OK\\n\",\"type\":1},{\"output\":\"* checking DESCRIPTION meta-information ...\",\"type\":1},{\"output\":\" WARNING\\n\",\"type\":2},{\"output\":\"Non-standard license specification:\\n\",\"type\":1},{\"output\":\" License: MIT + file LICENSE\\n\",\"type\":1},{\"output\":\"Standardizable: FALSE\\n\",\"type\":1},{\"output\":\"* checking top-level files ... OK\\n\",\"type\":1},{\"output\":\"* checking for left-over files ... OK\\n\",\"type\":1},{\"output\":\"* checking index information ... OK\\n\",\"type\":1},{\"output\":\"* checking package subdirectories ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking R files for non-ASCII characters ...\",\"type\":1},{\"output\":\" WARNING\\n\",\"type\":2},{\"output\":\"Found the following files with non-ASCII characters:\\n\",\"type\":1},{\"output\":\" stf_metadados.R\\n\",\"type\":1},{\"output\":\" stf_monocratica.R\\n\",\"type\":1},{\"output\":\" stf_urls.R\\n\",\"type\":1},{\"output\":\"Portable packages must use only ASCII characters in their R code,\\n\",\"type\":1},{\"output\":\"except perhaps in comments.\\n\",\"type\":1},{\"output\":\"Use \\\\uxxxx escapes for other characters.\\n\",\"type\":1},{\"output\":\"* checking R files for syntax errors ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking whether the package can be loaded ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking whether the package can be loaded with stated dependencies ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking whether the package can be unloaded cleanly ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking whether the namespace can be loaded with stated dependencies ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking whether the namespace can be unloaded cleanly ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking loading without being on the library search path ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking dependencies in R code ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking S3 generic/method consistency ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking replacement functions ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking foreign function calls ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking R code for possible problems ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking Rd files ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking Rd metadata ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking Rd line widths ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking Rd cross-references ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking for missing documentation entries ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking for code/documentation mismatches ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking Rd \\\\usage sections ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking Rd contents ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking for unstated dependencies in examples ...\",\"type\":1},{\"output\":\" OK\\n\",\"type\":1},{\"output\":\"* checking examples ...\",\"type\":1},{\"output\":\" NONE\\n\",\"type\":1},{\"output\":\"* DONE\\n\",\"type\":1},{\"output\":\"Status: 2 WARNINGs\\n\",\"type\":1},{\"output\":\"checking DESCRIPTION meta-information ... WARNING\\n\",\"type\":2},{\"output\":\"Non-standard license specification:\\n\",\"type\":1},{\"output\":\" License: MIT + file LICENSE\\n\",\"type\":1},{\"output\":\"Standardizable: FALSE\\n\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"checking R files for non-ASCII characters ... WARNING\\n\",\"type\":2},{\"output\":\"Found the following files with non-ASCII characters:\\n\",\"type\":1},{\"output\":\" stf_metadados.R\\n\",\"type\":1},{\"output\":\" stf_monocratica.R\\n\",\"type\":1},{\"output\":\" stf_urls.R\\n\",\"type\":1},{\"output\":\"Portable packages must use only ASCII characters in their R code,\\n\",\"type\":1},{\"output\":\"except perhaps in comments.\\n\",\"type\":1},{\"output\":\"Use \\\\uxxxx escapes for other characters.\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"See\\n\",\"type\":1},{\"output\":\" ‘/home/rstudio/pacotes/stfstj.Rcheck/00check.log’\\n\",\"type\":1},{\"output\":\"for details.\\n\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"\\n\",\"type\":1},{\"output\":\"R CMD check results\\n\",\"type\":1},{\"output\":\"0 errors | 2 warnings | 0 notes\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"\\nR CMD check succeeded\\n\\n\",\"type\":1}]" 4 | compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}" 5 | files.monitored-path="" 6 | find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":true,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}" 7 | imageDirtyState="1" 8 | saveActionState="-1" 9 | -------------------------------------------------------------------------------- /R/stf__opinion_metadata.R: -------------------------------------------------------------------------------- 1 | # This function gets the urls according to the search parameters provided for 2 | # stf_opinion_metadata. So this function is going to be used inside the stf_panel_metadata function. 3 | 4 | 5 | stf_url<-function(x,y,w){ 6 | ## y will take the query parameter according to the options selected for the parameter database from stf_metadata function. 7 | 8 | 9 | ## Build url based on search, start and end parameters 10 | url1<-"http://www.stf.jus.br/portal/jurisprudencia/listarConsolidada.asp?base=baseAcordaos" 11 | 12 | url1<-httr::modify_url(url1,query=list(txtPesquisaLivre=x,dataFinal=w,dataInicial=y)) 13 | 14 | ## Encodes the URL replacing specially spaces by "%" plus the hexadecimal representation 15 | 16 | ## Gets the number of precedents 17 | numero_tinyurl<-httr::GET(url1) %>% 18 | httr::content() %>% 19 | xml2::xml_find_all("//*[@class='linkPagina']|//*[@class='linkPagina']/@href") %>% 20 | xml2::xml_text() 21 | 22 | ## 23 | paginas<-stringr::str_extract(numero_tinyurl[[1]],"\\d+") %>% 24 | as.numeric() %>% 25 | magrittr::divide_by(10) %>% 26 | ceiling() 27 | tinyURL<-numero_tinyurl[[2]] 28 | urls <- stringr::str_c("http://www.stf.jus.br/portal/jurisprudencia/",tinyURL,"&pagina=",1:paginas) 29 | } 30 | # End of the function 31 | 32 | # This functions encapsulates the previous function in the purrr::possibly function for the control 33 | # errors and the absense of results in the specified database. So this the actual function 34 | # that's going to be used. 35 | 36 | stf_urls<-purrr::possibly(stf_url,"ignore") 37 | # End of the function 38 | 39 | # STF parties description is very messy. This functions does its best to correct all the parties descriptions. 40 | stf_parties_names<-function(z){ 41 | z %>% 42 | purrr::map_chr(~{ 43 | .x %>% 44 | stringr::str_replace(stringr::regex("(adv|dpu).*\\s*",ignore_case = T),"Advogado") %>% 45 | stringr::str_replace(stringr::regex("AG.*E.*\\s*",ignore_case = T),"Agravante") %>% 46 | stringr::str_replace(stringr::regex("AG.*(o|a).*\\s*",ignore_case = T),"Agravado") %>% 47 | stringr::str_replace(stringr::regex(".*(COATOR|coatro|autoridade).*\\s*",ignore_case = T),"Coator") %>% 48 | stringr::str_replace(stringr::regex("emb.*(o|a).*\\s*",ignore_case = T),"Embargado") %>% 49 | stringr::str_replace(stringr::regex("emb.*e.*\\s*",ignore_case = T),"Embargante") %>% 50 | stringr::str_replace(stringr::regex("EXT.*\\s*",ignore_case = T),"Extraditando") %>% 51 | stringr::str_replace(stringr::regex("imp.*d.*\\s*",ignore_case = T),"Impetrado") %>% 52 | stringr::str_replace(stringr::regex("imp.*t.*\\s*|IMPRE\\s*",ignore_case = T),"Impetrante") %>% 53 | stringr::str_replace(stringr::regex("^p(a|c|e|t).*\\s*",ignore_case = T),"Paciente") %>% 54 | stringr::str_replace(stringr::regex(".*rec.*e.*\\s*",ignore_case = T),"Recorrente") %>% 55 | stringr::str_replace(stringr::regex(".*rec.*(o|a).*\\s*",ignore_case = T),"Recorrido") %>% 56 | stringr::str_replace(stringr::regex(".*req.*e.*\\s*",ignore_case = T),"Requerente") %>% 57 | stringr::str_replace(stringr::regex(".*req.*(o|a).*\\s*",ignore_case = T),"Requerido") %>% 58 | stringr::str_replace(stringr::regex("^proc.*\\s*",ignore_case = T),"Procurador") %>% 59 | stringr::str_replace(stringr::regex("^sus.*e.*\\s*",ignore_case = T),"Suscitante") %>% 60 | stringr::str_replace(stringr::regex("^sus.*(o|a).*\\s*",ignore_case = T),"Suscitado") %>% 61 | stringr::str_replace(stringr::regex(".*curiae.*\\s*",ignore_case = T),"Amicus_curiae") %>% 62 | stringr::str_replace(stringr::regex("rc.*e.*\\s*",ignore_case = T),"Reclamante") %>% 63 | stringr::str_replace(stringr::regex("rc.*(o|a).*\\s*",ignore_case = T),"Reclamado") %>% 64 | stringr::str_replace(stringr::regex("intd(o|a).*\\s*",ignore_case = T),"Interessado") %>% 65 | stringr::str_replace(stringr::regex("r\u00E9u*.*\\s*",ignore_case = T),"R\u00E9u") %>% 66 | stringr::str_replace(stringr::regex("autor.*",ignore_case = T),"Autor") %>% 67 | stringr::str_replace(stringr::regex("litis.*pass.*",ignore_case = T),"Listisconsorte_passivo") %>% 68 | stringr::str_replace(stringr::regex("litis.*at.*",ignore_case = T),"Listisconsorte_ativo") %>% 69 | stringr::str_replace(stringr::regex("DND(oa).*",ignore_case = T),"Denunciado") %>% 70 | stringr::str_replace(stringr::regex("inves(oa).*",ignore_case = T),"Investigado") 71 | 72 | }) 73 | } 74 | # End of the function 75 | 76 | # This is the main function. It collects all the metadata from the Brazilian 77 | # Supreme Court panel opinion. 78 | 79 | #' Returns metadada from Brazilian Supreme Court precedents 80 | #' 81 | #' @param open_search Words to be searched 82 | #' @param parties_names Logical. If TRUE (default), it will attempt to fix 83 | #' the parties prefixes. 84 | #' @param dt_start start date in the format "dd/mm/yyy" 85 | #' @param dt_end end date in the format "dd/mm/yyyy" 86 | #' 87 | #' @keywords stf, precedents, metadata 88 | #' 89 | #' @return Dataframe with the metadata 90 | #' 91 | #' @export 92 | stf_opinion_metadata<-function(open_search,dt_start,dt_end,parties_names=TRUE){ 93 | 94 | 95 | 96 | ## calls the stf_urls function to grab all urls. 97 | urls<-stf_urls(x=open_search,y=dt_start,w=dt_end) 98 | 99 | ## If nothing was found, it returns a error message informing that no precedent was found. 100 | assertthat::assert_that(urls[1]!="ignore",msg=paste("No precedent was found in the database")) 101 | 102 | ## This whole chunck collects the content of every ten precedents loaded by the urls 103 | 104 | urls %>% purrr::map_dfr(purrr::possibly(~{ 105 | 106 | ## Grabs the parsed page. 107 | principal<- .x %>% 108 | httr::GET() %>% 109 | httr::content() 110 | 111 | ## Unfortunately, stf doesn't have a tag for every element of the metadata. 112 | ## So in the same element div and class attribute "processosJurisprudenciaAcordaos" 113 | ## we get the lawsuit number, the appealed court, the procedural class and the name 114 | ## of the justice who reports the case, the occasional justice appointed to report that case, 115 | ## and date of the trial, and the Panel. 116 | 117 | recurso<-principal %>% 118 | xml2::xml_find_all("//div[@class='processosJurisprudenciaAcordaos']/p[1]/strong") %>% 119 | xml2::xml_text() %>% 120 | stringr::str_split("\n") 121 | 122 | processo<-recurso %>% 123 | purrr::map_chr(~stringr::str_extract(.x[[1]],".*?(?=\\/)")) 124 | 125 | origem<-recurso %>% 126 | purrr::map_chr(~stringr::str_extract(.x[[1]],"(?<=\\/).*")) %>% 127 | stringr::str_trim() 128 | 129 | 130 | classe<-recurso %>% 131 | purrr::map_chr(~stringr::str_trim(.x[[6]])) 132 | 133 | 134 | 135 | 136 | relator<-recurso %>% 137 | purrr::map_chr(~{ 138 | .x[[7]] %>% 139 | stringr::str_extract("(?<=Relator\\(a\\)\\:).*?(?=Relator|Julgamento)") %>% 140 | stringr::str_extract("(?<=Min\\.\\s).*") 141 | }) 142 | 143 | 144 | 145 | relator_acordao<- recurso %>% 146 | purrr::map_chr(~{ 147 | .x[[7]] %>% 148 | stringr::str_extract("(?<=Relator\\(a\\)\\sp\\/\\sAc\u00F3rd\u00E3o\\:).*(?=Julgamento)") %>% 149 | stringr::str_extract("(?<=Min\\.\\s).*") 150 | }) 151 | 152 | 153 | 154 | 155 | 156 | data_julgamento<- recurso %>% 157 | purrr::map_chr(~{ 158 | .x[[7]] %>% 159 | stringr::str_extract("\\d{2}\\/\\d{2}\\/\\d{4}") 160 | }) 161 | 162 | 163 | 164 | orgao_julgador<- recurso %>% 165 | purrr::map_chr(~{ 166 | .x[[7]] %>% 167 | stringr::str_extract("(?<=.rg.o Julgador\\:).*") 168 | }) 169 | 170 | 171 | ## Date of the decision's publication 172 | publicacao<-principal %>% 173 | xml2::xml_find_all("//p[strong='Publica\u00E7\u00E3o']/following-sibling::*[1]") %>% 174 | xml2::xml_text() 175 | 176 | data_publicacao<- publicacao %>% 177 | stringr::str_extract("(?<=PUBLIC\\s|DJ\\s)\\d{2}.\\d{2}.\\d{4}") 178 | 179 | ## In case of the Panel decision's report (acordãos), this will return whether it's electronic or not. 180 | ## This if information will be valueble to distinguish between reports that are text or images. 181 | 182 | eletronico<-publicacao %>% 183 | stringr::str_detect(stringr::regex("ELETR\u00D4NICO",ignore_case=TRUE)) 184 | 185 | 186 | ## This chunk will get all parties of the lawsuit and their respective descriptions. 187 | partes<-principal %>% 188 | xml2::xml_find_all("//p[strong[contains(.,'Parte')]]/following-sibling::pre[1]") %>% 189 | xml2::xml_text() %>% 190 | stringr::str_extract_all("\\w.*\\:.*(\r\n)*\\w*?") %>% 191 | 192 | purrr::modify_depth(1,~{ 193 | .x %>% 194 | setNames(stringr::str_extract(.,".*(?=\\:)")) 195 | }) 196 | 197 | partes<-dplyr::bind_rows(!!!partes) 198 | 199 | partes<-partes %>% 200 | purrr::map_dfr(~stringr::str_replace(.x,".*?(\\:\\s)","")) 201 | 202 | partes<-partes %>% 203 | dplyr::select(-dplyr::matches(stringr::regex("rela|red.*",ignore_case=TRUE))) 204 | 205 | if(parties_names){ 206 | names(partes)<-stf_parties_names(z=names(partes)) 207 | } 208 | 209 | ementa<- principal %>% 210 | 211 | xml2::xml_find_all("//div[contains(@style,'line-height: 150%;text-align: justify;')]") %>% 212 | xml2::xml_text() 213 | 214 | 215 | ## This chunk gets the decision. 216 | decisao_tag<-principal %>% 217 | xml2::xml_find_all("//strong[div/@style='line-height: 150%;text-align: justify;']/following-sibling::p[1]") %>% 218 | xml2::xml_text() 219 | 220 | 221 | decisao<-principal %>% 222 | xml2::xml_find_all("//strong[div/@style='line-height: 150%;text-align: justify;']/following-sibling::p[1]/../div[1]") %>% 223 | xml2::xml_text() 224 | 225 | 226 | decisao<-ifelse(decisao_tag=="Decis\u00E3o",decisao,"inexistente") 227 | 228 | voto<-decisao %>% purrr::map_chr(~{ 229 | if 230 | (stringr::str_detect(.x,stringr::regex("maioria",ignore_case=TRUE))){ 231 | "maioria" 232 | }else if (stringr::str_detect(.x,stringr::regex("un(a|\u00E2)nim.*",ignore_case=TRUE))){ 233 | "un\u00E2nime" 234 | }else if (stringr::str_detect(.x,stringr::regex("empate",ignore_case=TRUE))){ 235 | "empate" 236 | }else 237 | NA 238 | }) 239 | 240 | 241 | ## The code below gets the url of the Panel decision's report. 242 | url_inteiro_teor<-principal %>% 243 | xml2::xml_find_all("//li/a[contains(@href,'obterInteiroTeor')]") %>% 244 | xml2::xml_attrs() %>% 245 | stringr::str_extract("inteiroTeor.*") %>% 246 | stringr::str_c("http://www.stf.jus.br/portal/",.) 247 | 248 | 249 | ## The code below gets the timeline of the lawsuit 250 | url_andamento<-principal %>% 251 | xml2::xml_find_all("//div[@class='abasAcompanhamento']/ul[@class='abas']/li/a[contains(@href,'verProcessoAndamento')]") %>% 252 | xml2::xml_attrs() %>% 253 | stringr::str_extract("numero.*") %>% 254 | stringr::str_c("http://www.stf.jus.br/portal/processo/verProcessoAndamento.asp?",.) 255 | 256 | ## The code below creates a data frame with all the metadata grabbed above. 257 | data.frame(processo, origem, classe, relator, relator_acordao, 258 | data_julgamento, data_publicacao, orgao_julgador, 259 | eletronico, ementa, voto,decisao, url_inteiro_teor, 260 | url_andamento, partes, stringsAsFactors = FALSE) 261 | 262 | },data.frame(processo=NA_character_,origem=NA_character_,classe=NA_character_,relator=NA_character_,relator_acordao=NA_character_,data_julgamento=NA_character_,data_publicacao=NA_character_,orgao_julgador=NA_character_,eletronico=NA,ementa=NA_character_,voto=NA_character_,decisao=NA_character_,url_inteiro_teor=NA_character_,url_andamento=NA_character_,partes=NA_character_), 263 | quiet = FALSE 264 | )) 265 | } 266 | 267 | 268 | 269 | 270 | -------------------------------------------------------------------------------- /R/stf_mono_metadata.R: -------------------------------------------------------------------------------- 1 | # This function gets the urls according to the search parameters provided for 2 | # stf_mono_metadata. So this function is going to be used inside the stf_metadata function. 3 | 4 | 5 | stf_url<-function(x,y){ 6 | ## y will take the query parameter according to the options selected for the parameter database from stf_metadata function. 7 | 8 | 9 | ## Creates the url, x is the open_search parameter. 10 | url1<-stringr::str_c("http://www.stf.jus.br/portal/jurisprudencia/listarConsolidada.asp?txtPesquisaLivre=",x,"&base=baseMonocraticas") 11 | 12 | ## Encodes the URL replacing specially spaces by "%" plus the hexadecimal representation 13 | url1<-URLencode(url1) 14 | 15 | ## Gets the number of precedents 16 | numero_tinyurl<-httr::GET(url1) %>% 17 | httr::content() %>% 18 | xml2::xml_find_all("//*[@class='linkPagina']|//*[@class='linkPagina']/@href") %>% 19 | xml2::xml_text() 20 | 21 | ## 22 | paginas<-stringr::str_extract(numero_tinyurl[[1]],"\\d+") %>% 23 | as.numeric() %>% 24 | magrittr::divide_by(10) %>% 25 | ceiling() 26 | tinyURL<-numero_tinyurl[[2]] 27 | urls <- stringr::str_c("http://www.stf.jus.br/portal/jurisprudencia/",tinyURL,"&pagina=",1:paginas) 28 | } 29 | # End of the function 30 | 31 | # This functions encapsulates the previous function in the purrr::possibly function for the control 32 | # of errors and the absense of results in the specified database. So this the actual function 33 | # that's going to grab the data. 34 | 35 | stf_urls<-purrr::possibly(stf_url,"ignore") 36 | # End of the function 37 | 38 | # STF parties description is very messy. This functions does its best to correct all the parties descriptions. 39 | stf_parties_names<-function(z){ 40 | z %>% 41 | purrr::map_chr(~{ 42 | .x %>% 43 | stringr::str_replace(stringr::regex("(adv|dpu).*\\s*",ignore_case = T),"Advogado") %>% 44 | stringr::str_replace(stringr::regex("AG.*E.*\\s*",ignore_case = T),"Agravante") %>% 45 | stringr::str_replace(stringr::regex("AG.*(o|a).*\\s*",ignore_case = T),"Agravado") %>% 46 | stringr::str_replace(stringr::regex(".*(COATOR|coatro|autoridade).*\\s*",ignore_case = T),"Coator") %>% 47 | stringr::str_replace(stringr::regex("emb.*(o|a).*\\s*",ignore_case = T),"Embargado") %>% 48 | stringr::str_replace(stringr::regex("emb.*e.*\\s*",ignore_case = T),"Embargante") %>% 49 | stringr::str_replace(stringr::regex("EXT.*\\s*",ignore_case = T),"Extraditando") %>% 50 | stringr::str_replace(stringr::regex("imp.*d.*\\s*",ignore_case = T),"Impetrado") %>% 51 | stringr::str_replace(stringr::regex("imp.*t.*\\s*|IMPRE\\s*",ignore_case = T),"Impetrante") %>% 52 | stringr::str_replace(stringr::regex("^p(a|c|e|t).*\\s*",ignore_case = T),"Paciente") %>% 53 | stringr::str_replace(stringr::regex(".*rec.*e.*\\s*",ignore_case = T),"Recorrente") %>% 54 | stringr::str_replace(stringr::regex(".*rec.*(o|a).*\\s*",ignore_case = T),"Recorrido") %>% 55 | stringr::str_replace(stringr::regex(".*req.*e.*\\s*",ignore_case = T),"Requerente") %>% 56 | stringr::str_replace(stringr::regex(".*req.*(o|a).*\\s*",ignore_case = T),"Requerido") %>% 57 | stringr::str_replace(stringr::regex("^proc.*\\s*",ignore_case = T),"Procurador") %>% 58 | stringr::str_replace(stringr::regex("^sus.*e.*\\s*",ignore_case = T),"Suscitante") %>% 59 | stringr::str_replace(stringr::regex("^sus.*(o|a).*\\s*",ignore_case = T),"Suscitado") %>% 60 | stringr::str_replace(stringr::regex(".*curiae.*\\s*",ignore_case = T),"Amicus_curiae") %>% 61 | stringr::str_replace(stringr::regex("rc.*e.*\\s*",ignore_case = T),"Reclamante") %>% 62 | stringr::str_replace(stringr::regex("rc.*(o|a).*\\s*",ignore_case = T),"Reclamado") %>% 63 | stringr::str_replace(stringr::regex("intd(o|a).*\\s*",ignore_case = T),"Interessado") %>% 64 | stringr::str_replace(stringr::regex("r\u00E9u*.*\\s*",ignore_case = T),"R\u00E9u") %>% 65 | stringr::str_replace(stringr::regex("autor.*",ignore_case = T),"Autor") %>% 66 | stringr::str_replace(stringr::regex("litis.*pass.*",ignore_case = T),"Listisconsorte_passivo") %>% 67 | stringr::str_replace(stringr::regex("litis.*at.*",ignore_case = T),"Listisconsorte_ativo") %>% 68 | stringr::str_replace(stringr::regex("DND(oa).*",ignore_case = T),"Denunciado") %>% 69 | stringr::str_replace(stringr::regex("inves(oa).*",ignore_case = T),"Investigado") 70 | 71 | }) 72 | } 73 | # End of the function 74 | 75 | # This is the main function. It collects all the metadata. 76 | 77 | #' Returns metadada from Brazilian Supreme Court monocratic decisions 78 | #' 79 | #' @param open_search Words to be searched 80 | #' @param parties_names Logical. If TRUE (default), it will attempt to fix 81 | #' parties prefixes. 82 | #' 83 | #' @keywords stf, precedents, metadata 84 | #' 85 | #' @return Dataframe with the metadata 86 | #' 87 | #' @export 88 | stf_mono_metadata<-function(open_search,parties_names=TRUE){ 89 | 90 | ## calls the stf_urls function to grab all urls. 91 | urls<-stf_urls(x=open_search,y="&base=baseMonocraticas") 92 | 93 | ## If nothing was found, it returns a error message informing that no precedent was found. 94 | assertthat::assert_that(urls[1]!="ignore",msg=paste("No document was found in the database")) 95 | 96 | ## This whole chunck collects the content of every ten precedents loaded by the urls 97 | 98 | urls %>% purrr::map_dfr(purrr::possibly(~{ 99 | 100 | ## Grabs the parsed page. 101 | principal<- .x %>% 102 | httr::GET() %>% 103 | httr::content() 104 | 105 | ## Unfortunately, stf doesn't have a tag for every element of the metadata. 106 | ## So in the same element div and class attribute "processosJurisprudenciaAcordaos" 107 | ## we get the lawsuit number, the appealed court, the procedural class and the name 108 | ## of the justice who reports the case, the occasional justice appointed to report that case, 109 | ## and date of the trial, and the Panel. 110 | 111 | recurso<-principal %>% 112 | xml2::xml_find_all("//div[@class='processosJurisprudenciaAcordaos']/p[1]/strong") %>% 113 | xml2::xml_text() %>% 114 | stringr::str_split("\n") 115 | 116 | processo<-recurso %>% 117 | purrr::map_chr(~stringr::str_extract(.x[[1]],".*?(?=\\/)")) 118 | 119 | origem<-recurso %>% 120 | purrr::map_chr(~stringr::str_extract(.x[[1]],"(?<=\\/).*")) %>% 121 | stringr::str_trim() 122 | 123 | classe<-recurso %>% 124 | purrr::map_chr(~stringr::str_trim(.x[[2]])) 125 | 126 | 127 | 128 | relator<-recurso %>% 129 | purrr::map_chr(~{ 130 | .x[[3]] %>% 131 | stringr::str_extract("(?<=Relator\\(a\\)\\:).*?(?=Relator|Julgamento)") %>% 132 | stringr::str_extract("(?<=Min\\.\\s).*") 133 | }) 134 | 135 | 136 | 137 | 138 | 139 | 140 | data_julgamento<- recurso %>% 141 | purrr::map_chr(~{ 142 | .x[[3]] %>% 143 | stringr::str_extract("\\d{2}\\/\\d{2}\\/\\d{4}") 144 | }) %>% 145 | lubridate::dmy() 146 | 147 | 148 | 149 | 150 | 151 | ## Date of the decision's publication 152 | publicacao<-principal %>% 153 | xml2::xml_find_all("//p[strong='Publica\u00E7\u00E3o']/following-sibling::*[1]") %>% 154 | xml2::xml_text() 155 | 156 | data_publicacao<- publicacao %>% 157 | stringr::str_extract("(?<=PUBLIC\\s|DJ\\s)\\d{2}.\\d{2}.\\d{4}") %>% 158 | lubridate::dmy() 159 | 160 | ## In case of the Panel decision's report (acordãos), this will return whether it's electronic or not. 161 | ## This if information will be valueble to distinguish between reports that are text or images. 162 | 163 | ## This chunk will get all parties of the lawsuit and their respective descriptions. 164 | partes<-principal %>% 165 | xml2::xml_find_all("//p[strong[contains(.,'Parte')]]/following-sibling::pre[1]") %>% 166 | xml2::xml_text() %>% 167 | stringr::str_extract_all("\\w.*\\:.*(\r\n)*\\w*?") %>% 168 | 169 | purrr::modify_depth(1,~{ 170 | .x %>% 171 | setNames(stringr::str_extract(.,".*(?=\\:)")) 172 | }) 173 | 174 | partes<-dplyr::bind_rows(!!!partes) 175 | 176 | partes<-partes %>% 177 | purrr::map_dfr(~stringr::str_replace(.x,".*?(\\:\\s)","")) 178 | 179 | partes<-partes %>% 180 | dplyr::select(-dplyr::matches(stringr::regex("rela|red.*",ignore_case=TRUE))) 181 | 182 | if(parties_names){ 183 | names(partes)<-stf_parties_names(z=names(partes)) 184 | } 185 | 186 | 187 | ## This chunk gets the decision. 188 | 189 | decisao<-principal %>% 190 | xml2::xml_find_all("//p[strong='Decis\u00E3o']/following-sibling::pre[1]") %>% 191 | xml2::xml_text() 192 | 193 | 194 | 195 | ## The code below gets the url of the Panel decision's report. 196 | 197 | 198 | ## The code below gets the timeline of the lawsuit 199 | url_andamento<-principal %>% 200 | xml2::xml_find_all("//div[@class='abasAcompanhamento']/ul[@class='abas']/li/a[contains(@href,'verProcessoAndamento')]") %>% 201 | xml2::xml_attrs() %>% 202 | stringr::str_extract("numero.*") %>% 203 | stringr::str_c("http://www.stf.jus.br/portal/processo/verProcessoAndamento.asp?",.) 204 | 205 | ## The code below creates a data frame with all the metadata grabbed above. 206 | 207 | s<-data.frame(processo,origem,classe,relator,data_julgamento,data_publicacao,decisao,url_andamento,partes,stringsAsFactors = FALSE) 208 | 209 | },data.frame(processo=NA_character_,origem=NA_character_,classe=NA_character_,relator=NA_character_,data_julgamento=NA_character_,data_publicacao=NA_character_,decisao=NA_character_,url_andamento=NA_character_,partes=NA_character_), 210 | quiet = FALSE 211 | )) 212 | } 213 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /.Rproj.user/13C1E41B/console06/BBE25B02: -------------------------------------------------------------------------------- 1 | git checkout -b jjesusfilho-master master  2 | M .Rbuildignore 3 | M R/stf_metadados.R 4 | Switched to a new branch 'jjesusfilho-master' 5 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ git pull https://github.com/jjesusfilho/st tfstj.git master 6 | remote: Counting objects: 194, done. 7 | Receiving objects: 0% (1/194) Receiving objects: 1% (2/194) Receiving objects: 2% (4/194) Receiving objects: 3% (6/194) Receiving objects: 4% (8/194) Receiving objects: 5% (10/194) Receiving objects: 6% (12/194) Receiving objects: 7% (14/194) Receiving objects: 8% (16/194) Receiving objects: 9% (18/194) Receiving objects: 10% (20/194) Receiving objects: 11% (22/194) Receiving objects: 12% (24/194) Receiving objects: 13% (26/194) Receiving objects: 14% (28/194) Receiving objects: 15% (30/194) Receiving objects: 16% (32/194) Receiving objects: 17% (33/194) Receiving objects: 18% (35/194) Receiving objects: 19% (37/194) Receiving objects: 20% (39/194) Receiving objects: 21% (41/194) Receiving objects: 22% (43/194) Receiving objects: 23% (45/194) Receiving objects: 24% (47/194) Receiving objects: 25% (49/194) Receiving objects: 26% (51/194) Receiving objects: 27% (53/194) Receiving objects: 28% (55/194) Receiving objects: 29% (57/194) Receiving objects: 30% (59/194) Receiving objects: 31% (61/194) Receiving objects: 32% (63/194) Receiving objects: 33% (65/194) Receiving objects: 34% (66/194) Receiving objects: 35% (68/194) Receiving objects: 36% (70/194) Receiving objects: 37% (72/194) Receiving objects: 38% (74/194) Receiving objects: 39% (76/194) Receiving objects: 40% (78/194) Receiving objects: 41% (80/194) Receiving objects: 42% (82/194) Receiving objects: 43% (84/194) Receiving objects: 44% (86/194) Receiving objects: 45% (88/194) Receiving objects: 46% (90/194) Receiving objects: 47% (92/194) Receiving objects: 48% (94/194) Receiving objects: 49% (96/194) Receiving objects: 50% (97/194) Receiving objects: 51% (99/194) Receiving objects: 52% (101/194) Receiving objects: 53% (103/194) Receiving objects: 54% (105/194) Receiving objects: 55% (107/194) Receiving objects: 56% (109/194) Receiving objects: 57% (111/194) Receiving objects: 58% (113/194) Receiving objects: 59% (115/194) Receiving objects: 60% (117/194) Receiving objects: 61% (119/194) Receiving objects: 62% (121/194) Receiving objects: 63% (123/194) Receiving objects: 64% (125/194) Receiving objects: 65% (127/194) Receiving objects: 66% (129/194) Receiving objects: 67% (130/194) Receiving objects: 68% (132/194) Receiving objects: 69% (134/194) Receiving objects: 70% (136/194) Receiving objects: 71% (138/194) Receiving objects: 72% (140/194) Receiving objects: 73% (142/194) Receiving objects: 74% (144/194) Receiving objects: 75% (146/194) Receiving objects: 76% (148/194) Receiving objects: 77% (150/194) Receiving objects: 78% (152/194) Receiving objects: 79% (154/194) Receiving objects: 80% (156/194) Receiving objects: 81% (158/194) Receiving objects: 82% (160/194) Receiving objects: 83% (162/194) Receiving objects: 84% (163/194) Receiving objects: 85% (165/194) remote: Total 194 (delta 7), reused 7 (delta 7), pack-reused 187 8 | Receiving objects: 86% (167/194) Receiving objects: 87% (169/194) Receiving objects: 88% (171/194) Receiving objects: 89% (173/194) Receiving objects: 90% (175/194) Receiving objects: 91% (177/194) Receiving objects: 92% (179/194) Receiving objects: 93% (181/194) Receiving objects: 94% (183/194) Receiving objects: 95% (185/194) Receiving objects: 96% (187/194) Receiving objects: 97% (189/194) Receiving objects: 98% (191/194) Receiving objects: 99% (193/194) Receiving objects: 100% (194/194) Receiving objects: 100% (194/194), 41.87 KiB | 2.62 MiB/s, done. 9 | Resolving deltas: 0% (0/124) Resolving deltas: 8% (10/124) Resolving deltas: 10% (13/124) Resolving deltas: 16% (20/124) Resolving deltas: 32% (40/124) Resolving deltas: 39% (49/124) Resolving deltas: 44% (55/124) Resolving deltas: 46% (58/124) Resolving deltas: 54% (67/124) Resolving deltas: 59% (74/124) Resolving deltas: 63% (79/124) Resolving deltas: 71% (89/124) Resolving deltas: 79% (99/124) Resolving deltas: 80% (100/124) Resolving deltas: 82% (102/124) Resolving deltas: 84% (105/124) Resolving deltas: 87% (109/124) Resolving deltas: 94% (117/124) Resolving deltas: 95% (119/124) Resolving deltas: 96% (120/124) Resolving deltas: 100% (124/124) Resolving deltas: 100% (124/124), completed with 3 local objects. 10 | From https://github.com/jjesusfilho/stfstj 11 | * branch master -> FETCH_HEAD 12 | Updating 8b514a3..d0dc79b 13 | error: Your local changes to the following files would be overwritten by merge: 14 | .Rbuildignore 15 | R/stf_metadados.R 16 | Please commit your changes or stash them before you merge. 17 | error: The following untracked working tree files would be overwritten by merge: 18 | .travis.yml 19 | Please move or remove them before you merge. 20 | Aborting 21 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ git pull https://github.com/jjesusfilho/st tfstj.git master 22 | From https://github.com/jjesusfilho/stfstj 23 | * branch master -> FETCH_HEAD 24 | Updating 8b514a3..d0dc79b 25 | Fast-forward 26 | .Rbuildignore | 5 + 27 | .Rprofile | 1 + 28 | .travis.yml | 23 ++++ 29 | DESCRIPTION | 24 ++-- 30 | LICENSE | 2 + 31 | LICENSE.md | 21 ++++ 32 | NAMESPACE | 12 +- 33 | R/stf__opinion_metadata.R | 264 ++++++++++++++++++++++++++++++++++++++++++++ 34 | R/stf_acompanhamento.R | 10 +- 35 | R/stf_acordaos.R | 36 ------ 36 | R/stf_help_view.R | 18 +++ 37 | R/stf_metadados.R | 108 ------------------ 38 | R/stf_mono_metadata.R | 216 ++++++++++++++++++++++++++++++++++++ 39 | R/stf_monocratica.R | 70 ------------ 40 | R/stf_opinion.R | 39 +++++++ 41 | R/stf_thesaurus.R | 17 +++ 42 | R/stf_thesaurusDF.R | 36 ++++++ 43 | R/stf_urls.R | 27 ----- 44 | R/stfstj.R | 6 +- 45 | R/stj_mono_metadata.R | 94 ++++++++++++++++ 46 | R/stj_opinion_metadata.R | 123 +++++++++++++++++++++ 47 | R/utils.R | 8 ++ 48 | README.Rmd | 92 +++++++++++++++ 49 | README.md | 72 ++++++++++++ 50 | appveyor.yml | 45 ++++++++ 51 | man/stf_acordaos.Rd | 24 ---- 52 | man/stf_help_view.Rd | 21 ++++ 53 | man/stf_metadados.Rd | 19 ---- 54 | man/stf_mono_metadata.Rd | 23 ++++ 55 | man/stf_monocratica.Rd | 22 ---- 56 | man/stf_opinion.Rd | 26 +++++ 57 | man/stf_opinion_metadata.Rd | 23 ++++ 58 | man/stf_thesaurus.Rd | 21 ++++ 59 | man/stf_thesaurusDF.Rd | 21 ++++ 60 | man/stf_urls.Rd | 21 ---- 61 | man/stj_mono_metadata.Rd | 22 ++++ 62 | man/stj_opinion_metadata.Rd | 19 ++++ 63 | 37 files changed, 1284 insertions(+), 347 deletions(-) 64 | create mode 100644 .Rprofile 65 | create mode 100644 .travis.yml 66 | create mode 100644 LICENSE 67 | create mode 100644 LICENSE.md 68 | create mode 100644 R/stf__opinion_metadata.R 69 | delete mode 100644 R/stf_acordaos.R 70 | create mode 100644 R/stf_help_view.R 71 | delete mode 100644 R/stf_metadados.R 72 | create mode 100644 R/stf_mono_metadata.R 73 | delete mode 100644 R/stf_monocratica.R 74 | create mode 100644 R/stf_opinion.R 75 | create mode 100644 R/stf_thesaurus.R 76 | create mode 100644 R/stf_thesaurusDF.R 77 | delete mode 100644 R/stf_urls.R 78 | create mode 100644 R/stj_mono_metadata.R 79 | create mode 100644 R/stj_opinion_metadata.R 80 | create mode 100644 R/utils.R 81 | create mode 100644 README.Rmd 82 | create mode 100644 README.md 83 | create mode 100644 appveyor.yml 84 | delete mode 100644 man/stf_acordaos.Rd 85 | create mode 100644 man/stf_help_view.Rd 86 | delete mode 100644 man/stf_metadados.Rd 87 | create mode 100644 man/stf_mono_metadata.Rd 88 | delete mode 100644 man/stf_monocratica.Rd 89 | create mode 100644 man/stf_opinion.Rd 90 | create mode 100644 man/stf_opinion_metadata.Rd 91 | create mode 100644 man/stf_thesaurus.Rd 92 | create mode 100644 man/stf_thesaurusDF.Rd 93 | delete mode 100644 man/stf_urls.Rd 94 | create mode 100644 man/stj_mono_metadata.Rd 95 | create mode 100644 man/stj_opinion_metadata.Rd 96 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ git checkout master 97 | D .gitignore 98 | D man/stf_acompanhamento.Rd 99 | D man/stfstj.Rd 100 | D stfstj.Rproj 101 | Switched to branch 'master' 102 | Your branch is up to date with 'origin/master'. 103 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ git merge --no-ff jjesusfilho-master 104 | Removing man/stf_urls.Rd 105 | Removing man/stf_monocratica.Rd 106 | Removing man/stf_metadados.Rd 107 | Removing man/stf_acordaos.Rd 108 | Removing R/stf_urls.R 109 | Removing R/stf_monocratica.R 110 | Removing R/stf_metadados.R 111 | Removing R/stf_acordaos.R 112 | hint: Waiting for your editor to close the file... [?1000h[?2004h Merge made by the 'recursive' strategy. 113 | .Rbuildignore | 5 + 114 | .Rprofile | 1 + 115 | .travis.yml | 23 ++++ 116 | DESCRIPTION | 24 ++-- 117 | LICENSE | 2 + 118 | LICENSE.md | 21 ++++ 119 | NAMESPACE | 12 +- 120 | R/stf__opinion_metadata.R | 264 ++++++++++++++++++++++++++++++++++++++++++++ 121 | R/stf_acompanhamento.R | 10 +- 122 | R/stf_acordaos.R | 36 ------ 123 | R/stf_help_view.R | 18 +++ 124 | R/stf_metadados.R | 108 ------------------ 125 | R/stf_mono_metadata.R | 216 ++++++++++++++++++++++++++++++++++++ 126 | R/stf_monocratica.R | 70 ------------ 127 | R/stf_opinion.R | 39 +++++++ 128 | R/stf_thesaurus.R | 17 +++ 129 | R/stf_thesaurusDF.R | 36 ++++++ 130 | R/stf_urls.R | 27 ----- 131 | R/stfstj.R | 6 +- 132 | R/stj_mono_metadata.R | 94 ++++++++++++++++ 133 | R/stj_opinion_metadata.R | 123 +++++++++++++++++++++ 134 | R/utils.R | 8 ++ 135 | README.Rmd | 92 +++++++++++++++ 136 | README.md | 72 ++++++++++++ 137 | appveyor.yml | 45 ++++++++ 138 | man/stf_acordaos.Rd | 24 ---- 139 | man/stf_help_view.Rd | 21 ++++ 140 | man/stf_metadados.Rd | 19 ---- 141 | man/stf_mono_metadata.Rd | 23 ++++ 142 | man/stf_monocratica.Rd | 22 ---- 143 | man/stf_opinion.Rd | 26 +++++ 144 | man/stf_opinion_metadata.Rd | 23 ++++ 145 | man/stf_thesaurus.Rd | 21 ++++ 146 | man/stf_thesaurusDF.Rd | 21 ++++ 147 | man/stf_urls.Rd | 21 ---- 148 | man/stj_mono_metadata.Rd | 22 ++++ 149 | man/stj_opinion_metadata.Rd | 19 ++++ 150 | 37 files changed, 1284 insertions(+), 347 deletions(-) 151 | create mode 100644 .Rprofile 152 | create mode 100644 .travis.yml 153 | create mode 100644 LICENSE 154 | create mode 100644 LICENSE.md 155 | create mode 100644 R/stf__opinion_metadata.R 156 | delete mode 100644 R/stf_acordaos.R 157 | create mode 100644 R/stf_help_view.R 158 | delete mode 100644 R/stf_metadados.R 159 | create mode 100644 R/stf_mono_metadata.R 160 | delete mode 100644 R/stf_monocratica.R 161 | create mode 100644 R/stf_opinion.R 162 | create mode 100644 R/stf_thesaurus.R 163 | create mode 100644 R/stf_thesaurusDF.R 164 | delete mode 100644 R/stf_urls.R 165 | create mode 100644 R/stj_mono_metadata.R 166 | create mode 100644 R/stj_opinion_metadata.R 167 | create mode 100644 R/utils.R 168 | create mode 100644 README.Rmd 169 | create mode 100644 README.md 170 | create mode 100644 appveyor.yml 171 | delete mode 100644 man/stf_acordaos.Rd 172 | create mode 100644 man/stf_help_view.Rd 173 | delete mode 100644 man/stf_metadados.Rd 174 | create mode 100644 man/stf_mono_metadata.Rd 175 | delete mode 100644 man/stf_monocratica.Rd 176 | create mode 100644 man/stf_opinion.Rd 177 | create mode 100644 man/stf_opinion_metadata.Rd 178 | create mode 100644 man/stf_thesaurus.Rd 179 | create mode 100644 man/stf_thesaurusDF.Rd 180 | delete mode 100644 man/stf_urls.Rd 181 | create mode 100644 man/stj_mono_metadata.Rd 182 | create mode 100644 man/stj_opinion_metadata.Rd 183 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ git merge --no-ff jjesusfilho-mastergit push origin master 184 | To github.com:courtsbr/stfstj.git 185 | ! [rejected] master -> master (fetch first) 186 | error: failed to push some refs to 'git@github.com:courtsbr/stfstj.git' 187 | hint: Updates were rejected because the remote contains work that you do 188 | hint: not have locally. This is usually caused by another repository pushing 189 | hint: to the same ref. You may want to first integrate the remote changes 190 | hint: (e.g., 'git pull ...') before pushing again. 191 | hint: See the 'Note about fast-forwards' in 'git push --help' for details. 192 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ git merge --no-ff jjesusfilho-master 193 | Already up to date. 194 | ]0;/home/rstudio/pacotes/stfstj]0;rstudio@s2assessoria: ~/pacotes/stfstjrstudio@s2assessoria:~/pacotes/stfstj$ --------------------------------------------------------------------------------