사용자:WonRyong/interwiki.py

위키문헌 ― 우리 모두의 도서관.

인터위키 봇은 문서 좌측의 외국어 위키백과 링크를 관리하는 봇이다.

시작하기[편집]

파이톤 위키피디아 봇의 사용을 시작하기 위해 m:Using the python wikipediabot 또는 User:WonRyong/Bot Howto를 참조하라. 우리는 당신이 봇 실행하는 법을 안다고 전제한다.(파이톤 언어와 봇 소스 프로그램의 다운로드, user-config.py파일의 생성, 그리고 login.py의 실행) 시작하기 위해서 cmd 창에서, "interwiki.py" 라고 치거나 "python interwiki.py"라고 치면 된다.

The bot will ask for a page to check. Give a page on your home Wikipedia, preferably one with one or more interwiki-links that could however have more. The bot will read this page, and if it has any interwiki-links, it will check those pages as well, and the interwiki-links from those, etcetera. After it has finished that, what happens on what pages it found.

  • If the page has no interwiki links, or if the links found are identical to the ones on the page, the bot will stop silently.
  • If the bot finds interwiki links to new languages, or finds that an interwiki-link has to be changed, it will do so.
  • If the bot finds that an interwiki link is to be removed, it will ask your permission to do so.
  • If the bot finds more than one page for a language, it will go into an interactive mode. It will give the pages found with the pages that link to that page, and ask for each language with more than one link, which if any should be linked to, then ask for each language with one link whether it should be linked.

Note that these behaviours can be changed using options, see below.

You can also specify the page to work on directly, using "interwiki.py pagename". But there are more possibilities, see below.

여러 문서 자동으로 작업하기[편집]

XML Export를 사용하여, pywikipediabot-소프트웨어는 한번에 최대 60개 까지의 여러 문서들을 일괄처리할 수 있다. 가장 일반적인 방식은 -start 옵션 을 사용하여, Special:Allpages에서 알파벳 순서로 문서를 가져와서 일괄처리하는 것이다.

-start 옵션[편집]

-start 옵션을 추가하면, 봇은 거기서 정해준 알파벳 부터 알파벳 순으로 페이지를 처리해나간다. 만약 B부터 시작하려면 interwiki.py -start:B 라고 입력하면 된다. 전체 페이지를 알파벳 순서로 처리하려면 interwiki.py -start:! 라고 입력하면 된다.

다시 작업 시작하기: -continue, -restore 옵션[편집]

인터위키 봇 실행하면 엄청나게 오랜 시간 작업을 계속한다. 따라서, 중간에 중단했다가, 다시 나중에 그 중단된 부분부터 시작하는 옵션이 있다.

CTRL+C로 작업을 중도에 중단한 경우, interwiki.py -continue 를 입력하면 중단된 부분부터 작업을 다시 시작한다.

-continue 옵션을 사용하면, 중단된 부분부터, 알파벳 순서로 작업하기 시작한다.

만약 알파벳 순서가 싫다면, interwiki.py -restore 을 입력하면 된다.

Be warned that only the last bot run that was stopped will be recoverable. The bot will save its information to a file interwiki.dump, and if another run is broken off, even if it is only on one page, it will overwrite the file.

자동 모드[편집]

많은 페이지를 작업하는데, 문제 발생시 봇이 일일이 사용자에게 해결을 물어오면, 번거롭다. 문제발생시 질문을 답해주지 않고, 사용자가 어디 다른 일을 보고 있다면, 봇은 계속 질문에 대한 답만 기다리면서 작업을 멈추어 버린다. 이럴 경우, 문제가 발생하면 질문하지 않고 넘어가게 하는 옵션이 -autonomous 이다. 이 옵션을 사용하면, 질문이나 문제발생 또는 삭제발생으로 중간에 멈추는 일 없이 무조건 자동처리를 한다. 그리고 로그 파일은 autonomous_problems.dat 의 이름으로 저장한다. 만약 삭제발생시 자동으로 삭제하길 바란다면, -force 옵션을 같이 사용해 주면 된다. (often a page is removed because of a correctable typo).

sax_parse_bug.dat 파일[편집]

Sometimes there is an error message mentioning a file sax_parse_bug.dat on the screen while running interwiki.py, and then it starts retrieving some pages one-by-one instead of in a single batch. This is caused by an illegal character in one of the pages to be retrieved.

The tool xmltest.py can be used to trace this problem. Run it with the filename as argument:

python xmltest.py sax_parse_bug.dat

This will generate a python stack trace. The last line of that stack trace will show a line number and column where the illegal character is in the file. Please check this position, and if possible, correct the wiki page associated with it.

년도별로 작업하기[편집]

-years 옵션은 일본어 위키백과 같은 곳에서는 제대로 작동하지 않는다. 따라서 확인이 필요하다. 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]]

만약 -years 옵션으로 봇 작업을 하다가 중단한 경우에, 나중에 연속해서 하려면, 중단되었던 년도를 -years:XYZ 옵션에 적어서 재시작할 수 있다.

다음과 같이, XYZ에 마이너스 숫자를 입력하여 기원전(B.C.) 부터 작업을 시작할 수도 있다:

python interwiki.py -autonomous -years:-500

