« BioPathBot » : différence entre les versions

De Wikipast
Aller à la navigation Aller à la recherche
(Wikipastbot update)
(Wikipastbot update)
Ligne 4 : Ligne 4 :
==Description==
==Description==


Depuis une databiographie suivant le format utilisé sur le wiki (ex: 1890.03.19 / Genève), le BioPathBot est capable d'extraire les informations temporelles et spatiales. Ces deux données forment un tuple et sont parsées de façon suivante :  
Depuis une <span style="color:red">databiographie</span> (correction(s): <span style="color:green">
</span>) suivant le format utilisé sur le <span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki
</span>) (<span style="color:red">ex</span> (correction(s): <span style="color:green">exo, en, eu, eux, es, eh, et, x, e, rex, tex
</span>): 1890.03.19 / Genève), le BioPathBot est capable d'extraire les informations temporelles et spatiales. Ces deux données forment un <span style="color:red">tuple</span> (correction(s): <span style="color:green">tuile, tulle
</span>) et sont <span style="color:red">parsées</span> (correction(s): <span style="color:green">parées, pansées, parlées, passées
</span>) de façon suivante :  
*La date est formée d'une année, d'un mois et d'un jour. Si des informations venaient à manquer, la date est complétée par défaut avec le mois de janvier et le premier du mois.  
*La date est formée d'une année, d'un mois et d'un jour. Si des informations venaient à manquer, la date est complétée par défaut avec le mois de janvier et le premier du mois.  
*Le lieu est transformé en coordonnées géographiques (utilisant la librairie python [https://pypi.python.org/pypi/geopy geopy])
*Le lieu est transformé en coordonnées géographiques (utilisant la librairie python [<span style="color:red">https</span> (correction(s): <span style="color:green">
</span>)://pypi.python.<span style="color:red">org</span> (correction(s): <span style="color:green">orge, ore, ors, or, ort, ord, erg
</span>)/pypi/<span style="color:red">geopy</span> (correction(s): <span style="color:green">
</span>) <span style="color:red">geopy</span> (correction(s): <span style="color:green">
</span>)])


Ainsi transformées et triées chronologiquement, ces données  permettent de générer une carte utilisant [http://matplotlib.org/basemap/index.html basemap], où sont dessinés des points pour marquer les lieux, ainsi que des traits mettant en avant la trajectoire de la personne. Cette carte est ensuite importée sur wikipast puis insérée sur une page annexe.
Ainsi transformées et triées chronologiquement, ces données  permettent de générer une carte utilisant [<span style="color:red">http</span> (correction(s): <span style="color:green">
</span>)://<span style="color:red">matplotlib</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">org</span> (correction(s): <span style="color:green">orge, ore, ors, or, ort, ord, erg
</span>)/<span style="color:red">basemap</span> (correction(s): <span style="color:green">
</span>)/index.html <span style="color:red">basemap</span> (correction(s): <span style="color:green">
</span>)], où sont dessinés des points pour marquer les lieux, ainsi que des traits mettant en avant la trajectoire de la personne. Cette carte est ensuite importée sur <span style="color:red">wikipast</span> (correction(s): <span style="color:green">
</span>) puis insérée sur une page annexe.


Par exemple la carte de [[Jean Tinguely]] se visualise comme:
Par exemple la carte de [[Jean Tinguely]] se visualise comme:
Ligne 18 : Ligne 33 :
*Peu importe le type de page (une page concernant une personne, un hypermot...), une carte est générée. Donc si une page ne relate pas la vie d'une personne, la carte aura peu de sens.
*Peu importe le type de page (une page concernant une personne, un hypermot...), une carte est générée. Donc si une page ne relate pas la vie d'une personne, la carte aura peu de sens.


*Avec l'algorithme actuel, les dates et les lieux sont parfaitement extraits et placé sur la carte. Cependant, si les données ne sont pas suffisamment précises, elles seront approximées (1980 devient 1980.01.01 tandis que le point géographique correspondant à la Suisse sera son centre géographique). Cela peut mener à des erreurs de trajectoire lors du tri chronologique ou simplement à une position différente de la réalité sur la carte.
*Avec l'algorithme actuel, les dates et les lieux sont parfaitement extraits et placé sur la carte. Cependant, si les données ne sont pas suffisamment précises, elles seront <span style="color:red">approximées</span> (correction(s): <span style="color:green">
</span>) (1980 devient 1980.01.01 <span style="color:red">tandis</span> (correction(s): <span style="color:green">candis, tendis, taudis
</span>) que le point géographique correspondant à la Suisse sera son centre géographique). Cela peut mener à des erreurs de trajectoire lors du tri chronologique ou simplement à une position différente de la réalité sur la carte.


*S'il existe des événements post-mortem mais que la mort de la personne n'est pas mentionnée ou ne suit pas la convention de l'hypermot [[Décès]], ces données seront aussi extraites et placées sur la carte, alors même que la personne ne se déplace pas.
*S'il existe des événements post-<span style="color:red">mortem</span> (correction(s): <span style="color:green">mortel, mortes, morte
</span>) mais que la mort de la personne n'est pas mentionnée ou ne suit pas la convention de l'hypermot [[Décès]], ces données seront aussi extraites et placées sur la carte, alors même que la personne ne se déplace pas.


*Si des événements sont spatialement trop proches, ils vont se superposer sur la carte et il deviendra difficile de retracer les événements d'une façon visuellement claire. Par exemple, pour un trait entre Berne et Lausanne, il sera difficile de juger si une personne a fait plusieurs fois ce même déplacement ou ne l'a fait qu'une seule fois au cours de sa vie.
*Si des événements sont spatialement trop proches, ils vont se superposer sur la carte et il deviendra difficile de retracer les événements d'une façon visuellement claire. Par exemple, pour un trait entre Berne et Lausanne, il sera difficile de juger si une personne a fait plusieurs fois ce même déplacement ou ne l'a fait qu'une seule fois au cours de sa vie.
Ligne 30 : Ligne 48 :
==Code==
==Code==


   import urllib.request
   import <span style="color:red">urllib</span> (correction(s): <span style="color:green">
   import requests
</span>).<span style="color:red">request</span> (correction(s): <span style="color:green">
   from bs4 import BeautifulSoup
</span>)
   import <span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>)
   <span style="color:red">from</span> (correction(s): <span style="color:green">rom, froc
</span>) <span style="color:red">bs</span> (correction(s): <span style="color:green">bé, ès, s, by, bi, bis, b, es, bus, bas, as, bu, os, us
</span>)4 import BeautifulSoup
   import re
   import re
   import math
   import math
   import datetime
   import <span style="color:red">datetime</span> (correction(s): <span style="color:green">
   from geopy.geocoders import Nominatim
</span>)
   from mpl_toolkits.basemap import Basemap
   <span style="color:red">from</span> (correction(s): <span style="color:green">rom, froc
   import matplotlib.pyplot as plt
</span>) <span style="color:red">geopy</span> (correction(s): <span style="color:green">
   from colorsys import hsv_to_rgb
</span>).<span style="color:red">geocoders</span> (correction(s): <span style="color:green">
   from matplotlib.colors import rgb2hex
</span>) import Nominatim
   <span style="color:red">from</span> (correction(s): <span style="color:green">rom, froc
</span>) <span style="color:red">mpl</span> (correction(s): <span style="color:green">mil, mal, mol, ml
</span>)_<span style="color:red">toolkits</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">basemap</span> (correction(s): <span style="color:green">
</span>) import Basemap
   import <span style="color:red">matplotlib</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">pyplot</span> (correction(s): <span style="color:green">
