User:Jimregan: Difference between revisions

From Mediawiki1
Jump to navigationJump to search
m (add a slight introduction, fix the overuse of 'do' in Anja's warning.)
m (pre, not nowiki)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
The quick and dirty script below gets a naive list of templates for which there is no mapping (as of the last extraction).
<pre>
<pre>
#!/bin/bash
import net.sourceforge.jwbf.bots.MediaWikiBot
for lang in $@
import net.sourceforge.jwbf.contentRep.Article
do
import scala.io.Source._
    wget http://downloads.dbpedia.org/3.6/${lang}/infobox_properties_${lang}.nq.bz2
    bzgrep 'http://dbpedia.org/property/wikiPageUsesTemplate' infobox_properties_${lang}.nq.bz2 |awk '{print $3}'|sort -n| uniq -c|sort -nr > ${lang}-templates
    cat ${lang}-templates |awk '$1>49{print " " $0}'|sed -e "s/<http:\/\/dbpedia.org\/resource\/Template:/[[Mapping_${lang}:/"|sed -e 's/>/]]/' > ${lang}-mappings
done
</pre>


<b>Please note that not all templates listed are infoboxes. Please only map infoboxes.</b>
val m = new MediaWikiBot("http://mappings.dbpedia.org/")
m.login("Username", "password")
val links = fromFile("/tmp/articles", "utf-8").getLines


<b>Also, handle redirects carefully. If not intended otherwise, only map the main infobox, not redirects to it.</b>
links.foreach {
 
first => {
;[[User:Jimregan/ca.wikipedia]]
val art = new Article(m.readContent(first), m)
;[[User:Jimregan/de.wikipedia]]
art.setText(art.getText.replaceAll(" twinCity ", " twinTown "))
;[[User:Jimregan/el.wikipedia]]
art.setMinorEdit(true)
;[[User:Jimregan/en.wikipedia]]
art.setEditSummary("s/twinCity/twinTown/")
;[[User:Jimregan/es.wikipedia]]
art.save
;[[User:Jimregan/fr.wikipedia]]
}
;[[User:Jimregan/ga.wikipedia]]
}
;[[User:Jimregan/hr.wikipedia]]
</pre>
;[[User:Jimregan/hu.wikipedia]]
;[[User:Jimregan/it.wikipedia]]
;[[User:Jimregan/nl.wikipedia]]
;[[User:Jimregan/pl.wikipedia]]
;[[User:Jimregan/pt.wikipedia]]
;[[User:Jimregan/ru.wikipedia]]
;[[User:Jimregan/sl.wikipedia]]
;[[User:Jimregan/tr.wikipedia]]
 
 
;[[User:Jimregan/cs.wikipedia]]
;[[User:Jimregan/sk.wikipedia]]

Latest revision as of 15:54, 6 April 2015

import net.sourceforge.jwbf.bots.MediaWikiBot
import net.sourceforge.jwbf.contentRep.Article
import scala.io.Source._

val m = new MediaWikiBot("http://mappings.dbpedia.org/")
m.login("Username", "password")
val links = fromFile("/tmp/articles", "utf-8").getLines

links.foreach { 
	first => {
		val art = new Article(m.readContent(first), m)
		art.setText(art.getText.replaceAll(" twinCity ", " twinTown "))
		art.setMinorEdit(true)
		art.setEditSummary("s/twinCity/twinTown/")
		art.save
	}
}