-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIPC_analysis.Rmd
45 lines (31 loc) · 1.23 KB
/
IPC_analysis.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: "IPC (Indian Penal Code) Notebook"
output: html_notebook
description: An analysis of the citations of sections of Indian Penal Code in the case laws from the High Courts and Supreme court of India
---
# Analysis of the citations of Indian Penal Code (IPC) Act using cases from [IndianKanoon](https://indiankanoon.org/)
> Please refer to this [link](https://indiankanoon.org/doc/1569253/) to access the original document of the IPC act
## All sections of the IPC
```{r include=FALSE}
library(dplyr)
library(rvest)
library(glue)
source("ik_scrape_functions.R")
act_id <- 1569253
ik_act_url <- glue::glue('https://indiankanoon.org/doc/{act_id}/')
print('Fetching links to sections and sub sections')
all_sections_of_act_link <- ik_act_url %>%
read_html() %>%
html_nodes(css = ".article a") %>%
html_attr('href') %>%
unlist()
section_id <- all_sections_of_act_link %>%
stringr::str_replace_all(pattern = "\\/doc\\/",replacement = "") %>%
stringr::str_trim() %>%
stringr::str_replace_all(pattern = "\\/",replacement = "")
# Adding the parent act
section_id <- c(act_id, section_id)
print('Starting to fetch citations')
all_sections_citations_df <- lapply(section_id, ik_case_summary_geography) %>%
dplyr::bind_rows()
```