</span>) as <span style="color:red">plt</span> (correction(s): <span style="color:green">plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot
</span>)
   <span style="color:red">from</span> (correction(s): <span style="color:green">rom, froc
</span>) <span style="color:red">colorsys</span> (correction(s): <span style="color:green">
</span>) import <span style="color:red">hsv</span> (correction(s): <span style="color:green">hiv
</span>)_to_<span style="color:red">rgb</span> (correction(s): <span style="color:green">rab
</span>)
   <span style="color:red">from</span> (correction(s): <span style="color:green">rom, froc
</span>) <span style="color:red">matplotlib</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">colors</span> (correction(s): <span style="color:green">colore, coloris, colorés, colos, colora, coloré, colons
</span>) import <span style="color:red">rgb</span> (correction(s): <span style="color:green">rab
</span>)2<span style="color:red">hex</span> (correction(s): <span style="color:green">hem, heu, hep, rex, tex
</span>)
   SEGMENTS = 100
   SEGMENTS = 100
    
    
   # draw plots inline rather than in a seperate window
   # <span style="color:red">draw</span> (correction(s): <span style="color:green">drap, drag
   %matplotlib inline
</span>) plots <span style="color:red">inline</span> (correction(s): <span style="color:green">incline
   # draw plots bigger
</span>) <span style="color:red">rather</span> (correction(s): <span style="color:green">ratier, rater
   plt.rcParams["figure.figsize"] = [20.0, 10.0]
</span>) <span style="color:red">than</span> (correction(s): <span style="color:green">tian, ahan, tan, thon, thaï, han, khan
</span>) in a <span style="color:red">seperate</span> (correction(s): <span style="color:green">
</span>) <span style="color:red">window</span> (correction(s): <span style="color:green">
</span>)
   %<span style="color:red">matplotlib</span> (correction(s): <span style="color:green">
</span>) <span style="color:red">inline</span> (correction(s): <span style="color:green">incline
</span>)
   # <span style="color:red">draw</span> (correction(s): <span style="color:green">drap, drag
</span>) plots <span style="color:red">bigger</span> (correction(s): <span style="color:green">bigler, jigger
</span>)
   <span style="color:red">plt</span> (correction(s): <span style="color:green">plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot
</span>).rcParams["figure.figsize"] = [20.0, 10.0]
    
    
   user='BioPathBot'
   user='BioPathBot'
   passw='chkiroju'
   <span style="color:red">passw</span> (correction(s): <span style="color:green">passe, passé, passa
   baseurl='http://wikipast.epfl.ch/wikipast/'
</span>)='<span style="color:red">chkiroju</span> (correction(s): <span style="color:green">
   summary='Wikipastbot update'
</span>)'
   protected_logins=["Frederickaplan","Maud","Vbuntinx","Testbot","IB","SourceBot","PageUpdaterBot","Orthobot","BioPathBot","ChronoBOT","Amonbaro","AntoineL","AntoniasBan  deros","Arnau","Arnaudpannatier","Aureliver","Brunowicht","Burgerpop","Cedricviaccoz","Christophe","Claudioloureiro","Ghislain","Gregoire3245","Hirtg","Houssm","Icebak  er","JenniCin","JiggyQ","JulienB","Kl","Kperrard","Leandro  Kieliger","Marcus","Martin","MatteoGiorla","Mireille","Mj2905","Musluoglucem","Nacho","Nameless","Nawel","O'showa","PA","Qantik","QuentinB","Raphael.barman","Roblan11"  ,"Romain Fournier","Sbaaa","Snus","Sonia","Tboyer","Thierry","Titi","Vlaedr","Wanda"]
   <span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)='<span style="color:red">http</span> (correction(s): <span style="color:green">
</span>)://<span style="color:red">wikipast</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">epfl</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">ch</span> (correction(s): <span style="color:green">chu, co, h, ce, ah, eh, c, ph, oh, ci, cm, chi
</span>)/<span style="color:red">wikipast</span> (correction(s): <span style="color:green">
</span>)/'
   <span style="color:red">summary</span> (correction(s): <span style="color:green">
</span>)='Wikipastbot update'
   <span style="color:red">protected</span> (correction(s): <span style="color:green">
</span>)_<span style="color:red">logins</span> (correction(s): <span style="color:green">logis, login, lopins, logions
</span>)=["Frederickaplan","Maud","Vbuntinx","Testbot","IB","SourceBot","PageUpdaterBot","Orthobot","BioPathBot","ChronoBOT","Amonbaro","AntoineL","AntoniasBan  deros","Arnau","Arnaudpannatier","Aureliver","Brunowicht","Burgerpop","Cedricviaccoz","Christophe","Claudioloureiro","Ghislain","Gregoire3245","Hirtg","Houssm","Icebak  er","JenniCin","JiggyQ","JulienB","Kl","Kperrard","Leandro  Kieliger","Marcus","Martin","MatteoGiorla","Mireille","Mj2905","Musluoglucem","Nacho","Nameless","Nawel","O'showa","PA","Qantik","QuentinB","Raphael.barman","Roblan11"  ,"Romain Fournier","Sbaaa","Snus","Sonia","Tboyer","Thierry","Titi","Vlaedr","Wanda"]
   depuis_date='2017-05-02T16:00:00Z'
   depuis_date='2017-05-02T16:00:00Z'
   liste_pages=[]
   liste_pages=[]
   for user in protected_logins:
   for user in <span style="color:red">protected</span> (correction(s): <span style="color:green">
       result=requests.post(baseurl+'api.php?action=query&list=usercontribs&ucuser='+user+'&format=xml&ucend='+depuis_date)
</span>)_<span style="color:red">logins</span> (correction(s): <span style="color:green">logis, login, lopins, logions
       soup=BeautifulSoup(result.content,'lxml')
</span>):
       for primitive in soup.usercontribs.findAll('item'):
       <span style="color:red">result</span> (correction(s): <span style="color:green">
           liste_pages.append(primitive['title'])
</span>)=<span style="color:red">requests</span> (correction(s): <span style="color:green">
           print(primitive['title'])
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)+'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)?action=<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)&<span style="color:red">list</span> (correction(s): <span style="color:green">liste, listé, lise, lest, lis, liât, lift, lit
</span>)=<span style="color:red">usercontribs</span> (correction(s): <span style="color:green">
</span>)&<span style="color:red">ucuser</span> (correction(s): <span style="color:green">
</span>)='+user+'&format=<span style="color:red">xml</span> (correction(s): <span style="color:green">ml
</span>)&<span style="color:red">ucend</span> (correction(s): <span style="color:green">
</span>)='+depuis_date)
       <span style="color:red">soup</span> (correction(s): <span style="color:green">houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue
</span>)=BeautifulSoup(<span style="color:red">result</span> (correction(s): <span style="color:green">
</span>).content,'<span style="color:red">lxml</span> (correction(s): <span style="color:green">
</span>)')
       for primitive in <span style="color:red">soup</span> (correction(s): <span style="color:green">houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue
</span>).<span style="color:red">usercontribs</span> (correction(s): <span style="color:green">
</span>).findAll('item'):
           liste_pages.<span style="color:red">append</span> (correction(s): <span style="color:green">appends, appendu, apprend
</span>)(primitive['<span style="color:red">title</span> (correction(s): <span style="color:green">tille, titre
</span>)'])
           <span style="color:red">print</span> (correction(s): <span style="color:green">peint, prin, priant, priât, point, sprint, prit, prient
</span>)(primitive['<span style="color:red">title</span> (correction(s): <span style="color:green">tille, titre
</span>)'])
    
    
   names=list(set(liste_pages))
   <span style="color:red">names</span> (correction(s): <span style="color:green">nases, dames, lames, nages, nazes, cames, rames
</span>)=<span style="color:red">list</span> (correction(s): <span style="color:green">liste, listé, lise, lest, lis, liât, lift, lit
</span>)(set(liste_pages))
    
    
   # Login request
   # Login <span style="color:red">request</span> (correction(s): <span style="color:green">
   payload={'action':'query','format':'json','utf8':'','meta':'tokens','type':'login'}
</span>)
   r1=requests.post(baseurl + 'api.php', data=payload)
   <span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>)={'action':'<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)','format':'<span style="color:red">json</span> (correction(s): <span style="color:green">son
</span>)','<span style="color:red">utf</span> (correction(s): <span style="color:green">urf, ut
</span>)8':'','<span style="color:red">meta</span> (correction(s): <span style="color:green">jeta, feta, mata, méta, mena, mets, met, mesa, mita
</span>)':'<span style="color:red">tokens</span> (correction(s): <span style="color:green">
</span>)','type':'login'}
   <span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)1=<span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>) + 'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)', data=<span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>))
    
    
   #login confirm
   #login <span style="color:red">confirm</span> (correction(s): <span style="color:green">confire, confirma, confirme, confirmé
   login_token=r1.json()['query']['tokens']['logintoken']
