![]() |
#1 |
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?
|
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() Isn't "Imperial" limited to liquid (volume) measure ? |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
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... |
![]() |
![]() |
![]() |
#4 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() 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] |
|
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
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. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Junior Member
![]() Posts: 4
Karma: 10
Join Date: Jan 2012
Device: cybook opus
|
Quote:
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... |
|
![]() |
![]() |
![]() |
#7 |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,544
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
|
![]() |
![]() |
![]() |
#8 |
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! |
![]() |
![]() |
![]() |
#9 |
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.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unit DIED !! | sirmaru | Kindle Fire | 48 | 12-25-2011 02:37 PM |
New Unit | Dallasjam | Introduce Yourself | 7 | 03-24-2010 08:12 PM |
Demo Unit | kielus | Sony Reader | 14 | 02-19-2009 10:45 PM |
Another defective unit | smp_iliad | iRex | 13 | 11-21-2008 07:15 AM |
Another damaged unit? | wataru | iRex | 2 | 11-09-2008 09:25 AM |