Wikipedia:Reference desk/Archives/Computing/2013 October 8

Computing desk
< October 7 << Sep | October | Nov >> October 9 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


October 8

edit

e-Books

edit

This probably is going to sound stupid, but I am dealing with a new smartphone and I want to add some e-Books for me to read them. I have installed some app called Laputa or something, but it doesn't show any book on the virtual shelf, the question is... how do I add a book and which formats are e-Books? Miss Bono [hello, hello!] 14:11, 8 October 2013 (UTC)[reply]

I had never heard of that, but after a little research, it looks like the Laputa android app is no longer supported, and the content provider it used to give access to books no longer exists. So I think probably you should look for a different solution. What sort of smartphone is it, and what company provides your phone service? Looie496 (talk) 15:18, 8 October 2013 (UTC)[reply]
It's a Samsung Galaxy Appeal. Miss Bono [hello, hello!] 15:41, 8 October 2013 (UTC)[reply]
What about Google Books? (link to Play store) They have a decent collection and a lot of free ones. Thanks Jenova20 (email) 15:45, 8 October 2013 (UTC)[reply]
Kindle and Nook apps are also available on Android if you want to buy books from Amazon or Barnes&Noble respectively. APL (talk) 18:57, 8 October 2013 (UTC)[reply]
Some libraries also allow you to "borrow" digital books. Ie. they stop working after a certain amount of time (or, you have to "return it" after a certain amount of time...) I don't know if their methods apply to both ereaders (my - narrow - experience) and ebook apps on smartphones (no experience at all); though I can't see how they couldn't, as the majority of the customers these days are probably using their phones over dedicated ereaders. --.Yellow1996.(ЬMИED¡) 22:57, 8 October 2013 (UTC)[reply]
I use Moon+ ebook reader on my small Android tablet and find it very good because it's highly customisable. It can deal with both epub and mobi format ebooks. There's a free version.-gadfium 02:45, 9 October 2013 (UTC)[reply]

Using software 'mwdumper'

edit

Hello I have been given a project to create a database of almost 1600 wikipedia articles. I have been using the software mwdumper to store one .xml article file at a time to the database. Can anyone please tell me a faster way to transfer these files to the database? or maybe another software that can get the job done. Thanks. — Preceding unsigned comment added by Kclalwani (talkcontribs) 15:33, 8 October 2013 (UTC)[reply]

This is a place for ultra simple code requests???

edit

Dont know if this is a place to it. But I was wanting a simple code that do that: PSEUDO CODE

1-create 2 empty lists. List 1 and 2

2-Request the user to post some text, any text.

3-Add the word start as the first value of of list 1, then get first chacater (space considered on character) of text user wrote and add as value 2 , second character (if exist) is added as value 3, third as value 4......, after all this the program add the word final as the last value of the list.

3-The program then get a random value of this list. And add to a string variable (not list). Lets say letter X.

4-Program get the first character of variable it created on step 3. (if the variable is 'start' it skip this step). Now it check list 1, everytime it find this value on the list (case sensitive) it check the previous character and add to list 2. Then it select a random value of the list 2 and put it as the first character of variable created on step 3.

5-Clear list 2.

6-Do the same as step 5 but using last character of variable of step 3 (if variable is 'final' it skip this step), and add the character to the end of step 3 variable instead of begining.

7-Clear list 2.

8-Go back to step 4 until the firt character of step 3 variable is 'start' and then go to step 9

9-Go back to step 6 until the last character of step 3 variable is 'last' and then go to step 10.

10-Program show variable of step 3 — Preceding unsigned comment added by 201.78.195.197 (talk) 20:28, 8 October 2013 (UTC)[reply]