</span>)
   payload={'action':'login','format':'json','utf8':'','lgname':user,'lgpassword':passw,'lgtoken':login_token}
   login_<span style="color:red">token</span> (correction(s): <span style="color:green">
   r2=requests.post(baseurl + 'api.php', data=payload, cookies=r1.cookies)
</span>)=r1.<span style="color:red">json</span> (correction(s): <span style="color:green">son
</span>)()['<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)']['<span style="color:red">tokens</span> (correction(s): <span style="color:green">
</span>)']['logintoken']
   <span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>)={'action':'login','format':'<span style="color:red">json</span> (correction(s): <span style="color:green">son
</span>)','<span style="color:red">utf</span> (correction(s): <span style="color:green">urf, ut
</span>)8':'','<span style="color:red">lgname</span> (correction(s): <span style="color:green">igname
</span>)':user,'<span style="color:red">lgpassword</span> (correction(s): <span style="color:green">
</span>)':passw,'<span style="color:red">lgtoken</span> (correction(s): <span style="color:green">
</span>)':login_token}
   <span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)2=<span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>) + 'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)', data=<span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>), cookies=<span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)1.cookies)
    
    
   #get edit token2
   #<span style="color:red">get</span> (correction(s): <span style="color:green">cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut
   params3='?format=json&action=query&meta=tokens&continue='
</span>) <span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
   r3=requests.get(baseurl + 'api.php' + params3, cookies=r2.cookies)
</span>) <span style="color:red">token</span> (correction(s): <span style="color:green">
   edit_token=r3.json()['query']['tokens']['csrftoken']
</span>)2
   <span style="color:red">params</span> (correction(s): <span style="color:green">parais, paras
</span>)3='?format=<span style="color:red">json</span> (correction(s): <span style="color:green">son
</span>)&action=<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)&<span style="color:red">meta</span> (correction(s): <span style="color:green">jeta, feta, mata, méta, mena, mets, met, mesa, mita
</span>)=<span style="color:red">tokens</span> (correction(s): <span style="color:green">
</span>)&continue='
   <span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)3=<span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">get</span> (correction(s): <span style="color:green">cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut
</span>)(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>) + 'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)' + <span style="color:red">params</span> (correction(s): <span style="color:green">parais, paras
</span>)3, cookies=r2.cookies)
   <span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)_<span style="color:red">token</span> (correction(s): <span style="color:green">
</span>)=r3.<span style="color:red">json</span> (correction(s): <span style="color:green">son
</span>)()['<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)']['<span style="color:red">tokens</span> (correction(s): <span style="color:green">
</span>)']['csrftoken']
    
    
   edit_cookie=r2.cookies.copy()
   <span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
   edit_cookie.update(r3.cookies)
</span>)_cookie=<span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)2.cookies.<span style="color:red">copy</span> (correction(s): <span style="color:green">cops, cosy, cop
</span>)()
   <span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)_cookie.update(<span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)3.cookies)
    
    
   #setup geolocator
   #<span style="color:red">setup</span> (correction(s): <span style="color:green">stup
   geolocator = Nominatim(timeout=10)
</span>) <span style="color:red">geolocator</span> (correction(s): <span style="color:green">
</span>)
   <span style="color:red">geolocator</span> (correction(s): <span style="color:green">
</span>) = Nominatim(<span style="color:red">timeout</span> (correction(s): <span style="color:green">
</span>)=10)
    
    
    
    
   # upload config
   # <span style="color:red">upload</span> (correction(s): <span style="color:green">
   def uploadMap(filename):
</span>) <span style="color:red">config</span> (correction(s): <span style="color:green">confit, confié, confia, confie
</span>)
   <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey
</span>) uploadMap(<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>)):
    
    
       # read local file
       # <span style="color:red">read</span> (correction(s): <span style="color:green">rend, rad
       upload_file = open(filename,"rb")
</span>) local file
       upload_contents = upload_file.read()
       <span style="color:red">upload</span> (correction(s): <span style="color:green">
       upload_file.close()
</span>)_file = open(<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>),"<span style="color:red">rb</span> (correction(s): <span style="color:green">ru, ré, b, rab, re, ri, ra, ob
</span>)")
       <span style="color:red">upload</span> (correction(s): <span style="color:green">
</span>)_contents = <span style="color:red">upload</span> (correction(s): <span style="color:green">
</span>)_file.<span style="color:red">read</span> (correction(s): <span style="color:green">rend, rad
</span>)()
       <span style="color:red">upload</span> (correction(s): <span style="color:green">
</span>)_file.close()
    
    
       # setting parameters for upload
       # <span style="color:red">setting</span> (correction(s): <span style="color:green">betting
       # ref: https://www.mediawiki.org/wiki/API:Upload
</span>) <span style="color:red">parameters</span> (correction(s): <span style="color:green">
       payload={'action':'upload','filename':filename, 'ignorewarnings':1, 'token':edit_token}
</span>) for <span style="color:red">upload</span> (correction(s): <span style="color:green">
       files={'file':upload_contents}
</span>)
       # <span style="color:red">ref</span> (correction(s): <span style="color:green">zef, rez, rep, re, rif, nef, reg, bref, rex, réf
