<< | Index | >>
Confirm the current status
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_doc_parser.rb Loaded suite test_fachinfo_doc_parser Started ...........FFFFFF......FFFFFF.E..F.. >------------------------------------------------------------------------ Disktest (10 �g< >------------------------------------------------------------------------ Disktest (10 µ< ................................................. Finished in 14.920982 seconds. 1) Failure: test_composition10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1038]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 2) Failure: test_galenic_form10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1051]: <"Galenische Form und Wirkstoffmengen pro Einheit"> expected but was <"Tropfen. 1 ml enth\303\244lt: 25 mg Hamameliswasser, 5 mg Augentrosttinktur, 0,9 mg Dexpanthenol.">. 3) Failure: test_iksnrs10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1069]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 4) Failure: test_indications10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1062]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 5) Failure: test_name10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1033]: <"Tendro, Augentropfen\n"> expected but was <"Tendro, Augentropfen\n\t\t\t\t\t\t\t\t\t\tTentan AG\n">. 6) Failure: test_registration_owner10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1079]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 7) Failure: test_composition12(TestFachinfoDocParser12) [test_fachinfo_doc_parser.rb:1182]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 8) Failure: test_galenic_form12(TestFachinfoDocParser12) [test_fachinfo_doc_parser.rb:1195]: <"Forme gal\351nique et quantit\351 de principe actif par unit\351"> expected but was <"a Principe actif : extrait de millepertuis (Hyperici herba extractum).">. 9) Failure: test_iksnrs12(TestFachinfoDocParser12) [test_fachinfo_doc_parser.rb:1213]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 10) Failure: test_indications12(TestFachinfoDocParser12) [test_fachinfo_doc_parser.rb:1206]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 11) Failure: test_name12(TestFachinfoDocParser12) [test_fachinfo_doc_parser.rb:1177]: <"Yakona-Hypericum\n"> expected but was <"Yakona-Hypericum\n\t\t\t\t\t\t\t\t\t\tTentan AG\n">. 12) Failure: test_registration_owner12(TestFachinfoDocParser12) [test_fachinfo_doc_parser.rb:1223]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 13) Error: test_date13(TestFachinfoDocParser13): NoMethodError: undefined method `text' for nil:NilClass test_fachinfo_doc_parser.rb:1299:in `test_date13' 14) Failure: test_name13(TestFachinfoDocParser13) [test_fachinfo_doc_parser.rb:1247]: <1> expected but was <2>. 85 tests, 360 assertions, 13 failures, 1 errors
Note
Next
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_doc_parser.rb Loaded suite test_fachinfo_doc_parser Started FFFFFF Finished in 0.060513 seconds. 1) Failure: test_composition10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1042]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 2) Failure: test_galenic_form10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1055]: <"Galenische Form und Wirkstoffmengen pro Einheit"> expected but was <"Tropfen. 1 ml enth\303\244lt: 25 mg Hamameliswasser, 5 mg Augentrosttinktur, 0,9 mg Dexpanthenol.">. 3) Failure: test_iksnrs10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1073]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 4) Failure: test_indications10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1066]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 5) Failure: test_name10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1037]: <"Tendro, Augentropfen\n"> expected but was <"Tendro, Augentropfen\n\t\t\t\t\t\t\t\t\t\tTentan AG\n">. 6) Failure: test_registration_owner10(TestFachinfoDocParser10) [test_fachinfo_doc_parser.rb:1083]: <nil> expected to be an instance of <ODDB::Text::Chapter> but was <NilClass>. 6 tests, 8 assertions, 6 failures, 0 errors
Memo
Confirm the class (data) structure of rwv2
test.rb
require 'rwv2' require 'rwv2/handlers' class TextHandler < Rwv2::TextHandler def run_of_text(text, character_properties) # puts text end def section_start(section_properties) p "section_start" end def section_end p "section_end" end def page_break p "page_break" end def paragraph_start(paragraph_properties) p "paragraph_start" end def paragraph_end p "paragraph_end" end end parser = Rwv2.create_parser('test.doc') parser.set_text_handler(TextHandler.new) parser.parse
Result
masa@masa ~/work $ ruby test.rb "section_start" "paragraph_start" "paragraph_end" "paragraph_start" "paragraph_end" ... "paragraph_start" "paragraph_end" "section_end"
Note
Experiment
test.rb
require 'rwv2' require 'rwv2/handlers' class TextHandler < Rwv2::TextHandler def run_of_text(text, character_properties) puts text end def section_start(section_properties) p "section_start" end def section_end p "section_end" end def page_break p "page_break" end def paragraph_start(paragraph_properties) p "paragraph_start" end def paragraph_end p "paragraph_end" end end parser = Rwv2.create_parser('test.doc') parser.set_text_handler(TextHandler.new) parser.parse
Result
masa@masa ~/work $ ruby test.rb "section_start" "paragraph_start" Fachinformation Tendro, Augentropfen "paragraph_end" "paragraph_start" 1 7.September 2007 Seite PAGE 2 von NUMPAGES \*Arabic 2 "paragraph_end" "paragraph_start" Tendro, Augentropfen "paragraph_end" "paragraph_start" "paragraph_end" "paragraph_start" Tentan AG "paragraph_end" "paragraph_start" "paragraph_end" "paragraph_start" "paragraph_end" "paragraph_start" Zusammensetzung "paragraph_end" "paragraph_start" a Wirkstoffe: Hamameliswasser, Augentrosttinktur, Dexpanthenol "paragraph_end" "paragraph_start" b. Hilfsstoff: Konservierungsmittel: Phenylquecksilberborat , sowie weitere "paragraph_end" "paragraph_start" Hilfsstoffe. "paragraph_end" "paragraph_start" "paragraph_end" "paragraph_start" Galenische Form und Wirkstoffmengen pro Einheit "paragraph_end" ...
Note
Consideration
Indikationen/Anwendungsmöglichkeiten Augentropfen bei leichten Reizungen der Augen (Brennen), zur Befeuchtung der Augen bei Müdigkeits- und Trockenheitsgefühl.
ext/fiparse/fiparse.rb#parse_fachinfo_doc
def parse_fachinfo_doc(src) parser = Rwv2.create_parser_from_content(src) handler = FachinfoTextHandler.new parser.set_text_handler(handler) parser.set_table_handler(handler.table_handler) parser.parse if(handler.writers.empty?) ## Product-Name was not written large enough - retry with whatever was # the largest fontsize handler.cutoff_fontsize = handler.max_fontsize parser.parse end handler.writers.collect { |wt| wt.to_fachinfo }.compact.first end
Note
Memo
test_*10, test_*11, test_*12, test_*13 all passed
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_doc_parser.rb Loaded suite test_fachinfo_doc_parser Started ..................................................................................... Finished in 15.136881 seconds. 85 tests, 394 assertions, 0 failures, 0 errors
Next (The last error of test_fachinfo_doc.rb)
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_doc_parser.rb Loaded suite test_fachinfo_doc_parser Started test_fachinfo_doc_parser.rb:982: [BUG] Segmentation fault ruby 1.8.6 (2009-06-08) [x86_64-linux] Abgebrochen
Check
Experiment
Result
Next
Experiment
ext/fiparse/src/fachinfo_doc.rb#new_font
elsif(!@in_table) # remove ' symbol of swissmedic number if text =~ /\(Swissmedic\)/ text.gsub!(/(\d+).*?(\d+)/,'\1\2') end
Note
ext(fiparse/test/test_fachinfo_doc.rb#test_isknrs10
def test_iksnrs10
writer = @text_handler.writers.first
chapter = writer.iksnrs
assert_instance_of(ODDB::Text::Chapter, chapter)
assert_equal('Zulassungsnummer', chapter.heading)
assert_equal(1, chapter.sections.size)
assert_equal(1, chapter.sections.first.paragraphs.size)
paragraph = chapter.sections.first.paragraphs.first
assert_equal("47831 (Swissmedic)", paragraph.text)
end
Result
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_doc_parser.rb Loaded suite test_fachinfo_doc_parser Started . Finished in 0.011241 seconds. 1 tests, 5 assertions, 0 failures, 0 errors
Check the actual loading on the local oddb system
Check final test (test_fachinfo_doc_parser.rb)
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_doc_parser.rb Loaded suite test_fachinfo_doc_parser Started ........................................................................................ Finished in 15.34317 seconds. 88 tests, 400 assertions, 0 failures, 0 errors
Commit
Check the current status
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ ruby test_fachinfo_hpricot.rb Loaded suite test_fachinfo_hpricot Started F...F.................................... Finished in 1.078624 seconds. 1) Failure: test_chapter(ODDB::FiParse::TestFachinfoHpricot) [test_fachinfo_hpricot.rb:52]: <"1 Brausetablette enth\303\244lt: Carbasalatum calcicum 528\302\240mg corresp. Acidum Acetylsalicylicum 415\302\240mg, Acidum ascorbicum 250\302\240mg."> expected but was <"1 Brausetablette enth\303\244lt: Carbasalatum calcicum 528 mg corresp. Acidum Acetylsalicylicum 415 mg, Acidum ascorbicum 250 mg.">. 2) Failure: test_composition1(ODDB::FiParse::TestFachinfoHpricotAlcaCDe) [test_fachinfo_hpricot.rb:113]: <"1 Brausetablette enth\303\244lt: Carbasalatum calcicum 528\302\240mg corresp. Acidum Acetylsalicylicum 415\302\240mg, Acidum ascorbicum 250\302\240mg."> expected but was <"1 Brausetablette enth\303\244lt: Carbasalatum calcicum 528 mg corresp. Acidum Acetylsalicylicum 415 mg, Acidum ascorbicum 250 mg.">. 41 tests, 100 assertions, 2 failures, 0 errors
Note
Commit
Check coverage of fiparse
masa@masa ~/ywesee/oddb.org/ext/fiparse/test $ rcov suite.rb -t
Loaded suite /usr/bin/rcov
Started
..............................................................................................................................................................
Finished in 20.883724 seconds.
158 tests, 680 assertions, 0 failures, 0 errors
65.6%
46 file(s) 11072 Lines 9630 LOC
Memo
Commit