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

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 01-17-2012, 08:11 PM   #1
soma
Junior Member
soma began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2012
Device: cybook opus
unit conversion

I would like to convert all units in an ebook (eg. imperial to metric). Is there an easy way to do this? Programatically it shouldn't be too hard to write some regular expressions, convert the captured text to floating point and do the units conversion, but this is a bit beyond the 'search & replace' feature. If not, what would be the best way to extend calibre to do this?
soma is offline   Reply With Quote
Old 01-17-2012, 08:29 PM   #2
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 15,244
Karma: 6020307
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by soma View Post
I would like to convert all units in an ebook (eg. imperial to metric). Is there an easy way to do this? Programatically it shouldn't be too hard to write some regular expressions, convert the captured text to floating point and do the units conversion, but this is a bit beyond the 'search & replace' feature. If not, what would be the best way to extend calibre to do this?
That is not the kind of conversion that Calibre does

Isn't "Imperial" limited to liquid (volume) measure ?
theducks is offline   Reply With Quote
Old 01-18-2012, 08:10 AM   #3
soma
Junior Member
soma began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2012
Device: cybook opus
eg. I would like to do the following conversions:

'68 degrees Farenheit' > '20C'
'200 pounds' > '90.7kg'
'10 miles' > '16.1km'

Imperial units are like a foreign language to me...
soma is offline   Reply With Quote
Old 01-18-2012, 11:01 AM   #4
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 15,244
Karma: 6020307
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by soma View Post
eg. I would like to do the following conversions:

'68 degrees Farenheit' > '20C'
'200 pounds' > '90.7kg'
'10 miles' > '16.1km'

Imperial units are like a foreign language to me...
Ain't gonna happen. Keep your chart handy

Those type of TRANSLATIONS would be a nightmare.
10 Klicks. 10Km 10 Kilometers

Besides... If I am reading a novel in a European setting, I want native measurements.
[rant]
The USA tried to ease into system SI. Big mistake... Few ever changed.
If it had been done, Cold Turkey back then, we would be in step with the rest of the world today.

[/rant]
theducks is offline   Reply With Quote
Old 01-18-2012, 09:57 PM   #5
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 6,073
Karma: 6108201
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo Touch, Kobo Glo
I have to agree with theducks. I just don't think "And kilometres to go before I sleep" sounds the same.

But, if you want to do some investigation, there is a Firefox plugin that can do some of this. Have a look at http://www.the-converter.co/. Maybe you can convince the author to do the same for ebooks.
davidfor is offline   Reply With Quote
Old 01-20-2012, 06:45 PM   #6
soma
Junior Member
soma began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2012
Device: cybook opus
Quote:
I have to agree with theducks. I just don't think "And kilometres to go before I sleep" sounds the same.
True, there isn't much point if there's no preceding number, and when reading fiction a rough mental conversion is good enough with native units adding to the artistic effect.

The Firefox plugin looks good, but doesn't seem to handle numbers as words (eg. three hundred and twenty five pounds). There are quite a lot of possibilities, but I think it is doable. Just not sure I have enough motivation to do it myself yet...
soma is offline   Reply With Quote
Old 01-21-2012, 06:08 AM   #7
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 65,436
Karma: 43770933
Join Date: Nov 2006
Location: UK
Device: Kindle Voyage, iPad Mini, iPhone 4, MS Surface Pro, N7
Quote:
Originally Posted by theducks View Post
Isn't "Imperial" limited to liquid (volume) measure ?
No. "Imperial" measurements is the British English term for what you call "English" measurements. ie, the "Fred Flintstone" way of measuring things .
HarryT is offline   Reply With Quote
Old 01-24-2012, 06:21 PM   #8
JVerstry
Junior Member
JVerstry began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2012
Device: none
Hi, you will probably have to write your own library for this.

Converting British imperial units is not that complicated, because it is just a matter of multiplying a value by the appropriate number. You can obtain them from http://www.convert-kit.com by entering a couple of values.

For temperatures, it is a bit more tricky. You should take a look at the formulas available at wikipedia (http://en.wikipedia.org/wiki/Convers...of_temperature). Then, you can also verify your implementation of these by entering test values here: http://www.convert-kit.com/temperature.html.

Hope it helps!
JVerstry is offline   Reply With Quote
Old 01-27-2012, 05:41 AM   #9
soma
Junior Member
soma began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2012
Device: cybook opus
Well, I've made a start on writing some python to do this: searching for imperial units and finding the preceding numerals for conversion isn't too hard. Currently I'm looking at converting numbers written as words to floating point. Once I have this working on plain text, I'll look at how to integrate this into Calibre via a plugin for epub conversion.
soma is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unit DIED !! sirmaru Kindle Fire 48 12-25-2011 03:37 PM
New Unit Dallasjam Introduce Yourself 7 03-24-2010 09:12 PM
Demo Unit kielus Sony Reader 14 02-19-2009 11:45 PM
Another defective unit smp_iliad iRex 13 11-21-2008 08:15 AM
Another damaged unit? wataru iRex 2 11-09-2008 10:25 AM


All times are GMT -4. The time now is 02:34 AM.


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