</span>): <span style="color:red">https</span> (correction(s): <span style="color:green">
</span>)://<span style="color:red">www</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">mediawiki</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">org</span> (correction(s): <span style="color:green">orge, ore, ors, or, ort, ord, erg
</span>)/<span style="color:red">wiki</span> (correction(s): <span style="color:green">kiki, tiki
</span>)/API:Upload
       <span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>)={'action':'<span style="color:red">upload</span> (correction(s): <span style="color:green">
</span>)','<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>)':<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>), '<span style="color:red">ignorewarnings</span> (correction(s): <span style="color:green">
</span>)':1, '<span style="color:red">token</span> (correction(s): <span style="color:green">
</span>)':<span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)_<span style="color:red">token</span> (correction(s): <span style="color:green">
</span>)}
       files={'file':<span style="color:red">upload</span> (correction(s): <span style="color:green">
</span>)_contents}
    
    
       # upload the image
       # <span style="color:red">upload</span> (correction(s): <span style="color:green">
       print("Uploading file to %s via API..." % (baseurl+"index.php/Fichier:"+filename))
</span>) <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
       r4=requests.post(baseurl+'api.php',data=payload,files=files,cookies=edit_cookie)
</span>) image
       <span style="color:red">print</span> (correction(s): <span style="color:green">peint, prin, priant, priât, point, sprint, prit, prient
</span>)("Uploading file to %s via API..." % (<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)+"index.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)/Fichier:"+<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>)))
       r4=<span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)+'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)',data=<span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>),files=files,cookies=<span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)_cookie)
    
    
       # in case of error print the response
       # in case <span style="color:red">of</span> (correction(s): <span style="color:green">bof, f, on, if, ou, lof, o, off, oh, où, or, ob, ok, ouf, os
       #print(r4.text)
</span>) <span style="color:red">error</span> (correction(s): <span style="color:green">errer
</span>) <span style="color:red">print</span> (correction(s): <span style="color:green">peint, prin, priant, priât, point, sprint, prit, prient
</span>) <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
</span>) <span style="color:red">response</span> (correction(s): <span style="color:green">
</span>)
       #<span style="color:red">print</span> (correction(s): <span style="color:green">peint, prin, priant, priât, point, sprint, prit, prient
</span>)(r4.<span style="color:red">text</span> (correction(s): <span style="color:green">texto, texte, test, tex
</span>))
    
    
    
    
   def addToPage(name, img):
   <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey
       title = name + " BioPathBot"
</span>) addToPage(<span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
       content = "[[Fichier: "+ img +"]]"
</span>), <span style="color:red">img</span> (correction(s): <span style="color:green">
       pageToChange = requests.post(baseurl+'api.php?action=query&titles='+title+'&export&exportnowrap')
</span>)):
       payload={'action':'edit','assert':'user','format':'json','utf8':'','text':content,'summary':summary,'title':title,'token':edit_token}
       <span style="color:red">title</span> (correction(s): <span style="color:green">tille, titre
       r4=requests.post(baseurl+'api.php',data=payload,cookies=edit_cookie)
</span>) = <span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
</span>) + " BioPathBot"
       content = "[[Fichier: "+ <span style="color:red">img</span> (correction(s): <span style="color:green">
</span>) +"]]"
       pageToChange = <span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)+'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)?action=<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)&<span style="color:red">titles</span> (correction(s): <span style="color:green">tilles, titres
</span>)='+<span style="color:red">title</span> (correction(s): <span style="color:green">tille, titre
</span>)+'&export&<span style="color:red">exportnowrap</span> (correction(s): <span style="color:green">
</span>)')
       <span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>)={'action':'<span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)','<span style="color:red">assert</span> (correction(s): <span style="color:green">
</span>)':'user','format':'<span style="color:red">json</span> (correction(s): <span style="color:green">son
</span>)','<span style="color:red">utf</span> (correction(s): <span style="color:green">urf, ut
</span>)8':'','<span style="color:red">text</span> (correction(s): <span style="color:green">texto, texte, test, tex
</span>)':content,'<span style="color:red">summary</span> (correction(s): <span style="color:green">
</span>)':<span style="color:red">summary</span> (correction(s): <span style="color:green">
</span>),'<span style="color:red">title</span> (correction(s): <span style="color:green">tille, titre
</span>)':<span style="color:red">title</span> (correction(s): <span style="color:green">tille, titre
</span>),'<span style="color:red">token</span> (correction(s): <span style="color:green">
</span>)':<span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)_<span style="color:red">token</span> (correction(s): <span style="color:green">
</span>)}
       <span style="color:red">r</span> (correction(s): <span style="color:green">ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i
</span>)4=<span style="color:red">requests</span> (correction(s): <span style="color:green">
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)+'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)',data=<span style="color:red">payload</span> (correction(s): <span style="color:green">
</span>),cookies=<span style="color:red">edit</span> (correction(s): <span style="color:green">redit, dit, exit, édit, ledit
</span>)_cookie)
    
    
   # BioPathBot : add line of databiographie to the right page (time and space)
   # BioPathBot : <span style="color:red">add</span> (correction(s): <span style="color:green">ado, aïd, adp, ada
   def getDataFromPage(name):
</span>) line <span style="color:red">of</span> (correction(s): <span style="color:green">bof, f, on, if, ou, lof, o, off, oh, où, or, ob, ok, ouf, os
</span>) <span style="color:red">databiographie</span> (correction(s): <span style="color:green">
</span>) to <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
</span>) <span style="color:red">right</span> (correction(s): <span style="color:green">light
</span>) page (<span style="color:red">time</span> (correction(s): <span style="color:green">tire, mime, tige, cime, tome, tipe, lime, aime, trime, rime, tine
</span>) <span style="color:red">and</span> (correction(s): <span style="color:green">ans, aïd, land, an, anda, ana
</span>) <span style="color:red">space</span> (correction(s): <span style="color:green">espace
</span>))
   <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey
</span>) getDataFromPage(<span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
</span>)):
       data = []
       data = []
       result=requests.post(baseurl+'api.php?action=query&titles='+name+'&export&exportnowrap')
       <span style="color:red">result</span> (correction(s): <span style="color:green">
       soup=BeautifulSoup(result.text, "lxml")
</span>)=<span style="color:red">requests</span> (correction(s): <span style="color:green">
       #soup=BeautifulSoup(result.text)
</span>).post(<span style="color:red">baseurl</span> (correction(s): <span style="color:green">
</span>)+'api.<span style="color:red">php</span> (correction(s): <span style="color:green">phi, pep, pop, ph
</span>)?action=<span style="color:red">query</span> (correction(s): <span style="color:green">
</span>)&<span style="color:red">titles</span> (correction(s): <span style="color:green">tilles, titres
</span>)='+<span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
</span>)+'&export&<span style="color:red">exportnowrap</span> (correction(s): <span style="color:green">
</span>)')
       <span style="color:red">soup</span> (correction(s): <span style="color:green">houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue
</span>)=BeautifulSoup(<span style="color:red">result</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">text</span> (correction(s): <span style="color:green">texto, texte, test, tex
</span>), "<span style="color:red">lxml</span> (correction(s): <span style="color:green">
</span>)")
       #<span style="color:red">soup</span> (correction(s): <span style="color:green">houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue
</span>)=BeautifulSoup(<span style="color:red">result</span> (correction(s): <span style="color:green">
</span>).<span style="color:red">text</span> (correction(s): <span style="color:green">texto, texte, test, tex
</span>))
       code=''
       code=''
       for primitive in soup.findAll("text"):
       for primitive in <span style="color:red">soup</span> (correction(s): <span style="color:green">houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue
</span>).findAll("<span style="color:red">text</span> (correction(s): <span style="color:green">texto, texte, test, tex
</span>)"):
           code+=primitive.string
           code+=primitive.string
    
    
       # split on list (*)
       # <span style="color:red">split</span> (correction(s): <span style="color:green">salit
       lines = code.split("*")
