Botwiki:Interwiki.py (guida)
From Botwiki
C'è un bisogno funzionale per i link interlingua tra le diverse versioni linguistiche di un progetto e interwiki.py può aiutarti a crearli.
Contents |
[edit] Iniziare
Per vedere di cosa hai bisogno per iniziare, guarda Come usare un wikipediabot in linguaggio python per creare il tuo bot. Sottointendiamo i passaggi meno importanti (scaricare Python e il bot, aver creato user-config, fatto partire il prompt e fatto partire login.py). Ora, per iniziare, digita interwiki.py se sei in windows o python interwiki.py per gli altri sistemi operativi.
A questo punto il bot richiederà una pagina da controllare. Digita quindi il nome di una voce presente nella tua Wikipedia (o nel progetto in cui stai utilizzando il bot) e preferibilmente scegli una voce con una o più link-interwiki che però può possederne di più. Il bot leggerà così tale pagina e se questa ha qualche link-interwiki, esso controllerà anche queste pagine, e i link-interwiki presenti in questa e così via. Dopo che il bot avrà finito, si comporterà nei seguenti modi, a seconda dei dati trovati:
- Se la pagina non ha link-interwiki, o se i link trovati sono identici a quelli presenti nella pagina, il bot si fermerà, tornando alla directory di pywikipedia.
- Se il bot trova i link-interwiki a nuove lingue, o trova che un link-interwiki debba essere cambiato, lo farà.
- Se il bot trova più di una pagina per lingua, esso entrerà nella "interactive mode" (
modalità KILLER!!modalità interattiva). Esso darà le pagine trovate assieme alle pagine che "linkano" a tale pagina, e chiederà per ogni lingua con più di un link, {[(which if any should be linked to)]} e poi chiederà per ogni lingua con un link se deve essere linkato.
Attenzione, perché questi comportamenti possono essere cambiati utilizzando le opzioni interwiki.py#Lavorare con più di una pagina qui sotto.
Puoi anche specificare la pagina da lavorare direttamente, utilizzando "interwiki.py nome-pagina". Anche se ci sono maggiorni possibilità, quindi guarda qua sotto.
[edit] Lavorare con più di una pagina.
Utilizzando il XML Export, il software-pywikipediabot può controllare più pagine invece che una soltanto, fino ad un massimo di 60 alla volta. Per utilizzare questa funzione, si può utilizzare il bot in una serie di pagine. Il modo utilizzato più comunemente è quello di ricevere le pagine in ordine alfabetico da "Special:All pages", utilizzando l'opzione -start.
[edit] -start
Se aggiungi l'opzione -start, il bot andrà attraverso le pagine in ordine alfabetico, iniziando dalla parola, lettera, numero o segno di interpunzione specificato. Per esempio, se si vuole iniziare dalla lettera "B", bisogna digitare interwiki.py -start:B. In particolare, se vuoi controllare l'intera Wikipedia, puoi digitare interwiki.py -start:!
[edit] Ripartire: -continue e -restore
Scansionare l'intera wiki può, in quelle più o mediamente estese, impiegare molto tempo. Così, molto probabilmente, accadrà che di essere costretto a fermare il bot prima che abbia finito tutto il suo lavoro. In questo caso, puoi utilizzare interwiki.py -continue la prossima volta. Il bot, quando va in crash o è fermato (utilizzando ctrl+c), scrive un file, specificando le pagine sulle quali stava lavorando. Se usi l'opzione -continue, esso riprenderà con quelle pagine e riprenderà andando in ordine alfabetico. Se vuoi far riiniziare un processo non alfabetico, puoi usare invece il comando "interwiki.py -restore" Esso riinizierà con le pagine su cui stava lavorando.
Attenzione!: ricordati però che è possibile riavviare solo l'ultimo processo eseguito dal bot che è stato fermato. Il bot salverà le sue informazioni in un file chiamato interwiki.dump, e se il bot sarà bloccato quando sta lavorando anche su una sola pagina, esso sovrascriverà il file.
[edit] Modalità automatica
Quando stai lavorando su molte pagine, potresti volere che il bot continui autonomamente, invece che continuare a chiedere ogni volta che incontra un problema. Si può fare ciò aggiungendo il comando "-autonomous". Se è utilizzata questa opzione, il bot salterà tutti i problemi e le rimozioni, e salverà un file log di questi ultimi nel file "autonomous_problems.dat". Se tu vuoi che rimuova lo stesso eventuali collegamenti errati, aggiungi anche il comando "-force; in questo caso è bene controllare successivamente le voci rimosse. (talvolta una pagina è rimossa solo a causa di una scrittura errata.)
[edit] Il file "sax_parse_bug.dat"
Talvolta c'è un messaggio di errore che menziona il file sax_parse_bug.dat sullo schermo mentre si sta facendo girare lo script interwiki.py, e poi inizia a richiamare alcune pagine una alla volta invece che in una volta sola. Questo può essere causato da un carattere "illegale" in una delle pagine richiamate.
Per risolvere il problema può essere usato il tool xmltest.py. Fallo partire con il nome del file come argomento (se utilizzi windows non digitare python):
python xmltest.py sax_parse_bug.dat |
Questo genererà un python stack trace. L'ultima linea dello stack trace mostrerà un numero lineare e una colonna che indica dove è situato il carattere illegale nel file. Per favore, controlla la sua posizione e, se è possibile, correggi la pagina wiki ad esso associata.
[edit] Bot in funzione con gli anni AD
C'è un'opzione speciale -years che permette di non seguire i collegamenti alle centinaia e ai decenni che sono comuni in alcune wikipedie (come la ja:).
There is a special option -years that makes sure not to follow links to centuries and decennia that are common on some wikipedias (like ja:). Even then, this option should be used in combination with an exceptions file (see below) because the la: and ia: number pages are about the numbers and not about the years.
python interwiki.py -autonomous -years |
This will take a while to start up while it is preparing hints for all pages named [[1]] through [[2050]]
If you stop the robot during a -years run and want to restart it later, you can tell the robot at which page to restart by using -years:XYZ where XYZ is the year where the robot stopped last time. You can also make the robot start B.C. by making XYZ a negative number.
python interwiki.py -autonomous -years:-500 |
[edit] Lavorare su una lista di pagine
Potrebbe capitarti di avere una lista di pagine da controllare per gli interwiki. Per fare lavorare lo script Interwiki.py su questa lista devi preparare un semplice file di testo, e scrivi una pagina per riga e per i nomi delle voci va utilizzata la sintassi:
[[progetto:lingua:nomevoce]] oppure [[lingua:nomevoce]] oppure semplicemente [[nomevoce]]
dove progetto è il nome del progetto (es. "wikipedia"), lingua è la sigla della lingua (es. "it"). Se le voci da controllare si trovano nella lingua di default del bot (tipo [[it:AAA]]) puoi omettere il prefisso "lingua:", lo stesso vale per il progetto. Terminata la lista puoi lanciare il comando con l'opzione "-file" ad esempio:
python interwiki.py -file:elenco_di_voci.txt |
[edit] Using hints
Upto now, we have only worked on adding interwikis on pages that already have some. But the bot can also be used to add them on pages that have none yet. This is done by using hints. If for example you want to add interwikis to the page [[en:House]], and think there might be a page at [[fr:Maison]] that would be about the same subject, you can type (if your bot is set to run on English by default) "interwiki.py House -hint:fr:Maison".
If the link is to the same title, you can remove the title, and even the second :. Also, if you want to link to the same word in several languages, you can combine them with commas. So instead of "interwiki.py Albert Einstein -hint:de:Albert_Einstein -hint:fr:Albert_Einstein -hint:id:Albert_Einstein" (those underscores are necessary, otherwise the bot will regard the 'Einstein' part of the pagename), you can write "interwiki.py Albert Einstein -hint:de,fr,id",
[edit] Special hints
Some special hints have been defined to do a number of languages at once. You can use them instead of the language part of a hint. Currently the following special hints exist for Wikipedia:
- 10: Ten of the largest Wikipedias
- 20,30,50: Idem, for twenty, thirty and fifty languages
- all: All Wikipedias with at least ~100 articles
- cyril: All languages in Cyrillic script
The same are defined for Wiktionary, but at the moment of writing, 30, 50 and all are the same for Wiktionary. It is intended to add more options.
[edit] Asking for hints
When working on multiple pages such hints in the command line are rarely useful. In that case (or if you want to decide on the hints later), you can use the options "-askhints", "-untranslated" and "-untranslatedonly". If you choose the -askhints option, for each page you will be asked for one or more hints. They can be like the hints after -hint: on the command line, but the ':' may not be omitted, and spaces are allowed. Thus, valid hints would for example be "en:John Smith", "de,nds,af:" or "50:". "-untranslated" asks for hints only if there are no interwiki links yet; "-untranslatedonly" is like -untranslated, but other pages are not worked on at all.
Instead of giving a hint, you can give an empty line. This specifies that all hints for this page have been given (or that you have no hints for it). Note that if you have given a hint, the bot will keep asking for more hints until you press enter. Another option is to input a question mark and nothing else; in that case you get shown the beginning of the text to the page. If after that you input the question mark again, it will give a larger part of the text, etcetera.
It might in these cases be useful to have the "-confirm" option added, so the bot gets interactive before making a change. This can be used to check whether the links are correct and/or as an impetus to create a backlink.
[edit] Wiktionary
For Wiktionary there is the special "-wiktionary" option. It works like "-hint:all", but has some extras because on Wiktionary some languages use capitalisation and others don't, and links to another word are never correct.
On non-capitalising wiktionaries, links to capitalising wiktionaries are only added for capitalised words. Also, any link found to a word that differs more than just in capitalisation, is ignored completely.
[edit] Automatic translation
For years (both AD and BC) and days of the year, the bot can automatically translate it in a large number of languages. If you do not want this automatic translation (for example because it takes long to go over such a large number of languages), it can be switched off with the "-noauto" option.
With the option "-years:" followed by a number (positive or negative), the bot goes through the years from the given year to 2050. If "-years" without any addition is given, the beginning year is taken to be the year 1.
With the option "-days" the bot goes through the days of the year; however, this bot only works correctly on nl:.
[edit] Avoiding unwanted links
If you want to run the bot, but know that for a given page, it will get to links that it should not get, you can use the -noredirect or -neverlink options.
-noredirect means that if a redirect page is found, the redirect is not followed, as is the normal behaviour, but the page is skipped.
-neverlink:xx with xx: a language code means that any links to the language xx: are ignored.
[edit] Working with the logfile
Each run of the interwiki.py program will write not only to the screen, but also to a file called logs/interwiki.log. You may have seen that once a subject is completed, a list of other Wikipedias interwiki links is printed preceded by 'WARNING:'. To use these lines, the interwiki.log file is more convenient than the screen.
First an explanation why this is important. Assume you have a page [[My Subject]] that links to [[fr:Mon Sujet]] and [[nl:Mijn Onderwerp]]. Assume also that neither the nl: nor the fr: page list your en: page: they only know each other. A run of interwiki.py on either fr: or nl: will not find your en: page. This can be referred to as the backlink problem: there can be an unknown language that link to the others, but as long as none of the others link back, there is no way of discovering the existance. Do we really need to add these backlinks manually? No, that is where the warnings come in. In the interwiki.log:
WARNING: fr:[[Mon Sujet]] does not link to [[en:My Subject]] WARNING: nl:[[Mijn Onderwerp]] does not link to [[en:My Subject]] |
If the person running interwiki.py either on fr: or on nl: would have this information, that would be sufficient to get the network of links completed.
For this reason there is another option for the interwiki.py program:
python interwiki.py -warnfile:english_treelang.log |
In this mode the program will read the warnfile, and start to process all of the pages that are mentioned for its home language using the "does not link to" lines as hints.
This process can still take a long time. If you trust the operator that sent you the log, and the log is recent, you can also do:
python warnfile.py english_treelang.log |
This will not verify any of the suggestions in the warnfile, but blindly implement them at full speed, saving the Wikipedia server a lot of efforts.
Now, instead of sending the whole interwiki.log file to everyone, there is a special program to split it up:
python splitwarning.py |
This will read your interwiki.log and create files called warning_XX.log (one for each language) that are more convenient to use. If you zip these files up and make them available somewhere on the internet, you can announce this at Interwiki bot/Warnfiles.
[edit] Panoramica delle opzioni
Ecco una lista delle opzioni con una breve spiegazione delle opzioni che non sono ancora state discusse.
- -array: (utilizza: -array:nn con nn come numero) Quando si lavora su molte pagine, assicura che il bot lavori almeno in quel determinato numero di pagine, se possibile. Il valore impostato di defaul è 100; quando si usa -untranslatedonly o opzioni simili, si potrebbe aver bisogno di settarlo con un valore migliore
- -always: Salva sempre la pagina, anche se è cambiato solo un byte (default: salva la pagina solo se è cambiato alla fin fine almeno un link)
- -askhints: Chiede consigli (vedi sopra)
- -autonomous: Lavora in modalità automatica (vedi sopra)
- -confirm: Chiede il permesso prima di fare qualsiasi modifica
- -days: Lavora sui giorni
- -file: Specifica un file contenente un elenco di voci. (vedi sopra: Lavorare su una lista di pagine)
- -force: Quando un interwiki va rimosso lo fa direttamente senza chiedere prima il permesso
- -hint: Give a hint (vedi sopra)
- -name: Old option; equivalent to "-hint:all", but capitalizes the last word when trying on eo:. Might get deprecated.
- -neverlink: Do not link to a specific language (vedi sopra)
- -noauto: Do not use automatic translation (vedi sopra)
- -nobacklink: Do not give a list of missing links on pages linked to
- -nobell: Give no audio sign when asking for input.
- -noredirect: If the bot finds a page linked to is a redirect, ist is skipped (normal behaviour: It follows the redirect)
- -noshownew: Do not show new links found
- -number: (usage"-number:nn" with nn a number) In combination with -start, checks only the first nn pages rather than the whole wiki.
- -same: Old option; equivalent to "-hint:all"; might get deprecated
- -showpage: When using -askhints or some such option, always show the page text, even if not prompted.
- -skipfile: (usage "-skipfile:filename") On a run using -start, do not do the pages in the file start
- -untranslated: Ask hints for untranslated pages (vedi sopra)
- -untranslatedonly: Ask hints for untranslated pages (vedi sopra)
- -warnfile: Use the logfile for pages and hints (vedi sopra)
- -wiktionary: Special wiktionary options (vedi sopra)
- -years: Work on the years
[edit] Opzioni valide per tutti gli script
- -help fornisce una lista di argomenti standard (ovvero, questa lista, ma in lingua inglese) e un help specifico sulla sintassi dello script, se è disponibile.
- -lang:xx stabilisce la lingua della wiki. Ha la precedenza sull'user-config.py.
- -family:xyz stabilisce il nome del progetto wiki (per esempio, wikipedia o wikitionary). Ha la precedenza sull'user-config.py.
- -log abilita i log. Questi verranno salvati nella sottocartella "logs".
- -log:xyz abilita i log, salvando il file risultante con il nome xyz.
- -nolog disabilita i log.
- -putthrottle:nn stabilisce il tempo minimo di nn secondi tra gli edit. Se ad esempio si vuole fare non più di un edit ogni 60 secondi bisogna dare l'opzione -putthrottle:60
BlogMarks
del.icio.us
digg
Fark
Furl
Newsvine
reddit
Segnalo
Simpy
Slashdot
smarking
Spurl
Wists
