Skip to content

Commit

Permalink
Update for cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JonanOribe committed Feb 21, 2023
1 parent 446913a commit c687c8d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
15 changes: 7 additions & 8 deletions models/case.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
class Case:
def __init__(self, case_ref,case_data:str):
self.case_ref:str = case_ref
def __init__(self, case_data:str):
self.resolution_type:str = case_data['TIPO_RESOLUCION']
self.resolution_number:str = case_data['NUMERO_RESOLUCION']
self.resolution_year:str = case_data['ANNO_RESOLUCION']
self.resolution_BIS:str = case_data['BIS_RESOLUCION']
self.resolution_number:int = case_data['NUMERO_RESOLUCION']
self.resolution_year:int = case_data['ANNO_RESOLUCION']
self.resolution_BIS:bool = case_data['BIS_RESOLUCION']

self.registration_date:str = case_data['FECHA_REGISTRO']
self.numeric_type:str = case_data['TIPO_NUMERADO']
Expand All @@ -13,15 +12,15 @@ def __init__(self, case_ref,case_data:str):

self.descriptive_synthesis:str = case_data['SINTESIS_DESCRIPTIVA']
self.analytic_synthesis:str = case_data['SINTESIS_ANALITICA']
self.boe_number:str = case_data['NUMERO_BOE']
self.boe_number:int = case_data['NUMERO_BOE']
self.boe_date:str = case_data['FECHA_BOE']

self.green_tome_number:str = case_data['NUMERO_TOMO_VERDE']
self.green_tome_number:int = case_data['NUMERO_TOMO_VERDE']
self.signature_date:str = case_data['FECHA_FIRMA']
self.boe_reference:str = case_data['REFERENCIA_BOE']
self.xml_boe_corrections:str = case_data['XML_CORRECCIONES_BOE']

self.last_update:str = case_data['ULTIMA_ACTUALIZACION']
self.content_irrelevant_for_internet:str = case_data['CONTENIDO_IRRELEVANTE_PARA_INTERNET']
self.content_irrelevant_for_internet:bool = case_data['CONTENIDO_IRRELEVANTE_PARA_INTERNET']
self.cache_date:str = case_data['FECHA_CACHE']

3 changes: 3 additions & 0 deletions scrapper/data_scrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from models.abstract import Abstract
from models.article import Article
from models.background import Background
from models.case import Case
from models.dictum import Dictum
from models.fundamentals import Fundamentals
from models.header import Header
Expand All @@ -17,6 +18,7 @@
class DataScrapper:
def __init__(self, source) -> None:
self.source:str = {section: dict(config.items(section)) for section in config.sections()}['URLS'][source.lower()]
self.cases:list[Case] = []
self.magistrates:list[Magistrate] = []
self.backgrounds:list[Background] = []
self.articles:list[Article] = []
Expand All @@ -35,6 +37,7 @@ def _save_data(self, file_name:str, data, format:str, output_path:str):
json.dump(data, outfile)
if format == 'graph':
case_ref = data['REFERENCIA_BOE']
self.cases.append(Case(data))
for elem in data['RESOLUCIONES_MAGISTRADOS']:
self.magistrates.append(Magistrate(case_ref,elem))
for elem in data['RESOLUCIONES_ANTECEDENTES']:
Expand Down
2 changes: 2 additions & 0 deletions scrapper/supreme_court_spain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def __init__(self,source:str, case_ids:List[str]):
self.case_ids:List = case_ids

def prepare_csv(self,output_path:str):
cases_json = json.loads(json.dumps([ob.__dict__ for ob in self.cases]))
pd.DataFrame.from_records(cases_json).to_csv(output_path+'cases.csv',index=False)
magistrates_json = json.loads(json.dumps([ob.__dict__ for ob in self.magistrates]))
pd.DataFrame.from_records(magistrates_json).to_csv(output_path+'magistrates.csv',index=False)
backgrounds_json = json.loads(json.dumps([ob.__dict__ for ob in self.backgrounds]))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# This call to setup() does all the work
setup(
name="lawLib",
version="0.5.1",
version="0.5.2",

description="Library to extract legal information from official resources",
long_description=long_description,
Expand Down

0 comments on commit c687c8d

Please sign in to comment.