</span>) on <span style="color:red">list</span> (correction(s): <span style="color:green">liste, listé, lise, lest, lis, liât, lift, lit
       for line in lines :
</span>) (*)
       <span style="color:red">lines</span> (correction(s): <span style="color:green">vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines
</span>) = code.<span style="color:red">split</span> (correction(s): <span style="color:green">salit
</span>)("*")
       for line in <span style="color:red">lines</span> (correction(s): <span style="color:green">vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines
</span>) :
    
    
           # add breaking lines (otherwise will be appened directly in one line)
           # <span style="color:red">add</span> (correction(s): <span style="color:green">ado, aïd, adp, ada
</span>) <span style="color:red">breaking</span> (correction(s): <span style="color:green">
</span>) <span style="color:red">lines</span> (correction(s): <span style="color:green">vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines
</span>) (<span style="color:red">otherwise</span> (correction(s): <span style="color:green">
</span>) <span style="color:red">will</span> (correction(s): <span style="color:green">till, bill, twill
</span>) <span style="color:red">be</span> (correction(s): <span style="color:green">bé, bi, re, ne, bée, de, beu, bye, by, b, bue, se, le, bel, bey, e, bu, me, te, ce, je, bec, ber, ben
</span>) <span style="color:red">appened</span> (correction(s): <span style="color:green">
</span>) <span style="color:red">directly</span> (correction(s): <span style="color:green">
</span>) in <span style="color:red">one</span> (correction(s): <span style="color:green">ont, gone, oie, ose, onde, on, ope, none, onc, ode, oye, zone, orne, ore, ne, âne, onze, once, ove, une
</span>) line)
           line = "\n\n"+line
           line = "\n\n"+line
    
    
           # get date if exist
           # <span style="color:red">get</span> (correction(s): <span style="color:green">cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut
           date = re.findall("((?<=\[\[)\d*(\.*\d*\.*\d*)*(?=\]\]))",line)
</span>) date if <span style="color:red">exist</span> (correction(s): <span style="color:green">exista, existé, existe, exit
</span>)
           date = re.<span style="color:red">findall</span> (correction(s): <span style="color:green">
</span>)("((?<=\[\[)\d*(\.*\d*\.*\d*)*(?=\]\]))",line)
           dateToAdd = ""
           dateToAdd = ""
    
    
Ligne 137 : Ligne 406 :
               dateToAdd = date[0][0]
               dateToAdd = date[0][0]
    
    
           # get place if exist
           # <span style="color:red">get</span> (correction(s): <span style="color:green">cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut
           place = re.findall("(?<=\/\s\[\[)[A-zÀ-ÿ]*(?=\]\])",line)
</span>) place if <span style="color:red">exist</span> (correction(s): <span style="color:green">exista, existé, existe, exit
</span>)
           place = re.<span style="color:red">findall</span> (correction(s): <span style="color:green">
</span>)("(?<=\/\s\[\[)[A-zÀ-ÿ]*(?=\]\])",line)
           location = ""
           location = ""
           if len(place) != 0:
           if len(place) != 0:
               placeToAdd = place[0]
               placeToAdd = place[0]
               location = geolocator.geocode(placeToAdd)
               location = <span style="color:red">geolocator</span> (correction(s): <span style="color:green">
</span>).geocode(placeToAdd)
    
    
           # if both the date and the location are available, append in data array
           # if both <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
           if dateToAdd and location:
</span>) date <span style="color:red">and</span> (correction(s): <span style="color:green">ans, aïd, land, an, anda, ana
</span>) <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
</span>) location are available, <span style="color:red">append</span> (correction(s): <span style="color:green">appends, appendu, apprend
</span>) in data array
           if dateToAdd <span style="color:red">and</span> (correction(s): <span style="color:green">ans, aïd, land, an, anda, ana
</span>) location:
               dataToAdd = [location.longitude,location.latitude];
               dataToAdd = [location.longitude,location.latitude];
               data.append(dataToAdd);
               data.<span style="color:red">append</span> (correction(s): <span style="color:green">appends, appendu, apprend
</span>)(dataToAdd);
       return data
       return data
    
    
    
    
   # finds the minimal and maximal longitude and latitude
   # finds <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
   def findCorners(pts):
</span>) minimal <span style="color:red">and</span> (correction(s): <span style="color:green">ans, aïd, land, an, anda, ana
</span>) maximal longitude <span style="color:red">and</span> (correction(s): <span style="color:green">ans, aïd, land, an, anda, ana
</span>) latitude
   <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey
</span>) findCorners(pts):
       minlon = maxlon = pts[0][0]
       minlon = maxlon = pts[0][0]
       minlat = maxlat = pts[0][1]
       minlat = maxlat = pts[0][1]
Ligne 170 : Ligne 453 :
       return [minlon, maxlon, minlat, maxlat]
       return [minlon, maxlon, minlat, maxlat]
    
    
   # draws the map, some points and the lines
   # draws <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
   def drawmap(pts, filename, export=False):
</span>) map, some points <span style="color:red">and</span> (correction(s): <span style="color:green">ans, aïd, land, an, anda, ana
</span>) <span style="color:red">the</span> (correction(s): <span style="color:green">tee, te, tue, thé
</span>) <span style="color:red">lines</span> (correction(s): <span style="color:green">vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines
</span>)
   <span style="color:red">def</span> (correction(s): <span style="color:green">zef, der, des, nef, de, dey
</span>) drawmap(pts, <span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>), export=False):
       n_pts = len(pts)
       n_pts = len(pts)
       corners = findCorners(pts)
       corners = findCorners(pts)
Ligne 178 : Ligne 467 :
       m.drawcountries(linewidth=1.0, color='0.6')
       m.drawcountries(linewidth=1.0, color='0.6')
       m.fillcontinents(color='white', lake_color='white')
       m.fillcontinents(color='white', lake_color='white')
       for i in range(n_pts-1): # draw lines
       for i in range(n_pts-1): # <span style="color:red">draw</span> (correction(s): <span style="color:green">drap, drag
</span>) <span style="color:red">lines</span> (correction(s): <span style="color:green">vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines
</span>)
           for j in range(SEGMENTS):
           for j in range(SEGMENTS):
               start = pts[i] + (pts[i+1]-pts[i])*(j/SEGMENTS)
               start = pts[i] + (pts[i+1]-pts[i])*(j/SEGMENTS)
               end = pts[i] + (pts[i+1]-pts[i])*((j+1)/SEGMENTS)
               end = pts[i] + (pts[i+1]-pts[i])*((j+1)/SEGMENTS)
               m.plot([start[0], end[0]], [start[1], end[1]], color=hsv_to_rgb((i+j/SEGMENTS)/n_pts, 1, 1))
               m.plot([start[0], end[0]], [start[1], end[1]], color=<span style="color:red">hsv</span> (correction(s): <span style="color:green">hiv
       for i in range(n_pts): # draw points
</span>)_to_<span style="color:red">rgb</span> (correction(s): <span style="color:green">rab
           m.plot(pts[i][0], pts[i][1], marker='o', color=hsv_to_rgb(i/n_pts, 1, 1), fillstyle='full', markeredgewidth=0.0)
</span>)((i+j/SEGMENTS)/n_pts, 1, 1))
       for i in range(n_pts): # <span style="color:red">draw</span> (correction(s): <span style="color:green">drap, drag
