This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | tjspPG<-function(livre="",quote=TRUE,classe="",assunto="",inicio="",fim=""){ | |
| if(quote==TRUE) livre<-deparse(livre) | |
| set_config(config(ssl_verifypeer = FALSE)) | |
| url<-"http://esaj.tjsp.jus.br/cjpg/pesquisar.do?conversationId=" | |
| a <- GET(url,query=list(`dadosConsulta.pesquisaLivre`=livre, | |
| `tipoNumero`="UNIFICADO", | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | devtools::install_github("jjesusfilho/tjsp") | |
| library(tjsp) | |
| library(quanteda) | |
| library(dplyr) | |
| library(textreadr) | |
| ## Extrai os metadados | |
| df<-tjsg_meta("audiencia de custodia") | |
| ## mantêm somente habeas corpus e mandado de segurança | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ufs<-tibble( | |
| sigla=c("AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO" ,"MA" ,"MS", "MT", "MG", "PA" ,"PB", "PR", "PE" ,"PI", | |
| "RJ", "RN", "RS", "RO", "RR", "SP", "SC", "SE", "TO"), | |
| estado=c("Acre","Alagoas","Amapá","Amazonas","Bahia","Ceará","Distrito Federal","Espírito Santo","Goiás","Maranhão","Mato Grosso do Sul","Mato Grosso","Minas Gerais","Pará","Paraíba","Paraná","Pernambuco","Piauí","Rio de Janeiro","Rio Grande do Norte","Rio Grande do Sul","Rondônia","Roraima","São Paulo","Santa Catarina","Sergipe","Tocantins")) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | install.packages("SPARQL") ## Instala o SPARQL no R | |
| library(SPARQL) ## Carrega o SPARQL | |
| ## Cria um objeto com o endpoint | |
| endpoint<-"http://www1.siop.planejamento.gov.br/sparql/" | |
| ## Constrói o query | |
| query<- | |
| "SELECT ?codExercicio ?data ?codEsfera ?descEsfera ?codOrgao ?descOrgao ?codUO ?descUO ?codFuncao ?descFuncao ?codSubfuncao ?descSubfuncao ?codPrograma ?descPrograma ?codAcao ?descAcao ?codSubtitulo ?descSubtitulo ?codPlanoOrcamentario ?descPlanoOrcamentario ?codFonte ?descFonte ?codCategoriaEconomica ?descCategoriaEconomica ?codGND ?descGND ?codModalidadeAplicacao ?descModalidadeAplicacao ?codIdUso ?descIdUso ?codResultadoPrimario ?descResultadoPrimario ?codElementoDespesa ?descElementoDespesa (sum(?val1) as ?ploa) (sum(?val2) as ?loa) (sum(?val3) as ?lei_mais_credito) (sum(?val4) as ?empenhado) (sum(?val5) as ?liquidado) (sum(?val6) as ?pago) WHERE { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | draw_confusion_matrix <- function(cm) { | |
| layout(matrix(c(1,1,2))) | |
| par(mar=c(2,2,2,2)) | |
| plot(c(100, 345), c(300, 450), type = "n", xlab="", ylab="", xaxt='n', yaxt='n') | |
| title('MATRIZ DE CONFUSAO', cex.main=2) | |
| # create the matrix | |
| rect(150, 430, 240, 370, col='#3F97D0') | |
| text(195, 435, 'Provido', cex=1.2) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Orientação | |
| # | |
| # Para selecionar os crimes, use os seguintes nomes: | |
| # | |
| # Para Taxa de homicídio, use: "TaxaHomicidio" | |
| # Para Homicídio doloso, use: "Homicicio" *** Atenção, é "Homicicio" e não "Homicidio"*** | |
| # Para Latrocínio, use: "Latrocinio" | |
| # Para Lesão corporal seguida de morte, use: "LesaoMorte" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #' Procura a palavra ou frase do segundo vetor que melhor | |
| #' se aproxima do primeiro. Particularmente útil para | |
| #' corrigir nomes de municípios. | |
| #' | |
| #' @param x Vetor de strings de referência. | |
| #' @param y Vetor de strings a serem buscados. | |
| #' | |
| #' @return vetor com as strings de y próximos | |
| #' de x. | |
| #' @export | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | g.log | |
| 0 info it worked if it ends with ok | |
| 1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'start' ] | |
| 2 info using [email protected] | |
| 3 info using [email protected] | |
| 4 verbose run-script [ 'prestart', 'start', 'poststart' ] | |
| 5 info lifecycle [email protected]~prestart: [email protected] | |
| 6 silly lifecycle [email protected]~prestart: no script for prestart, continuing | |
| 7 info lifecycle [email protected]~start: [email protected] | |
| 8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | url<-"https://archive.ics.uci.edu/ml/machine-learning-databases/voting-records/house-votes-84.data" | |
| df<-read.table(url, fileEncoding="UTF-8", sep=",") | |
| library(caret) | |
| set.seed(1984) | |
| ## Divide as bases | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(magrittr) | |
| months2<-function(date){ | |
| months_locale<-"1970-01-01" %>% | |
| as.Date() %>% | |
| seq.Date(by="month",len=12) %>% | |
| months() | |
| factor(months(date),ordered=TRUE,levels=months_locale) | |
| } |