Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 03-15-2011, 04:25 PM   #1
jribeiro
Member
jribeiro began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Dec 2009
Location: Belo Horizonte, Brazil
Device: Kindle 3 WiFi
Convert Text Dictionary to Mobi

I have a dictionary in text format that I would like to convert to mobi format. I am trying to convert it to the "keyword-tab-definition" format which I can translate into mobi using tab2opf. Unfortunately I don't know any tool able to make the conversion nor I have enough programming skills.

The dictionary looks like:

word1
definition 1
definition 2
definition 3

word2
definition

word3
definition 1
definition 2

Any hints (Linux or Windows)?.

Thanks.
jribeiro is offline   Reply With Quote
Old 03-15-2011, 06:16 PM   #2
janvanmaar
Addict
janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.
 
Posts: 215
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
For a very basic conversion, you can use something like this:
Code:
#!/usr/bin/python
# coding: utf-8
inp='yourfile.txt'
out='outfile.txt'
new_entry=1
with open(inp) as f:
  with open(out,'w') as g:
    for line in f:
      line=line.strip()
      if new_entry:
        line+='\t'
        new_entry=0
      elif not line:
        new_entry=1 
        line='\n'
      else:
        line='<BLOCKQUOTE>'+line+'</BLOCKQUOTE>'
      g.write(line)
Just paste it exactly as it is to an empty file, modify 'yourfile.txt' to the name of your input file and save it as 'script.py' in the same directory where your input file is. Under Linux you can run it by 'python script.py' and you should have your tab delimited file.
janvanmaar is offline   Reply With Quote
 
Enthusiast
Old 03-19-2011, 09:58 AM   #3
jribeiro
Member
jribeiro began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Dec 2009
Location: Belo Horizonte, Brazil
Device: Kindle 3 WiFi
Thanks, janvanmaar.

I converted file using your script. Tried to convert output file to opf using tab2opf and got error message:

File "Download/tab2opf.py", line 243, in <module>
dd = normalizeUnicode(dd,'cp1252')
File "Download/tab2opf.py", line 103, in normalizeUnicode
text = unicode(text, 'utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe1 in position 317: invalid continuation byte
jribeiro is offline   Reply With Quote
Old 03-19-2011, 01:18 PM   #4
janvanmaar
Addict
janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.
 
Posts: 215
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
Your original file was probably not utf. Convert it to utf first and then repeat the conversion to tab-delimited file and mobigen building.
janvanmaar is offline   Reply With Quote
Reply

Tags
dictionary, mobi, text

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mobi dictionary lookup 1mikemoroz Kindle Formats 8 03-21-2011 05:29 AM
Convert eReader Dictionary to MOBI? notyou Other formats 2 06-29-2010 01:37 AM
Convert zip with multiple text files to MOBI mindfire Calibre 1 03-27-2010 10:19 AM
Mobi Dictionary alterego Kindle Formats 0 10-30-2009 01:30 AM
will Mobi dictionary work in oi legin OpenInkpot 2 07-30-2009 02:07 PM


All times are GMT -4. The time now is 12:29 PM.


MobileRead.com is a privately owned, operated and funded community.