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

 01-17-2012, 08:11 PM #1 soma Junior Member   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?
01-17-2012, 08:29 PM   #2
theducks
Cat Bathmat

Posts: 18,017
Karma: 14927894
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
Quote:
 Originally Posted by soma 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 ?

 01-18-2012, 08:10 AM #3 soma Junior Member   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...
01-18-2012, 11:01 AM   #4
theducks
Cat Bathmat

Posts: 18,017
Karma: 14927894
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
Quote:
 Originally Posted by soma 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]

 01-18-2012, 09:57 PM #5 davidfor Grand Sorcerer   Posts: 8,523 Karma: 11052666 Join Date: Jul 2011 Location: Sydney, Australia Device: Kobo: Touch, Glo, Aura H2O, Glo HD 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.
01-20-2012, 06:45 PM   #6
soma
Junior Member

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...

01-21-2012, 06:08 AM   #7
HarryT
eBook Enthusiast

Posts: 72,676
Karma: 57099984
Join Date: Nov 2006
Location: UK
Device: Kindle Voyage, iPad Mini, iPhone 6, MS Surface Pro, N7
Quote:
 Originally Posted by theducks 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 .

 01-24-2012, 06:21 PM #8 JVerstry Junior Member   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!
 01-27-2012, 05:41 AM #9 soma Junior Member   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.