view · edit · sidebar · attach · print · history

20111108-replace-rockit-oddb_org

<< | Index | >>


  1. Replace Rockit library to normal regular expression
  2. Remove Rockit library
  3. Update testcases

Goal/Estimate/Evaluation
  • Replace rockit library (ODDB::SizeParser) oddb.org / 100% / 100%
  • Revemo all rockit processes / 100% / 100%
Commit

Replace Rockit library to normal regular expression

Task

  • The following fomart should be parsed correctly
    1. "2000-3000 l"
    2. "4000 in 5000 ml"
    3. "10x 250 in 500 ml"
    4. "20 + 30 Set"
    5. "10 Set"
    6. "200 (4 x 50) Tablette(n)"
    7. "5 Fl. à 1000 I.E."
    8. "50 Bolus/Boli" suspend
    9. "10 ampoules 10 ml" suspend
    10. "10 zu 0.6 g" suspend

Reference

Experiment ("4000 in 5000 ml")

Result

masa@masa ~/work $ ruby rockit.rb 
String                   : [addition, multi, count, measure, scale, comform]
"4000 in 5000 ml"        : [0, 1, 4000, [1, nil], [1, nil], nil]
masa@masa ~/work $ ruby parser.rb 
String                   : [addition, multi, count, measure, scale, comform]
"4000 in 5000 ml"        : [0, 1, 4000, [1, "ml"], [1, nil], nil]

Note

  • Part@comform is used to create Part@commercial_form in src/util/oddbapp.rb#create_commercial_forms
  • This should be set correctly

Experiment ("20 + 30 Set")

Result

masa@masa ~/work $ ruby rockit.rb 
String                   : [addition, multi, count, measure, scale, comform]
"5 Set"                  : [0, 1, 5, [1, nil], [1, nil], nil]
"20 + 30 Set"            : [20, 1, 30, [1, nil], [1, nil], "Set"]
masa@masa ~/work $ ruby parser.rb 
String                   : [addition, multi, count, measure, scale, comform]
"5 Set"                  : [0, 1, 5, [1, nil], [1, nil], "Set"]
"20 + 30 Set"            : [20, 1, 30, [1, nil], [1, nil], "Set"]

Experiment ("200 (4 x 50) Tablette(n)")

Result

masa@masa ~/work $ ruby rockit.rb 
String                   : [addition, multi, count, measure, scale, comform]
"200 (4 x 50) Tablette(n)": [0, 1, 200, [1, nil], [1, nil], nil]
masa@masa ~/work $ ruby parser.rb 
String                   : [addition, multi, count, measure, scale, comform]
"200 (4 x 50) Tablette(n)": [0, 1, 200, [1, nil], [1, nil], "Tablette(n)"]

Experiment ("50 Bolus/Boli") suspend

masa@masa ~/work $ ruby rockit.rb 
String                   : [addition, multi, count, measure, scale, comform]
"50 Bolus/Boli"          : [0, 1, 50, [1, nil], [1, nil], nil]
masa@masa ~/work $ ruby parser.rb 
String                   : [addition, multi, count, measure, scale, comform]
"50 Bolus/Boli"          : [0, 1, 50, [1, nil], [1, nil], "Bolus"]

Experiment ("10 ampoules 10 ml") suspend

masa@masa ~/work $ ruby rockit.rb 
String                   : [addition, multi, count, measure, scale, comform]
"10 ampoules 10 ml"      : [0, 1, 10, [1, nil], [1, nil], nil]
masa@masa ~/work $ ruby parser.rb 
String                   : [addition, multi, count, measure, scale, comform]
"10 ampoules 10 ml"      : [0, 1, 10, ["10", "ml"], [1, nil], "ampoules"]

Experiment ("10 zu 0.6 g") suspend

masa@masa ~/work $ ruby rockit2.rb 
String                   : [addition, multi, count, measure, scale, comform]
"10 zu 0.6 g"            : [0, Quanty(1,''), 10, Quanty(1,''), Quanty(1,''), nil]
masa@masa ~/work $ ruby parser2.rb
String                   : [addition, multi, count, measure, scale, comform]
"10 zu 0.6 g"            : [0, Quanty(1,''), 10, Quanty(0.6,'g'), Quanty(1,''), "zu"]

Diff

 $ ruby rockit.rb > dat.rockit
 $ ruby parser.rb > dat.parser
 $ diff -y --suppress-common-lines -W 200 dat.rockit dat.parser > diff.txt

Result

Experiment (translated into Dose)

Result

Note

  • It works on Ruby 1.9.3 too
  • sevral hundreds times faster than rockit
masa@masa ~/work $ ruby193 -I . parser2.rb
String                   : [addition, multi, count, measure, scale, comform]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
"3 Suppositorien"        : [0, Quanty(1,''), 3, Quanty(1,''), Quanty(1,''), "Suppositorien"]
...
masa@masa ~/work $ time ruby parser2.rb 
String                   : [addition, multi, count, measure, scale, comform]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
...

real    0m0.038s
user    0m0.036s
sys     0m0.002s
masa@masa ~/work $ time ruby rockit2.rb 
String                   : [addition, multi, count, measure, scale, comform]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
"9 Suppositorien"        : [0, Quanty(1,''), 9, Quanty(1,''), Quanty(1,''), "Suppositorien"]
...

real    0m13.788s
user    0m13.732s
sys     0m0.003s

Testcases Part class

masa@masa ~/ywesee/oddb.org $ ruby test/test_model/part.rb 
Loaded suite test/test_model/part
Started
.................
Finished in 0.030364 seconds.

17 tests, 17 assertions, 0 failures, 0 errors

Commit

Note

  • The new size parser parses data more correctly than the old parser with rockit, and faster

Remove Rockit library

Commit

Update testcases

Current status

4184 tests, 6589 assertions, 9 failures, 65 errors
view · edit · sidebar · attach · print · history
Page last modified on November 08, 2011, at 04:52 PM