User:Jimregan: Difference between revisions

From Mediawiki1
Jump to navigationJump to search
m (stick the recipe here so I don't have to rely on shell history)
m (pre, not nowiki)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<pre>
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


<pre>
links.foreach {
wget http://downloads.dbpedia.org/3.6/ca/infobox_properties_ca.nq.bz2
first => {
bzgrep 'http://dbpedia.org/property/wikiPageUsesTemplate' infobox_properties_ca.nq.bz2 |awk '{print $3}'|sort -n| uniq -c|sort -nr > ca-templates
val art = new Article(m.readContent(first), m)
cat ca-templates |awk '$1>49{print " " $0}'|sed -e 's/<http:\/\/dbpedia.org\/resource\/Template:/[[Mapping_ca:/'|sed -e 's/>/]]/' > ca-mappings
art.setText(art.getText.replaceAll(" twinCity ", " twinTown "))
art.setMinorEdit(true)
art.setEditSummary("s/twinCity/twinTown/")
art.save
}
}
</pre>
</pre>
[[User:Jimregan/pl.wikipedia]]
[[User:Jimregan/ca.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
	}
}