Manual:Pywikibot/interwiki.py/fr

From mediawiki.org

Les liens interlangue sont très utiles pour lier les différentes langues d'un même projet, interwiki.py peut aider à les créer.

Bien démarrer[edit]

Pour voir ce dont vous avez besoin pour commencer avec le Bot Wikipédia écrit en Python, voir w:fr:Aide:Pywikipedia. Nous supposons que vous avez déjà réalisé ces étapes (Télécharger et installer python, télécharger le bot, créer user-config.py et lancer login.py). Maintenant, pour démarrer, tapez "interwiki.py" (sans les ""), ou si ça ne fonctionne pas, "python interwiki.py".

Le bot demandera une page à vérifier. Donnez une page de votre Wikipédia, de préférence une avec un ou plusieurs liens interwikis. Le bot lira cette page, et si cette page a quelques liens interwiki, il les lira de la même façon, ainsi que les liens interwiki de ces pages, etc. Une fois cette démarche terminée, il procède sur les pages trouvées aux opérations suivantes :

  • Si la page n'a aucun lien interwiki, ou si les liens trouvés sont identiques à ceux sur la page, le bot s'arrête silencieusement.
  • Si le bot trouve de nouveaux liens interwiki vers d'autres langues, ou trouve un lien interwiki ayant besoin d'être changé, il s'en occupera.
  • Si le bot trouve un lien interwiki incorrect ayant besoin d'être supprimé, il demandera la permission de modifier la page.
  • Si le bot trouve plus d'une page par langue, il entrera en mode interactif. Il affiche une liste des pages trouvées et des pages liées à chacune, et demandera pour chaque langue avec plus d'un lien lesquels doivent être traités, puis demandera les autres langues si un lien doit être créé.

Ces comportements peuvent être modifiés via les options (voir plus bas).

Vous pouvez directement indiquer le nom de la page, en utilisant "interwiki.py <nom de la page>". Mais d'autres possibilités sont proposées (voir plus bas).

Travailler sur plus d'une page[edit]

Le logiciel pywikipedia peut télécharger plus d'une page, jusqu'à 60 à la fois. Pour utiliser cette possibilité, vous pouvez utiliser le bot sur une liste de pages. La possibilité la plus utilisée est la récupération des pages par ordre alphabétique depuis Special:Allpages, en utilisant l'option -start.

-start[edit]

Si vous ajoutez l'option -start, le bot va naviguer dans les pages par ordre alphabétique, en démarrant à la lettre spécifiée. Si vous voulez démarrer à la lettre B, par exemple, vous pouvez utiliser "interwiki.py -start:B". Pour la totalité du wiki, utiliser "interwiki.py -start:!"

Redémarrage= -continue, -restore[edit]

Visiter la totalité de wiki peut prendre du temps. Ainsi, il peut bien arriver que vous soyez obligé de quitter le programme avant qu'il ait terminé. Dans ce cas, vous pouvez utiliser "interwiki.py -continue" la prochaine fois. Le bot, quand il plante ou s'arrête (par ctrl-c), créera un fichier spécifiant les pages dans lesquelles il marche. Si vous utilisez l'option "-continue", il continuera avec ces pages, et après cela continuera alphabétiquement. Si vous voulez redémarrer en mode non-alphabétique, vous pouvez utiliser "interwiki.py -restore" à la place. Cela redémarrera juste les pages où il travaillait avant.

Soyez averti que seul le dernier lancement du bot arrêté sera récupérable. Le bot sauvegardera ses informations dans le fichier interwiki.dump, et si un autre lancement échoue, même si cela ne concerne qu'une page, il écrasera le fichier.

Mode autonome[edit]

Quand il travaille sur beaucoup de pages, vous pouvez vouloir que le bot avance plutôt que de tout le temps vous demander s'il y a un problème. Cela se fait en ajoutant l'option "-autonomous" ou "-auto". Si cette option est utilisée, le bot passera tous les problèmes et suppressions, et les enregistrera dans autonomous_problems.dat. Si vous voulez qu'il les retire, ajoutez aussi l'option "-cleanup"; dans ce cas, c'est bien de contrôler les suppressions à la fin (souvent, une page est enlevée à cause d'une typo incorrecte).

Le fichier sax_parse_bug.dat[edit]