</span>) points
           m.plot(pts[i][0], pts[i][1], marker='o', color=<span style="color:red">hsv</span> (correction(s): <span style="color:green">hiv
</span>)_to_<span style="color:red">rgb</span> (correction(s): <span style="color:green">rab
</span>)(i/n_pts, 1, 1), fillstyle='full', markeredgewidth=0.0)
       if export:
       if export:
           plt.savefig(filename, bbox_inches='tight')
           <span style="color:red">plt</span> (correction(s): <span style="color:green">plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot
       plt.show()
</span>).savefig(<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>), bbox_inches='tight')
       <span style="color:red">plt</span> (correction(s): <span style="color:green">plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot
</span>).show()
    
    
    
    
   for name in names:
   for <span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
       image_filename = (name + "_biopath.png").replace(" ","_")
</span>) in <span style="color:red">names</span> (correction(s): <span style="color:green">nases, dames, lames, nages, nazes, cames, rames
       data = getDataFromPage(name)
</span>):
       drawmap(np.array(data), image_filename, True)
       image_<span style="color:red">filename</span> (correction(s): <span style="color:green">
       uploadMap(image_filename)
</span>) = (<span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
       addToPage(name, image_filename)
</span>) + "_biopath.png").replace(" ","_")
       data = getDataFromPage(<span style="color:red">name</span> (correction(s): <span style="color:green">nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome
</span>))
       drawmap(np.array(data), image_<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>), True)
       uploadMap(image_<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>))
       addToPage(name, image_<span style="color:red">filename</span> (correction(s): <span style="color:green">
</span>))





Version du 30 mai 2017 à 08:04


Description

