GID_HuggingFace / main.py
giho905e's picture
Upload 30 files
84e78bb
raw
history blame
No virus
2.59 kB
#######################################################################################################
# IMPORT
#######################################################################################################
import pandas as pd
import geopandas as gpd
import os
from configparser import ConfigParser
# modules
from modules.geojson_github_loader import download_github_geojson
from modules.geojson_processor import geojson_processor_to_csv
from modules.language_model import TAPAS
#######################################################################################################
# CONFIG
#######################################################################################################
print('\nCurrent Working Directory (CWD):\n' + os.getcwd())
config_object = ConfigParser()
if 'config.ini' in os.listdir():
config_object.read('config.ini')
print('Setting have been imported from the config file.')
else:
print('No config file in the CWD')
quit()
# changing CWD and input output folders
os.chdir(format(config_object['CONFIG']['CWD']))
DATA = os.getcwd() + '\\' + format(config_object['CONFIG']['Input'])
OUT = os.getcwd() + '\\' + format(config_object['CONFIG']['Output'])
TEMP = os.getcwd() + '\\' + format(config_object['CONFIG']['Temp'])
#######################################################################################################
# Load and prepare Data
#######################################################################################################
# load github data
# attributes
github_user = "Giedeon25"
github_repo = "GID-Project"
file_path_github = "main/data/Input/gadm41_DEU_1.json"
token = "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"
local_file_path = DATA + '\\' + 'gadm41_DEU_1.json'
output_file = TEMP + '\\' + 'gadm41_DEU_1'
# load from GitHub
geojson_data = download_github_geojson(github_user, github_repo, file_path_github, token)
# load locally
geojson_data = gpd.read_file(local_file_path)
print(geojson_data.head())
# convert and save data
# attributes
# function
geojson_processor_to_csv(geojson_data, output_file)
#######################################################################################################
# LLM
#######################################################################################################
# attributes
question = 'what is the geometry of Saxony?'
table_main = pd.read_csv(TEMP + '\\' + 'gadm41_DEU_1_main').astype(str)
table_geom = pd.read_csv(TEMP + '\\' + 'gadm41_DEU_1_geom')
# function
TAPAS(question, table_main)