Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Building a Fast Wikipedia Offline Reader

Posted by kdawson on Mon Aug 13, 2007 09:53 PM
from the you-could-look-it-up dept.
ttsiod writes "An internet connection is not always at hand. I wanted to install Wikipedia on my laptop to be able to carry it along with me on business trips. After trying and rejecting the normal (MySQL-based) procedure, I quickly hacked a much better one over the weekend, using open source tools. Highlights: (1) Very fast searching. (2) Keyword (actually, title words) based searching. (3) Search produces multiple possible articles, sorted by probability (you choose amongst them). (4) LaTeX based rendering for mathematical equations. (5) Hard disk usage is minimal: space for the original .bz2 file plus the index built through Xapian. (6) Orders of magnitude faster to install (a matter of hours) compared to loading the 'dump' into MySQL — which, if you want to enable keyword searching, takes days."
+ -
story

Related Stories

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • Wow! (Score:3, Funny)

    by ferrocene (203243) on Monday August 13 2007, @09:56PM (#20220565) Journal
    After doing all that, I think you may have missed your flight! :)
      • Re: (Score:3, Insightful)

        This may seem like a stupid, trivial, and pointless project, but the programmer may have gained something from it that he could use later in something you don't feel that way about. If the programmer enjoyed doing it, that might have lead to a more productive coding session later in the day too.
      • Re:Why? (Score:5, Funny)

        by rabblerabble (884373) on Monday August 13 2007, @10:20PM (#20220707)
        I'll bite...Unfortunately, I don't have a basement, so therefore there are times that I am required to venture into the outer realm that happens to be heated by the big ball of gas known as Sol, as opposed to a pump ;P Seriously though, this is exactly what I have been looking for. What better way to show up your friends when they cry "You're wrong, google it!" knowing that there is no connection possible within twenty miles. Next time i'm drunk at the beach and someone wants to pretend to know the history of coffee harvesting, it's on.
      • by ampathee (682788) on Monday August 13 2007, @10:22PM (#20220719)

        Programmers shouldn't be wasting time on these trivial, pointless projects. We need their work in other more important projects!
        Hah! I'm going to start work on (let's see..) a random lolcat generator now, just to piss you off.
      • Programmers shouldn't be wasting time on these trivial, pointless projects. We need their work in other more important projects!

        Ironically, You're already reading slashdot. You had just wasted your time.















        You're reading it again, wasting more time ehh??....

        But the point is, if programming an offline wikipedia makes you happy and you don't need the money then you would understand....

      • Re:Why? (Score:5, Insightful)

        by thePsychologist (1062886) on Tuesday August 14 2007, @12:05AM (#20221433) Journal
        Realize that some of the greatest things done by humankind were from doing "pointless projects" as you call them. Prime numbers for instance were studied by mathematicians just for fun, and now look, they're used for cryptography. Try doing your banking without them.

        Complex numbers originated from something "useless" like trying to solve the quartic polynomial in radicals...try building a bridge without them. In fact all of science is built upon people going in random tangents doing things they enjoy, discovering seemingly "useless facts" but most of it becomes useful *and* gives us an idea of the universe in which we live.

        Only working on immediate practical problems is very shortsighted, and if mandated throughout the academic community, would mean the death of innovation and most discoveries.
  • Ho-Hum ... (Score:5, Funny)

    by jabberwock (10206) on Monday August 13 2007, @10:21PM (#20220715) Homepage
    What, no auto update? No User Agreement? No disabled features that are enabled by a mammoth key? No product registration?


    Let us know when you're ready for prime time ... ;-)

    • Re:Ho-Hum ... (Score:5, Insightful)

      by OzRoy (602691) on Tuesday August 14 2007, @12:18AM (#20221501)
      Auto-update would be interesting. How do you keep the data up to date without downloading the entire 2.9G again? Is there some sort of diff file you can download?
      • How do you keep the data up to date without downloading the entire 2.9G again?

        Not too hard if you have a sub-etha net connection handy. Better check that the article about The Earth which you have been working on hasn't been cut down to two words though.

  • I hope (Score:4, Funny)

    by Nikron (888774) on Monday August 13 2007, @10:36PM (#20220817)
    That you don't dump the wiki at a bad time.

    George W Bush

    Is a dick head!!!!11

    • Re:I hope (Score:5, Funny)

      by Anonymous Coward on Monday August 13 2007, @10:58PM (#20220979)
      You mean before someone makes it inaccurate again?

      Oh, nevermind, I see the problem:

      George W Bush

      Is a dick head!!!!11

      should be

      George W Bush

      Is a dick head!!!!!!

      Man, those out to mess with the content are getting more and more subtle...
  • But... (Score:2, Funny)

    by Anonymous Coward
    What's the point of it if there are no vandals or flame wars to make it interesting?
  • by Brietech (668850) on Monday August 13 2007, @10:45PM (#20220879)
    Combine this and one of the new E-ink ebook readers, make it pretty rugged, slap a solar panel on the back and man. . . you have something really close to a genuine hitchhiker's guide to the galaxy. Ah, I love where technology is heading =)
    • by Sneftel (15416) on Monday August 13 2007, @10:55PM (#20220949)
      As long as hitchhikers primarily need to know how to evolve a Pikachu into a Raichu, and how Benjamin Disraeli has been referenced in pop culture.
      • by RandomWhiteMan (685768) on Monday August 13 2007, @11:08PM (#20221051)
        You laugh now, but just wait until you're stranded in the middle of Blackheath England, needing a ride from a conservative British History Scholar who has his son with him playing Pokemon Gold. Won't be so smug then, will you. I bet you won't even have your towel on you when this all goes down.
      • by cowens (30752) on Tuesday August 14 2007, @02:06AM (#20221949)
        Ah, but that is what the original HHGTTG was as well. Tons of info on alcohol and Eccentricea Gallumbits (the triple breasted whore of Eroticon Six), but the entry for Earth was: Harmless. Later it was expanded: Mostly Harmless.
      • by nstlgc (945418) on Tuesday August 14 2007, @02:31AM (#20222091)
        Just so we're clear, you can make Pikachu evolve into Raichu by using the Thunder Stone (which makes sense, since they're Electric Pokémon). However, due to the emotional value Pikachu has to trainers, most of them choose not to evolve him. Some Pokémon games even plain don't allow this. I hope this was helpful.
    • Don't forget to put this on the cover, in large reassuring letters:

      DON'T PANIC
    • by Gromius (677157) on Tuesday August 14 2007, @01:53AM (#20221905)
      Yes its a perfect fit. Particularly as Wikipedia has now supplanted the Encyclopedia Britannica in many places as the standard repository of all knowledge and wisdom. Although it has many omissions, contains much that is apocryphal, or at least widely inaccurate, it scores over the older more pedestrian work in two important ways.

              * 1. It is slightly cheaper
              * 2. It has the words "You can copy and edit me for free" inscribed in large friendly letters in the license.

      Also like the guide, although it cannot hope to be useful or informative on all matters, it does make the reassuring claim that where it is inaccurate, it is at least definitively inaccurate :)

  • by Anonymous Coward

    I was able to build this in two days, most of which were spent searching for the appropriate tools. Simply unbelievable... toying around with these tools and writing less than 200 lines of code, and... presto!
    Give that man a job at Google.
  • by phliar (87116) on Monday August 13 2007, @11:27PM (#20221185) Homepage
    For a change it's not just a link to a .tar.gz somewhere, but an actual article where he goes through what he did, and (more important) why he did things that way. Good reading even if you don't want an off-line Wikipedia.
  • It doesn't take days (Score:5, Informative)

    by BReflection (736785) on Tuesday August 14 2007, @12:10AM (#20221467) Homepage
    It only takes days if you use the php import script to import the sql dump, which was not designed for importing the entire dump.

    Use the ANSI C implementation, which takes about 20 minutes to convert the XML to SQL and then takes a few hours to import into MySQL. Please not that you need a properly configured MySQL server in order to efficiently run a local copy of Wikipedia, which must have at least 8GB of ram.

    http://meta.wikimedia.org/wiki/Xml2sql [wikimedia.org]
  • by Splab (574204) on Tuesday August 14 2007, @12:32AM (#20221557)
    is very very slow when you do it on a normal installation, the reason is MySQL comes with a "be nice to people who don't know what they are doing" setup. Go into the my.cnf and find the buffer settings, crank them up and restart the server. It can really do a lot (especially if you are running InnoDB which you of course are since MyISAM isn't a proper database).
  • What?? (Score:5, Funny)

    by icydog (923695) on Tuesday August 14 2007, @12:48AM (#20221617) Homepage
    TFA is:

    1. Not a thinly-veiled attempt to advertise a crappy product
    2. Not bashing Microsoft
    3. Not about somebody who is trolling open-source (i.e. SCO)
    4. Not about Bush taking away all our rights and ending freedom
    5. Not about voting fraud and the end of democracy/America/the world
    6. Not decrying Vista DRM and its ties to the MAFIAA
    7. Posted on Slashdot

    Furthermore, TFA is interesting and informative.

    Am I in heaven?
  • by mu22le (766735) on Tuesday August 14 2007, @03:28AM (#20222305) Homepage Journal
    A PSP is very portable (fits in your sweater/backpack), hackable, and has up to 8Gb of storage. I have been dreaming for an year about porting wikipedia to it. Unfortunately I'm not familiar with the kind of programming needed and I could never find the time...
    • by tepples (727027) <slash2006&pineight,com> on Tuesday August 14 2007, @06:23AM (#20222965) Homepage Journal

      A PSP is very portable (fits in your sweater/backpack), hackable
      You have to buy a used PSP to be sure that you can hack it. New ones are likely to come with firmware version 3.51 or later, which is not cracked as of August 2007. The Nintendo DS, on the other hand, had its last major firmware update in September 2005 and is still cracked, with SLOT-1 modchips available at Wal-Mart for $30.

      and has up to 8Gb of storage
      So does a CompactFlash card in a GBA Movie Player in a Nintendo DS. It's a pity that the SLOT-1 adapters for DS haven't been shown to be compatible with SDHC.
  • by dannycim (442761) on Tuesday August 14 2007, @04:25AM (#20222493)
    There's a serious problem with the article's way of treating the data that I didn't see addressed.

    The wikipedia database file is one large bzip2'ed XML file which the author splits into blocks of 900k (bzip2's natural blocking) which he then parses for the "title" and "text" XML tags.

    The problem with that approach is that some of these tags may well end up being split over block boundaries, so some articles risk being missed. EG:

    END-OF-BLOCK: blablablabla...blabla[/text][othertag][ti

    START-OF-NEXT-BLOCK: tle][sometag]blablablablabla...

    So searching for "[title]" in boths blocks separately like TFA does will fail for one article.

    (I've used square brackets instead of lessthans and greaterthans because slashdot won't let me use them.)
    • by ttsiod (881575) on Tuesday August 14 2007, @11:53AM (#20226505) Homepage
      (Re-post: for some reason the response I sent some hours ago didn't appear) No, actually there is no bug. If you read the contents of the 'show.pl' script, you'll see that it adapts to a missing '</text>' by reading from the next volume - the next recxxx...bz2.

      As for the title, what you describe can't happen because of a fortunate side-effect: when compressing, bzip2 (as other compressors) look for previous appearances of a token (in this case, '<title>') and code a reference to it (instead of the full text) to save space. Since "text" and "title" appear all the time in these blocks (at least once for each article), they will NOT be split - they will be encoded as "references", and therefore, what you describe shouldn't happen (I hope :-)

    • Re:Uh.... (Score:5, Interesting)

      by dhwebb (526291) on Monday August 13 2007, @10:40PM (#20220837) Homepage Journal
      Programming something new to some people is like playing a video game. I love programming useless things just for the challenge. People who don't understand that have never had a true love for programming.
      • Re: (Score:2, Insightful)

        I love programming useless things just for the challenge.

        Have you ever worked on a project called "Clippey", by chance?
             
        • Re:Uh.... (Score:5, Funny)

          by Gazzonyx (982402) on Monday August 13 2007, @11:53PM (#20221377)

          I love programming useless things just for the challenge.

          Have you ever worked on a project called "Clippey", by chance?
          No, he said he has a love for programming; not a seething hatred for users. Besides, everyone knows programmers only hate admins. ;) On behalf of the programmers, I'd like to say that this isn't true we love our admins. Who else makes sure that our connections*&#^$: Connection Reset By Peer
      • Re:Uh.... (Score:4, Informative)

        by stephanruby (542433) on Monday August 13 2007, @11:38PM (#20221265)

        Programming something new to some people is like playing a video game.
        Speaking of which, http://www.pyweek.org/ [pyweek.org] is coming up this first week of September. It's time to dust off that python book (or borrow one from someone) and do whatever you have to do to get some days off that week.
      • I know the feeling (Score:5, Insightful)

        by aepervius (535155) on Tuesday August 14 2007, @12:30AM (#20221543)
        They say to you that their hobby is painting/music/walking/repairing old car/gardening/making reduced model etc... And they seem to think that their hobby are perfectly acceptable. But as soon as you say you like to program stuff, they don't understand how this would be a hobby. They mostly fail to recognize that every one of us has something in common : the joy of act of creation. The fact that our hobby entail creating something immaterial and full of "logic" does not matter. It is still a joy.
      • Re: (Score:3, Interesting)

        I was that way, once. Then other hobbies came along, and now I rarely do any programming thats not work related.

        Its funny how time changes you.
    • So you can settle trivial arguments with your friends when away from an internet connection, duh!

      (Or to always have something to read on your laptop while traveling - this is what I would use it for)
      • So you can settle trivial arguments with your friends when away from an internet connection, duh!

        (Or to always have something to read on your laptop while traveling - this is what I would use it for)
        I bet you're quite the ladies man, huh?
        Sorry, I couldn't resist!
    • by Tacvek (948259) on Monday August 13 2007, @11:14PM (#20221083) Journal
      My very serious question to you is how much better do you think things are at a "real" encyclopedia. They have many of the same problems, but they are just not public. "Real" encyclopedias can be just an inaccurate as the Wikipedia on many articles. For a quick first reference, Wikipedia is an ideal tool. Just be sure to take things with a grain of salt if you are not checking the sources for further information. Guess what though, the same applies to "real" encyclopedias too. One difference is that with "real" encyclopedias, you always lack revision information, and you often lack information about the sources used by the editors. (Some encyclopedias are better than others in that respect.)
      • by gad_zuki! (70830) on Tuesday August 14 2007, @12:04AM (#20221429)
        Yes, the paper encyclopedias are missing all the anime trivia. Christ, its embarassing to see "references in pop culture" sections which just spell out every geeky guy stereotype. I dont know why those people dont get banned. Everything in existance has an anime reference. That is unsettling.
    • Blatantly stolen from David Morgan-Mar [livejournal.com].

      In many of the more relaxed corners of the Outer Eastern Rim of the Internet, Wikipedia has already supplanted the great Encyclopaedia Britannica as the standard repository of all knowledge and wisdom, for though it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, it scores over the older, more pedestrian work in two important respects.

      First, it is slightly cheaper; and secondly it has the words "anyone can edit" inscribed in l

    • Re:2X (Score:5, Informative)

      by Brian Gordon (987471) on Monday August 13 2007, @11:24PM (#20221161)
      Ahaha, 2.9GB? That's the text alone. Images will net you more than 200GB [wikimedia.org] more. And yes, you do need a LAMP/WAMP and working mediawiki, but it wouldn't take 'days' it would take a few hours max. Also is this guy aware that wikipedia is available on DVD [wikipedia.org] already?
    • Re:The Point? (Score:5, Insightful)

      by Mr. Roadkill (731328) on Tuesday August 14 2007, @02:26AM (#20222067)

      I know that not everyone has a permanent connection to the net everywhere they go, but what is the point of storing a local copy of Wikipedia?
      Ummm... I think the whole point is, as you've pointed out, that not everyone has a permanent connection to the net everywhere they go. Or maybe they don't have access to everything they'd like even if they *do* have net access everywhere, or want to pay extravagant data rates while out and about.

      Joe has all-you-can-eat broadband at home, or an understanding employer with a fat pipe, and spends two hours each day on the train. Two and a half gig per month (and lets face it, you probably don't want to update it more frequently that that) and he's got probably half his reading material sorted out.

      Wang lives in Buttfuckistan, a fictional country with totalitarian leanings with too many real-world counterparts. The Great Firewall of Buttfuckistan (i.e. squidguard, under the control of Buttfuckistan Telecom, and settings in the routers to drop non-port-80 traffic half the time) makes it impossible to reliably access Wikipedia from inside their borders, which is a great shame because the entry on Buttfuckistan is particularly unflattering. Once a month, Joe sticks a DVD with five minutes from an old re-run of Friends and an encrypted dump of Wikipedia in an airmail envelope and sends it to Wang.

      Mary is still at secondary school, and her particular school has wifi access for students who are encouraged to purchase their own laptops, but since the local pastor discovered http://en.wikipedia.org/wiki/Image:Dream_of_the_fi shermans_wife_hokusai.jpg [wikipedia.org] they've been forced to add wikipedia to the school's blocklist. Which is a pity, because it's a great first-approximation source for material or research directions, but there you go. Mary can make a local copy through her home broadband connection, and can access it locally on her laptop wherever she goes - even at school, or church. Bill, Jillian and Mungo (the pastor's son) find out about this, and now all four of them take it in turns to make the copy each month, sharing the bandwidth costs. Their friends Harry and Sally, who don't have broadband but are great friends of the other four, also get copies... and there are plans to distribute the copies further, as a kind of teenage grass-roots knowledge-sharing and social-justice effort.

      Still can't see the point?
    • Re: (Score:3, Informative)

      Do you mean searching takes days, or loading? Searching should be quick if you index the words. If you are duplicating a bunch of local clones of wiki, then simply copy down the raw MySql table data files rather than reload from delimited files etc. (One needs to make sure their version of MySql is compatible with the table file format.)

      I suspect the former, plus creating the index, plus the not inconsiderable overhead of running an SQL server.

      DBs have their place. For a "real" Wiki, or more generally