Depuis une databiographie (correction(s): ) suivant le format utilisé sur le wiki (correction(s): kiki, tiki ) (ex (correction(s): exo, en, eu, eux, es, eh, et, x, e, rex, tex ): 1890.03.19 / Genève), le BioPathBot est capable d'extraire les informations temporelles et spatiales. Ces deux données forment un tuple (correction(s): tuile, tulle ) et sont parsées (correction(s): parées, pansées, parlées, passées ) de façon suivante :

  • La date est formée d'une année, d'un mois et d'un jour. Si des informations venaient à manquer, la date est complétée par défaut avec le mois de janvier et le premier du mois.
  • Le lieu est transformé en coordonnées géographiques (utilisant la librairie python [https (correction(s):

)://pypi.python.org (correction(s): orge, ore, ors, or, ort, ord, erg )/pypi/geopy (correction(s): ) geopy (correction(s): )])

Ainsi transformées et triées chronologiquement, ces données permettent de générer une carte utilisant [http (correction(s): )://matplotlib (correction(s): ).org (correction(s): orge, ore, ors, or, ort, ord, erg )/basemap (correction(s): )/index.html basemap (correction(s): )], où sont dessinés des points pour marquer les lieux, ainsi que des traits mettant en avant la trajectoire de la personne. Cette carte est ensuite importée sur wikipast (correction(s): ) puis insérée sur une page annexe.

Par exemple la carte de Jean Tinguely se visualise comme:

Jean Tinguely biopath.png

Critique

  • Peu importe le type de page (une page concernant une personne, un hypermot...), une carte est générée. Donc si une page ne relate pas la vie d'une personne, la carte aura peu de sens.
  • Avec l'algorithme actuel, les dates et les lieux sont parfaitement extraits et placé sur la carte. Cependant, si les données ne sont pas suffisamment précises, elles seront approximées (correction(s):

) (1980 devient 1980.01.01 tandis (correction(s): candis, tendis, taudis ) que le point géographique correspondant à la Suisse sera son centre géographique). Cela peut mener à des erreurs de trajectoire lors du tri chronologique ou simplement à une position différente de la réalité sur la carte.

  • S'il existe des événements post-mortem (correction(s): mortel, mortes, morte

) mais que la mort de la personne n'est pas mentionnée ou ne suit pas la convention de l'hypermot Décès, ces données seront aussi extraites et placées sur la carte, alors même que la personne ne se déplace pas.

  • Si des événements sont spatialement trop proches, ils vont se superposer sur la carte et il deviendra difficile de retracer les événements d'une façon visuellement claire. Par exemple, pour un trait entre Berne et Lausanne, il sera difficile de juger si une personne a fait plusieurs fois ce même déplacement ou ne l'a fait qu'une seule fois au cours de sa vie.
  • Parfois l'outil qui transforme les lieux en coordonnées géographiques crée des erreurs. Par exemple "Rome" devient "Lomé" qui se situe au Togo.
  • Certains événements se passe sans que la personne soit physiquement présente, mais on ne peut pas le détecter automatiquement. Les lieux apparaissent donc sur la carte.

Code

 import urllib (correction(s): 

).request (correction(s): )

 import requests (correction(s): 

)

 from (correction(s): rom, froc

) bs (correction(s): bé, ès, s, by, bi, bis, b, es, bus, bas, as, bu, os, us )4 import BeautifulSoup

 import re
 import math
 import datetime (correction(s): 

)

 from (correction(s): rom, froc

) geopy (correction(s): ).geocoders (correction(s): ) import Nominatim

 from (correction(s): rom, froc

) mpl (correction(s): mil, mal, mol, ml )_toolkits (correction(s): ).basemap (correction(s): ) import Basemap

 import matplotlib (correction(s): 

).pyplot (correction(s): ) as plt (correction(s): plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot )

 from (correction(s): rom, froc

) colorsys (correction(s): ) import hsv (correction(s): hiv )_to_rgb (correction(s): rab )

 from (correction(s): rom, froc

) matplotlib (correction(s): ).colors (correction(s): colore, coloris, colorés, colos, colora, coloré, colons ) import rgb (correction(s): rab )2hex (correction(s): hem, heu, hep, rex, tex )

 SEGMENTS = 100
 
 # draw (correction(s): drap, drag

) plots inline (correction(s): incline ) rather (correction(s): ratier, rater ) than (correction(s): tian, ahan, tan, thon, thaï, han, khan ) in a seperate (correction(s): ) window (correction(s): )

 %matplotlib (correction(s): 

) inline (correction(s): incline )

 # draw (correction(s): drap, drag

) plots bigger (correction(s): bigler, jigger )

 plt (correction(s): plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot

).rcParams["figure.figsize"] = [20.0, 10.0]

 user='BioPathBot'
 passw (correction(s): passe, passé, passa

)='chkiroju (correction(s): )'

 baseurl (correction(s): 

)='http (correction(s): )://wikipast (correction(s): ).epfl (correction(s): ).ch (correction(s): chu, co, h, ce, ah, eh, c, ph, oh, ci, cm, chi )/wikipast (correction(s): )/'

 summary (correction(s): 

)='Wikipastbot update'

 protected (correction(s): 

)_logins (correction(s): logis, login, lopins, logions )=["Frederickaplan","Maud","Vbuntinx","Testbot","IB","SourceBot","PageUpdaterBot","Orthobot","BioPathBot","ChronoBOT","Amonbaro","AntoineL","AntoniasBan deros","Arnau","Arnaudpannatier","Aureliver","Brunowicht","Burgerpop","Cedricviaccoz","Christophe","Claudioloureiro","Ghislain","Gregoire3245","Hirtg","Houssm","Icebak er","JenniCin","JiggyQ","JulienB","Kl","Kperrard","Leandro Kieliger","Marcus","Martin","MatteoGiorla","Mireille","Mj2905","Musluoglucem","Nacho","Nameless","Nawel","O'showa","PA","Qantik","QuentinB","Raphael.barman","Roblan11" ,"Romain Fournier","Sbaaa","Snus","Sonia","Tboyer","Thierry","Titi","Vlaedr","Wanda"]

 depuis_date='2017-05-02T16:00:00Z'
 liste_pages=[]
 for user in protected (correction(s): 

)_logins (correction(s): logis, login, lopins, logions ):

     result (correction(s): 

)=requests (correction(s): ).post(baseurl (correction(s): )+'api.php (correction(s): phi, pep, pop, ph )?action=query (correction(s): )&list (correction(s): liste, listé, lise, lest, lis, liât, lift, lit )=usercontribs (correction(s): )&ucuser (correction(s): )='+user+'&format=xml (correction(s): ml )&ucend (correction(s): )='+depuis_date)

     soup (correction(s): houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue

)=BeautifulSoup(result (correction(s): ).content,'lxml (correction(s): )')

     for primitive in soup (correction(s): houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue

).usercontribs (correction(s): ).findAll('item'):

         liste_pages.append (correction(s): appends, appendu, apprend

)(primitive['title (correction(s): tille, titre )'])

         print (correction(s): peint, prin, priant, priât, point, sprint, prit, prient

)(primitive['title (correction(s): tille, titre )'])

 names (correction(s): nases, dames, lames, nages, nazes, cames, rames

)=list (correction(s): liste, listé, lise, lest, lis, liât, lift, lit )(set(liste_pages))

 # Login request (correction(s): 

)

 payload (correction(s): 

)={'action':'query (correction(s): )','format':'json (correction(s): son )','utf (correction(s): urf, ut )8':,'meta (correction(s): jeta, feta, mata, méta, mena, mets, met, mesa, mita )':'tokens (correction(s): )','type':'login'}

 r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i

)1=requests (correction(s): ).post(baseurl (correction(s): ) + 'api.php (correction(s): phi, pep, pop, ph )', data=payload (correction(s): ))

 #login confirm (correction(s): confire, confirma, confirme, confirmé

)

 login_token (correction(s): 

)=r1.json (correction(s): son )()['query (correction(s): )']['tokens (correction(s): )']['logintoken']

 payload (correction(s): 

)={'action':'login','format':'json (correction(s): son )','utf (correction(s): urf, ut )8':,'lgname (correction(s): igname )':user,'lgpassword (correction(s): )':passw,'lgtoken (correction(s): )':login_token}

 r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i

)2=requests (correction(s): ).post(baseurl (correction(s): ) + 'api.php (correction(s): phi, pep, pop, ph )', data=payload (correction(s): ), cookies=r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i )1.cookies)

 #get (correction(s): cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut

) edit (correction(s): redit, dit, exit, édit, ledit ) token (correction(s): )2

 params (correction(s): parais, paras

)3='?format=json (correction(s): son )&action=query (correction(s): )&meta (correction(s): jeta, feta, mata, méta, mena, mets, met, mesa, mita )=tokens (correction(s): )&continue='

 r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i

)3=requests (correction(s): ).get (correction(s): cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut )(baseurl (correction(s): ) + 'api.php (correction(s): phi, pep, pop, ph )' + params (correction(s): parais, paras )3, cookies=r2.cookies)

 edit (correction(s): redit, dit, exit, édit, ledit

)_token (correction(s): )=r3.json (correction(s): son )()['query (correction(s): )']['tokens (correction(s): )']['csrftoken']

 edit (correction(s): redit, dit, exit, édit, ledit

)_cookie=r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i )2.cookies.copy (correction(s): cops, cosy, cop )()

 edit (correction(s): redit, dit, exit, édit, ledit

)_cookie.update(r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i )3.cookies)

 #setup (correction(s): stup

) geolocator (correction(s): )

 geolocator (correction(s): 

) = Nominatim(timeout (correction(s): )=10)


 # upload (correction(s): 

) config (correction(s): confit, confié, confia, confie )

 def (correction(s): zef, der, des, nef, de, dey

) uploadMap(filename (correction(s): )):

     # read (correction(s): rend, rad

) local file

     upload (correction(s): 

)_file = open(filename (correction(s): ),"rb (correction(s): ru, ré, b, rab, re, ri, ra, ob )")

     upload (correction(s): 

)_contents = upload (correction(s): )_file.read (correction(s): rend, rad )()

     upload (correction(s): 

)_file.close()

     # setting (correction(s): betting

) parameters (correction(s): ) for upload (correction(s): )

     # ref (correction(s): zef, rez, rep, re, rif, nef, reg, bref, rex, réf

): https (correction(s): )://www (correction(s): ).mediawiki (correction(s): ).org (correction(s): orge, ore, ors, or, ort, ord, erg )/wiki (correction(s): kiki, tiki )/API:Upload

     payload (correction(s): 

)={'action':'upload (correction(s): )','filename (correction(s): )':filename (correction(s): ), 'ignorewarnings (correction(s): )':1, 'token (correction(s): )':edit (correction(s): redit, dit, exit, édit, ledit )_token (correction(s): )}

     files={'file':upload (correction(s): 

)_contents}

     # upload (correction(s): 

) the (correction(s): tee, te, tue, thé ) image

     print (correction(s): peint, prin, priant, priât, point, sprint, prit, prient

)("Uploading file to %s via API..." % (baseurl (correction(s): )+"index.php (correction(s): phi, pep, pop, ph )/Fichier:"+filename (correction(s): )))

     r4=requests (correction(s): 

).post(baseurl (correction(s): )+'api.php (correction(s): phi, pep, pop, ph )',data=payload (correction(s): ),files=files,cookies=edit (correction(s): redit, dit, exit, édit, ledit )_cookie)

     # in case of (correction(s): bof, f, on, if, ou, lof, o, off, oh, où, or, ob, ok, ouf, os

) error (correction(s): errer ) print (correction(s): peint, prin, priant, priât, point, sprint, prit, prient ) the (correction(s): tee, te, tue, thé ) response (correction(s): )

     #print (correction(s): peint, prin, priant, priât, point, sprint, prit, prient

)(r4.text (correction(s): texto, texte, test, tex ))


 def (correction(s): zef, der, des, nef, de, dey

) addToPage(name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome ), img (correction(s): )):

     title (correction(s): tille, titre

) = name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome ) + " BioPathBot"

     content = "[[Fichier: "+ img (correction(s): 

) +"]]"

     pageToChange = requests (correction(s): 

).post(baseurl (correction(s): )+'api.php (correction(s): phi, pep, pop, ph )?action=query (correction(s): )&titles (correction(s): tilles, titres )='+title (correction(s): tille, titre )+'&export&exportnowrap (correction(s): )')

     payload (correction(s): 

)={'action':'edit (correction(s): redit, dit, exit, édit, ledit )','assert (correction(s): )':'user','format':'json (correction(s): son )','utf (correction(s): urf, ut )8':,'text (correction(s): texto, texte, test, tex )':content,'summary (correction(s): )':summary (correction(s): ),'title (correction(s): tille, titre )':title (correction(s): tille, titre ),'token (correction(s): )':edit (correction(s): redit, dit, exit, édit, ledit )_token (correction(s): )}

     r (correction(s): ô, , k, re, ri, q, or, z, v, t, l, é, n, b, o, j, m, ru, s, d, y, a, f, e, à, ré, h, c, x, g, w, u, ra, i

)4=requests (correction(s): ).post(baseurl (correction(s): )+'api.php (correction(s): phi, pep, pop, ph )',data=payload (correction(s): ),cookies=edit (correction(s): redit, dit, exit, édit, ledit )_cookie)

 # BioPathBot : add (correction(s): ado, aïd, adp, ada

) line of (correction(s): bof, f, on, if, ou, lof, o, off, oh, où, or, ob, ok, ouf, os ) databiographie (correction(s): ) to the (correction(s): tee, te, tue, thé ) right (correction(s): light ) page (time (correction(s): tire, mime, tige, cime, tome, tipe, lime, aime, trime, rime, tine ) and (correction(s): ans, aïd, land, an, anda, ana ) space (correction(s): espace ))

 def (correction(s): zef, der, des, nef, de, dey

) getDataFromPage(name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome )):

     data = []
     result (correction(s): 

)=requests (correction(s): ).post(baseurl (correction(s): )+'api.php (correction(s): phi, pep, pop, ph )?action=query (correction(s): )&titles (correction(s): tilles, titres )='+name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome )+'&export&exportnowrap (correction(s): )')

     soup (correction(s): houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue

)=BeautifulSoup(result (correction(s): ).text (correction(s): texto, texte, test, tex ), "lxml (correction(s): )")

     #soup (correction(s): houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue

)=BeautifulSoup(result (correction(s): ).text (correction(s): texto, texte, test, tex ))

     code=
     for primitive in soup (correction(s): houp, stup, soupe, soupé, youp, soul, sous, souk, soupa, sou, coup, loup, soue

).findAll("text (correction(s): texto, texte, test, tex )"):

         code+=primitive.string
 
     # split (correction(s): salit

) on list (correction(s): liste, listé, lise, lest, lis, liât, lift, lit ) (*)

     lines (correction(s): vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines

) = code.split (correction(s): salit )("*")

     for line in lines (correction(s): vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines

) :

         # add (correction(s): ado, aïd, adp, ada

) breaking (correction(s): ) lines (correction(s): vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines ) (otherwise (correction(s): ) will (correction(s): till, bill, twill ) be (correction(s): bé, bi, re, ne, bée, de, beu, bye, by, b, bue, se, le, bel, bey, e, bu, me, te, ce, je, bec, ber, ben ) appened (correction(s): ) directly (correction(s): ) in one (correction(s): ont, gone, oie, ose, onde, on, ope, none, onc, ode, oye, zone, orne, ore, ne, âne, onze, once, ove, une ) line)

         line = "\n\n"+line
 
         # get (correction(s): cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut

) date if exist (correction(s): exista, existé, existe, exit )

         date = re.findall (correction(s): 

)("((?<=\[\[)\d*(\.*\d*\.*\d*)*(?=\]\]))",line)

         dateToAdd = ""
 
         if len(date) != 0 :
             dateToAdd = date[0][0]
 
         # get (correction(s): cet, pet, let, gel, guet, ket, gît, net, et, set, met, jet, gent, gut

) place if exist (correction(s): exista, existé, existe, exit )

         place = re.findall (correction(s): 

)("(?<=\/\s\[\[)[A-zÀ-ÿ]*(?=\]\])",line)

         location = ""
         if len(place) != 0:
              placeToAdd = place[0]
              location = geolocator (correction(s): 

).geocode(placeToAdd)

         # if both the (correction(s): tee, te, tue, thé

) date and (correction(s): ans, aïd, land, an, anda, ana ) the (correction(s): tee, te, tue, thé ) location are available, append (correction(s): appends, appendu, apprend ) in data array

         if dateToAdd and (correction(s): ans, aïd, land, an, anda, ana

) location:

             dataToAdd = [location.longitude,location.latitude];
             data.append (correction(s): appends, appendu, apprend

)(dataToAdd);

     return data
 
 
 # finds the (correction(s): tee, te, tue, thé

) minimal and (correction(s): ans, aïd, land, an, anda, ana ) maximal longitude and (correction(s): ans, aïd, land, an, anda, ana ) latitude

 def (correction(s): zef, der, des, nef, de, dey

) findCorners(pts):

     minlon = maxlon = pts[0][0]
     minlat = maxlat = pts[0][1]
     for p in pts:
         currlon = p[0]
         if currlon<minlon:
             minlon = currlon
         elif currlon>maxlon:
             maxlon = currlon
 
         currlat = p[1]
         if currlat<minlat:
             minlat = currlat
         elif currlat>maxlat:
             maxlat = currlat
 
     return [minlon, maxlon, minlat, maxlat]
 
 # draws the (correction(s): tee, te, tue, thé

) map, some points and (correction(s): ans, aïd, land, an, anda, ana ) the (correction(s): tee, te, tue, thé ) lines (correction(s): vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines )

 def (correction(s): zef, der, des, nef, de, dey

) drawmap(pts, filename (correction(s): ), export=False):

     n_pts = len(pts)
     corners = findCorners(pts)
     m = Basemap(llcrnrlon=corners[0]-1, llcrnrlat=corners[2]-1, urcrnrlon=corners[1]+1, urcrnrlat=corners[3]+1, resolution='i')
     m.drawmapboundary(fill_color='0.6')
     m.drawcountries(linewidth=1.0, color='0.6')
     m.fillcontinents(color='white', lake_color='white')
     for i in range(n_pts-1): # draw (correction(s): drap, drag

) lines (correction(s): vines, liées, linos, lignes, mines, lises, lins, limes, lires, lices, lianes, laines, linges, lunes, liges, lies, pines, aines, line, fines )

         for j in range(SEGMENTS):
             start = pts[i] + (pts[i+1]-pts[i])*(j/SEGMENTS)
             end = pts[i] + (pts[i+1]-pts[i])*((j+1)/SEGMENTS)
             m.plot([start[0], end[0]], [start[1], end[1]], color=hsv (correction(s): hiv

)_to_rgb (correction(s): rab )((i+j/SEGMENTS)/n_pts, 1, 1))

     for i in range(n_pts): # draw (correction(s): drap, drag

) points

         m.plot(pts[i][0], pts[i][1], marker='o', color=hsv (correction(s): hiv

)_to_rgb (correction(s): rab )(i/n_pts, 1, 1), fillstyle='full', markeredgewidth=0.0)

     if export:
         plt (correction(s): plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot

).savefig(filename (correction(s): ), bbox_inches='tight')

     plt (correction(s): plut, plet, pet, pût, plût, pli, plot, plat, pst, put, pât, plu, pat, pot

).show()


 for name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome

) in names (correction(s): nases, dames, lames, nages, nazes, cames, rames ):

     image_filename (correction(s): 

) = (name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome ) + "_biopath.png").replace(" ","_")

     data = getDataFromPage(name (correction(s): nave, naze, rame, mame, lame, dame, game, came, nase, nage, nome

))

     drawmap(np.array(data), image_filename (correction(s): 

), True)

     uploadMap(image_filename (correction(s): 

))

     addToPage(name, image_filename (correction(s): 

))


Groupe

Nom et Prénom Pseudo
Christophe Badoux Christophe
Julien Burkhard JulienB
Kim Lan Phan Hoang Kl
Robin Lang Roblan11

Code