Parfois, lorsque le script interwiki.py est lancé, un message d'erreur mentionnant le fichier sax_parse_bug.dat peut apparaitre sur la console, et il commence à retrouver les pages une par une plutôt qu'en paquets. Cette erreur est causée par un caractère illégal sur une des pages qui étaient retrouvées.

Le script xmltest.py peut être utilisé pour retracer le problème. Lancez-le avec le fichier comme ceci:

python xmltest.py sax_parse_bug.dat

Cela va générer un python stack trace. La dernière ligne de ce stack trace va vous montrer la ligne et la colonne où est le caractère illégal dans ce fichier. S'il-vous-plait, regarder cette position, et si c'est possible, corriger la page Wiki associée avec lui.

Traiter les années[edit]

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

Traiter une simple liste de pages[edit]

Sometimes you have a list of pages available. Just a file of subjects, each subject on a separate line, formatted as [[xx:yyy]] comments. The -file option can be used to run the interwiki bot over such a list of subjects. An example of such a file could be an autonomous_problem.dat file that you want to treat manually:

python interwiki.py -file:autonomous.dat

Utiliser les indications[edit]

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 [[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",

Indications spéciales[edit]

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.

Donner des indications de façon interactive[edit]

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.

Wiktionnaire[edit]

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.

Traduction automatique[edit]

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:.

Éviter les liens indésirables[edit]

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.

Travailler avec le fichier de journal[edit]

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.

All Interwikis to en: missing

First an explanation why this is important. Assume you have a page [[My Subject]] that links to [[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.

Liste des options[edit]

Voici la liste des options avec une explication pour celles n'ayant pas déjà été présentées :

  • -array: (usage: "-array:nn" avec nn un nombre) Permet de traiter jusqu'à nn pages simultanément. Par défaut cette valeur à positionnée à 100; when using -untranslatedonly or a similar option, you might want to set it lower.
  • -always: Toujours enregistrer la page même si seulement un caractère a changé ; par défaut il faut qu'un lien ait été modifié pour que la page soient enregistrée.
  • -askhints: Demande des indications (voir ci-dessus)
  • -async: Mets la page dans une file d'attente et l'enregistre sur le wiki de manière asynchrone. Cela permet de charger des pages pendant que l'opération de sauvegarde est en attente et fournit de meilleures performances.
  • -autonomous: Travaille sans poser de questions donc sans intervention du dresseur
  • -cleanup: Like -force, keeping disambiguation mismatch and namespace mismatch unchanged
  • -confirm: Demande toujours une confirmation pour modifier une page
  • -days: Travaille sur les liens des jours
  • -file: (usage: "-file:filename") Indique un fichier contenant la liste des pages à traiter. Le nom des pages doit être formaté ainsi : [[Projet:langage:Nom_de_la_page]], [[langage:Nom_de_la_page]] ou [[Nom_de_la_page]].
  • -force: Quand un lien interwiki doit être enlevé, le faire sans demander une confirmation.
  • -hint: Donner une indication (voir ci-dessus)
  • -name: Ancienne option ; équivalente à "-hint:all", mais met en majuscule le dernier mot pour eo:. Pourrait être dépréciée.
  • -neverlink: Ne pas ajouter de lien dans le langage spécifié (voir détails plus haut).
  • -noauto: Ne pas utiliser la traduction automatique (voir détails plus haut).
  • -nobacklink: Ne pas donner une liste des liens manquants dans les pages liées.
  • -nobell: Pas de signal sonore pour indiquer une demande de confirmation.
  • -noredirect: Si le bot trouve une page liée avec un redirect, il l'ignore (le comportement par défaut est de suivre le redirect).
  • -noshownew: Ne pas afficher les nouveaux liens trouvés
  • -number: (utilisation : "-number:nn" où nn est un nombre) Utilisé en combinaison avec -start, vérifie seulement les premières nn pages plutôt que tout le wiki.
  • -same: Ancienne option ; équivalente à "-hint:all" ; pourrait être dépréciée
  • -showpage: Quand -askhints ou une option similaire est utilisée, toujours montrer le texte de la page, même s'il n'est pas demandé.
  • -skipfile: (usage "-skipfile:filename") On a run using -start, do not do the pages in the file start
  • -untranslated: Ask hints for untranslated pages (see above)
  • -untranslatedonly: Ask hints for untranslated pages (see above)
  • -warnfile: Use the logfile for pages and hints (see above)
  • -wiktionary: positionne des options spécifiques à wiktionary (voir détails plus haut).
  • -years: Travaille sur les liens des années.