Wikipedia:WikiProject Interlanguage Links/Scripts: Difference between revisions
Content deleted Content added
mNo edit summary |
mNo edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 49:
----
Extract the information required, ie:
----
<pre>
// suggested reciporcal links
// a:x -> b:x and b:x exists and no link from b:? to a:x exists => b:x -> a:x
Line 65 ⟶ 66:
AND b.from_title = a.to_title
AND b.to_lang = a.from_lang
WHERE a.from_lang
AND a.to_lang = 'en'
AND b.from_lang IS NULL;
// Interlanguage links to pages that do not exist
// en -> fr only
INSERT INTO suggestions
SELECT a.from_lang, a.from_title, a.to_lang, a.to_title
FROM inter a
INNER JOIN en.page f
ON f.page_title = a.from_title
AND f.page_namespace = 0
AND f.page_is_redirect = 0
LEFT JOIN fr.page t
ON t.page_title = a.to_title
AND t.page_namespace = 0
WHERE a.from_lang = 'en'
AND a.to_lang = 'fr'
AND t.page_title IS NULL
// Interlanguage links to redirects
// en -> fr only
SELECT a.from_lang, a.from_title, a.to_lang, a.to_title
FROM inter a
INNER JOIN en.page f
ON f.page_title = a.from_title
AND f.page_namespace = 0
AND f.page_is_redirect = 0
INNER JOIN fr.page t
ON a.to_title = t.page_title
AND t.page_namespace = 0
AND t.page_is_redirect = 1
WHERE a.from_lang = 'en'
AND a.to_lang = 'fr';
</pre>
----
Finally, extract these suggestions in a human-
----
<pre>
Line 81 ⟶ 115:
DECLARE sug_pos, sug_base, done INT;
DECLARE ftitle, ttitle VARCHAR(255);
DECLARE sug CURSOR FOR SELECT DISTINCT from_title, to_title FROM suggestions WHERE from_lang = flang AND to_lang = tlang;
DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' SET done = 1;
|