Sounds like homework. What efforts have you made so far to tackle the problem? Sebastian Garth (talk) 21:15, 8 October 2013 (UTC)[reply]
Its not homework, its some idea I had about making music by statistics. There is a website called button beats that allow you to play flash piano player with keyboard, with some specific flash piano version that allow you yo write the text and then it will play this text. On this program the user will write the text (the song), the song will select a random "note" based on how likely you are to find it on the song, and then select how the previous or next "note" will be at random, based on how likely is to some note be after this not (if selecting the next note) or how likely it is to find some specific note before the note (if selecting the previous note), and continue until the first note is the "start song note" and the last note is the "ending song note". This could be made using more than one song as a seed, but this would be too complex for a request. This kind of idea, would be able to make with real music sheets, but again it would be too complex to request it here. Its just some weird idea, I had, and want to see how it would be like, I could do it by hand (and random.org for randomization), in fact I already tried once with a song, but with a program it would be better. — Preceding unsigned comment added by 201.78.209.96 (talk) 14:35, 9 October 2013 (UTC)[reply]
Sounds like you're trying to describe Markov chain#Music. Katie R (talk) 17:30, 9 October 2013 (UTC)[reply]
First of all you need to make your explanation of the algorithm much, much clearer. I really couldn't make any sense of what the program was meant to achieve with the two lists, what data was stored in the lists, what the intermediate variable (the 'step 3 variable') would contain at any point in the program, the purpose of repeatedly clearing list 2, and so on. Very confusing indeed. Astronaut (talk) 15:59, 9 October 2013 (UTC)[reply]
How it works with a example:
The user write a text lets say: kKollm
The program get the first list and add start as it first value, then add the first character of the word player wrote as second value of the list, the second character of the list as the third value and this goes on, then it add the word end as the last value of the list.
The list 1 will be like this | start | k | K | o | l | l | m | end |
The program now get a random value (got using random.org) from this list and create a variable with this value.
variable_of_final_song = k
Now the program check the first value of this variable (k), if this value is start, it does nothing. If not check the list, when it find this first value (here is k) on this list, it check the previous value and add to list 2. Variable k only happen once on the list (remember that it is case sensitive) and before it its variable start.
The list 2 will be like this: | start |
Now the program get a random value from this list (in this case there is only one) and add t the variable_of_final_song at the beginning of it.
This variable becomes variable_of_final_song = startk
Then it get the last value of this variable (k) and check the list 1.
But before doing it, it will need to make the list 2 empty to use it.
Now each time it find the last character of variable_of_final_song on the list 1, it check the next character of this list and add it to list 2. On this example you can only find the value k only on the list 1 and after it there is the value K.
List 2 will now be | K |
The program now get a random value of this list 2 (only K is possible on this example) and add it to the end of the variable_of_final_song.
This variable becomes variable_of_final_song = startkK.
The program continue doing that, it will coninue doing the part where it add something to the beginning of variable variable_of_final_song until the beginning of the variable is start (a thing that already happened on this examle), and continue doing that kind of thing with final part of the variable until the end of the variable variable_of_final_song is end.
201.78.209.96 (talk) 18:29, 9 October 2013 (UTC)[reply]
Using emacs you can almost do this (assuming I'm understanding it right) using dissociated press. Enter the string into the editor, then run M-x dissociated-press with an argument of 1. You can't tell it where to start unfortunately, but running it repeatedly you should end up getting an example that starts on the right character. It should end the sequence on the last character in your input on it's own. Katie R (talk) 18:48, 9 October 2013 (UTC)[reply]
Note that this is using a Markov chain like I linked above. The Markov chain starts with a seed character, then picks the next one based on how likely each possible next character was in the input string. It doesn't build from the middle like yours - you can just start with a specific letter and let it build until it hits your "end" character. If you seed it with your "start" character, then I think it would produce the same results as your method. I'm sure there are online Markov chain tools that you can play with, but I can't do much searching for those sorts of things while on my work internet. Katie R (talk) 18:56, 9 October 2013 (UTC)[reply]
Yes, i saw the markov chain and decided to research about it. And found some codes and text generators. They are very similar but not 100% equal with my idea, some will check entire words, or more than one string (but I found generators that work with just one string like my example), some arent case sensitive, on some generators I found on the word 'xsav' as some example, when trying to generate a string after the string s both x and a would have a chance of happening and not only a, on some the last letter is adjacent to the first one, and the biggest change there is no end and start characters and so the generators usually stop generatin the word after they generate some x amount of strings.201.78.209.96 (talk) 20:16, 9 October 2013 (UTC)[reply]

sort 10 million lines

edit

Hello, I have a file with 10 million lines, each having 100 bytes of ASCII text. I want to have it sorted so that the lines are in lexicographical order after the 8th character of the line. This is on a Linux system with C compiler. Are there faster alternatives than Unix sort suitable for this situation? --SCIdude (talk) 20:52, 8 October 2013 (UTC)[reply]

You are talking about 1 GB of data. If you have a reasonably modern machine, UNIX sort should be able to do it completely in RAM. You could do a custom implementation (especially if your lines are guaranteed to be at most 100 bytes, it's straightforward to use qsort() and strcmp()) in C, probably with slightly less overhead than UNIX sort. Or your could build a trie and write it out in-order. But UNIX sort should be good enough unless you have a particular case in mind (e.g. if the data is mostly pre-sorted). --Stephan Schulz (talk) 21:06, 8 October 2013 (UTC)[reply]
Just for fun, I sorted a 33 million line file (about 3GB) using sort on a Linux system on a 5 year old workstation. Running time was 57 seconds. Just catting the file to a new file took 10 seconds. Thus unless this process needs to be done many times, sort is pretty fast and custom solution may not be worth your time. You may be able to do this a bit faster because you don't have to search for line endings, etc., but unless there is some special structure in the data to take advantage of, I would be surprised if you could get more than a factor of 2 speedup over the standard sort. --Mark viking (talk) 21:34, 8 October 2013 (UTC)[reply]