-file 옵션[편집]

autonomous.dat 라는 외부 파일에다가, 사용자는 다음과 같이 위키백과 페이지 목록을 적어서 저장할 수 있다. 물론 파일명은 다른 이름이어도 된다:

 [[plane]]
 [[vehicle]]
 [[train]]
 [[car]]

autonomous.dat이란 이름으로 저장한다. 그리고 봇 명령을 다음과 같이 입력한다:

python interwiki.py -file:autonomous.dat

그러면, 봇은 plane, vehicle, train, car의 문서만 인터위키 작업을 할 것이다.

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

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.

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.

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.

자동 번역[편집]

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.

-years:년도숫자 옵션을 사용하면, (숫자는 양수 또는 음수로 기입) 봇은 지정한 년도에서 부터 2050년 까지 작업을 한다. 만약 -years만 입력하고 년도숫자는 쓰지 않으면, AD 1년 부터 2050년까지 작업한다.

-days 옵션을 사용하면, 그 해의 날짜 부터 작업한다. 그러나 이 봇은 오직 nl: 버전에서만 제대로 작동한다.

원하지 않는 링크 생략하기[편집]

원하지 않는 것에 대한 작업을 생략하게 하는 명령으로, -noredirect 또는 -neverlink 옵션이 있다.

-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 옵션은, xx: 에 언어 코드를 사용하여, 지정한 언어코드의 어떤 링크도 작업을 생략한다.

logfile로 작업하기[편집]

interwiki.py 프로그램은 스크린 상의 문서에만 작업하는 것이 아니고, logs/interwiki.log 에도 작업을 동시에 한다. interwiki.log 파일을 이용하는 것은 그냥 인터위키 봇을 사용하는 것 보다 훨씬 편하다.

All Interwikis to en: missing

이 기능이 왜 중요한지를 설명한다. [[My Subject]]라는 영어 문서가 있다고 가정하자. 이 문서는 [[fr:Mon Sujet]] 과 [[nl:Mijn Onderwerp]] 에 인터위키 링크가 되어 있다. 또한, 영어문서에는 nl: 이나 fr: 페이지는 링크되어 있지 않다. 그러나 동일한 항목이 nl: 과 fr: 서로간에는 링크되어 있다.

이 경우에, interwiki.py 를 fr: 이나 nl: 에서 실행하면 en: 페이지는 찾아내지 못한다.

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. 이 경우 당신은 수동으로 이 링크 문제를 해결해야만 할까? 아니다. 다음과 같은 해결방법이 있다. 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.

이러한 이유 때문에, 인터위키 봇에는 또다른 옵션이 존재한다:

python interwiki.py -warnfile:english_treelang.log

이 모드에서, 인터위키 봇은 경고파일(warnfile)인 english_treelang.log 을 읽을 것이다. 그리고 그 파일 안에 있는 모든 페이지들을 처리하기 시작할 것이다.

이 작업은 아직 오랜 시간을 소요한다. 만약 로그파일을 생성하는 사용자 중 당신이 신뢰하는 이가 있다면, 그리고 로그파일이 최신이라면, 당신은 또한 이렇게 할 수도 있다:

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.

지금은, 모든 interwiki.log 파일을 모든 사용자에게 보내는 것을 대신하는, 새로운 봇이 있다:

python splitwarning.py

이것은 당신의 interwiki.log 을 읽을 것이다.

그리고 훨씬 사용이 편리한 warning_XX.log 파일을 생성할 것이다. (각각의 언어별로 하나씩)

만약 이것을 압축해서, 인터넷 어딘가에 다른 사용자들이 이용할 수 있게 하고자 한다면, m:Interwiki bot/Warnfiles을 통해 이것을 알릴 수 있다.

옵션 목록[편집]

여기엔 옵션과 그 설명이 있다. 이것들은 아직 토론된 적 없다.

  • -array: (usage: "-array:nn" with nn a number) When working on several pages, make sure to have at least this number of pages the bot is working on, if possible. The default value is 100; when using -untranslatedonly or a similar option, you might want to set it lower.
  • -always: Always save the page, even if only one byte has changed (default: save the page only if at least one link has actually changed)
  • -askhints: Ask hints (see above)
  • -autonomous: Work in autonomous mode (see above)
  • -confirm: Always ask permission before changing a page.
  • -days: Work on the days
  • -file: (usage: "-file:filename") Specifies a file containing a list of pages to process. (Page names are specified as [[project:lang:pagename]], [[lang:pagename]], or [[pagename]].
  • -force: When an interwiki link is to be removed, just do it, don't ask for permission
  • -hint: Give a hint (see above)
  • -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 (see above)
  • -noauto: Do not use automatic translation (see above)
  • -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 (see above)
  • -untranslatedonly: Ask hints for untranslated pages (see above)
  • -warnfile: Use the logfile for pages and hints (see above)
  • -wiktionary: Special wiktionary options (see above)
  • -years: Work on the years

더 보기[편집]

영어 위키백과에서 봇을 이용하려면, 반드시 이 문서에 자신의 봇 이름을 추가해야만 접속이 된다.
따로 봇 사용허가가 없이 그냥 등록하는 경우라면 without flag, 즉 비공식적인 봇 명단에 추가하면 된다.