diff --git a/documentation/imgs/LSTM_arch.png b/documentation/imgs/LSTM_arch.png index 79ccd79a1e8c2cce83fadd95d52a82f17c1bd691..76768fefd22f3756fae7a7abcbd7eab87e406e63 100644 Binary files a/documentation/imgs/LSTM_arch.png and b/documentation/imgs/LSTM_arch.png differ diff --git a/documentation/imgs/first_approach.png b/documentation/imgs/first_approach.png index 4b83d1184fc92e154510c934ecea41b4e80455ce..297c1a5025d993acfae6e501d88acac24dfc7e59 100644 Binary files a/documentation/imgs/first_approach.png and b/documentation/imgs/first_approach.png differ diff --git a/documentation/imgs/second_approach.png b/documentation/imgs/second_approach.png index bdff5964c3796980e518eb0f9aa724bd836e0ca6..e5e693fbaf11113de2673b366d4bf603047239c2 100644 Binary files a/documentation/imgs/second_approach.png and b/documentation/imgs/second_approach.png differ diff --git a/documentation/imgs/third_approach.png b/documentation/imgs/third_approach.png index ea8e6aaa02e19084a61e346ebacff25139cc63cb..d96596ad9ee35b8ada81b0a68535e593ed8e1a0e 100644 Binary files a/documentation/imgs/third_approach.png and b/documentation/imgs/third_approach.png differ diff --git a/lib/geocoder.py b/lib/geocoder.py index d0c44b13de7cd53b1812d59e135daa130b8a5272..2ea2e250683a9cdb005dc127b688ff43f334c347 100644 --- a/lib/geocoder.py +++ b/lib/geocoder.py @@ -3,6 +3,7 @@ import os #Â DATA LIB import numpy as np +import pandas as pd #Â DL LIB import tensorflow as tf @@ -82,7 +83,7 @@ def heuritic_mean(geocoder,data): toponyms = data.text.unique() input_ = np.asarray([[t1,t2] for t2 in toponyms for t1 in toponyms if t2 != t1]) res_geocode = pd.DataFrame(input_,columns="t tc".split()) - lons,lats = geocoder.get_coords(input_[:,0],input_[:,1]) + lons,lats = geocoder.wgs_coord(*geocoder.get_coords(input_[:,0],input_[:,1])) res_geocode["lon"] = lons res_geocode["lat"] = lats results = {} @@ -97,7 +98,7 @@ class TextGeocoder(): self.geocoder_model = geocoder_model self.ner_name = ner_name self.ner_model = None - if self.ner == "stanza": + if self.ner_name == "stanza": self.ner_model = stanza.Pipeline(lang) else: self.ner_model = spacy.load(lang) @@ -114,5 +115,7 @@ class TextGeocoder(): def geocode(self,entities): df = pd.DataFrame(entities) - results = self.heuristic_func(self.geocoder_model,df) - return results + heuristic_results = self.heuristic_func(self.geocoder_model,df) + for e in range(len(entities)): + entities[e]["coord"] = heuristic_results[entities[e]["text"]] + return entities diff --git a/server.py b/server.py index 0b59ac9ec89bd56a499887db8d8c010934148f1b..7b7cb4cf6ed7a532fa300275877061fb9ceb38f2 100644 --- a/server.py +++ b/server.py @@ -1,7 +1,7 @@ from flask import Flask, escape, request, render_template -from lib.geocoder import Geocoder +#from lib.geocoder import Geocoder -geocoder = Geocoder("./outputs/GB_MODEL_2/GB.txt_100_4_100__A_I_C.h5","./outputs/GB_MODEL_2/GB.txt_100_4_100__A_I_C_index") +geocoder = None#Geocoder("./outputs/GB_MODEL_2/GB.txt_100_4_100__A_I_C.h5","./outputs/GB_MODEL_2/GB.txt_100_4_100__A_I_C_index") app = Flask(__name__) @app.route('/') @@ -17,4 +17,8 @@ def home(): @app.route('/text') def text(): - return render_template("text.html",title="Text Geocoder") \ No newline at end of file + return render_template("text.html",title="Text Geocoder") + +@app.route('/geocode') +def geocode(): + pass \ No newline at end of file diff --git a/templates/text.html b/templates/text.html index 53aff30259b13535e617b7ba923c7f384e29dc19..0109f22edf40df052b1f6957612ffecca2cf2f65 100644 --- a/templates/text.html +++ b/templates/text.html @@ -1,16 +1,29 @@ -{% extends 'skeleton.html' %} - -{% block content %} +{% extends 'skeleton.html' %} {% block content %} <!-- MAP RENDER --> <div id="mapid"></div> <!-- TOPONYM FORM --> -<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Laborum, modi natus ab repellendus ex explicabo, sunt fuga commodi porro ipsam deserunt facilis culpa aspernatur odio tenetur quibusdam perferendis ipsum cupiditate?</p> -{% endblock %} - -{% block script %} +<div class="container"> + <p> + + </p> + <form action=""> + <div class="form-group"> + <label for="exampleFormControlTextarea1">Your text</label> + <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea> + <br> + <button class="btn btn-info" id="submit">Geocode</button> + + </div> + </form> + <h5>Results :</h5> + <div class="col-lg-12" style="border:1px solid #666"> + <p id="result_container"></p> + </div> +</div> + +{% endblock %} {% block script %} <script> - // Initialize the map // [50, -0.1] are the latitude and longitude // 4 is the zoom @@ -22,11 +35,7 @@ // Add a tile to the map = a background. Comes from OpenStreetmap L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a>', - }).addTo(mymap); - - var marker = L.marker([{{lat}}, {{lon}}]).addTo(mymap); - - + attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a>', + }).addTo(mymap); </script> {% endblock %} \ No newline at end of file