Commits

petermr  committed 1dc3280

removed some null pointers

  • Participants
  • Parent commits 1ced4cc

Comments (0)

Files changed (10)

File src/main/java/org/xmlcml/xhtml2stm/visitor/regex/RegexResults.java

 	}
 
 	protected Map<RegexComponent, Integer> getCountMap() {
+		ensureCountMap();
 		return countMap;
 	}
 

File src/main/java/org/xmlcml/xhtml2stm/visitor/regex/RegexVisitor.java

 		ensureTotalCountMap();
 		for (RegexComponent regexComponent : totalCountMap.keySet()) {
 			Integer count = totalCountMap.get(regexComponent);
-			LOG.trace(regexComponent.getPattern()+": "+count);
+			LOG.debug(regexComponent.getPattern()+": "+count);
 		}
 	}
 
 			//regexResults.debug();
 			Map<RegexComponent, Integer> countMap = regexResults.getCountMap();
 			ensureTotalCountMap();
+			LOG.debug("Hits: "+countMap.keySet().size());
 			for (RegexComponent regexComponent : countMap.keySet()) {
 				recordResults(countMap, regexComponent);
 			}

File src/test/java/org/xmlcml/xhtml2stm/visitor/regex/RegexVisitorTest.java

 	}
 
 	@Test
-	@Ignore // use filenames
+//	@Ignore // use filenames
 	public void testCommandRegex() throws Exception {
 
 		String[] args = new String[] {
 				"-i", Fixtures.MULTIPLE_312_HTML.toString(),
-				"-o", new File(Fixtures.AMI_OUT, "/multiple1.xml").toString(),
+				"-o", new File(Fixtures.AMI_OUT, "multiple1.xml").toString(),
 				"-g", "regex/pdb.xml", "regex/phylotree.xml",
 		};
 		RegexVisitor.main(args);

File src/test/java/org/xmlcml/xhtml2stm/visitor/species/SpeciesVisitorTest.java

 import java.io.File;
 import java.io.FileOutputStream;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Ignore;
 	@Test
 	public void testCommandlineHtmlFile() throws Exception {
 		String[] args = new String[] {
+				"-d",
 				"-i", Fixtures.MULTIPLE_SPECIES_312_HTML.toString(),
 				"-o", Fixtures.AMI_OUT.toString()+"/",
 		};
 		SpeciesVisitor.main(args);
+		LOG.debug(Fixtures.AMI_OUT.toString());
+		Assert.assertTrue(Fixtures.AMI_OUT.exists());
+		Assert.assertTrue(Fixtures.AMI_OUT.toString(), FileUtils.sizeOf(Fixtures.AMI_OUT) > 100);
+		Assert.assertTrue(new File("target/multiple.species.312.xml").exists());		
 	}
 
 	@Test

File src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.11.svg.molecule0.cml

 <?xml version="1.0" encoding="UTF-8"?>
-<molecule x2="283.5132076988977" y2="531.7425000000001" xmlns="http://www.xml-cml.org/schema"><atomArray><atom id="a7" elementType="C" x2="29.244" y2="-52.884" hydrogenCount="2"/><atom id="a8" elementType="C" x2="27.128" y2="-52.887" hydrogenCount="0"/><atom id="a11" elementType="C" x2="28.189" y2="-52.25" hydrogenCount="2"/><atom id="a12" elementType="O" x2="27.106" y2="-54.092" hydrogenCount="0"/><atom id="a7_h1" elementType="H" x2="30.244" y2="-51.884"/><atom id="a7_h2" elementType="H" x2="30.244" y2="-51.884"/><atom id="a11_h1" elementType="H" x2="29.189" y2="-51.25"/><atom id="a11_h2" elementType="H" x2="29.189" y2="-51.25"/><atom id="a2" elementType="N" x2="30.28" y2="-52.256"/><atom id="a3" elementType="O" x2="31.28" y2="-51.256"/><atom id="a4" elementType="O" x2="31.28" y2="-51.256"/><atom elementType="O" x2="26.056" y2="-52.262" id="a5"/><atom elementType="H" x2="27.056" y2="-51.262" id="a6"/></atomArray><bondArray><bond atomRefs2="a8 a12" order="D" id="a8_a12"/><bond atomRefs2="a11 a7" order="S" id="a11_a7"/><bond atomRefs2="a8 a11" order="S" id="a8_a11"/><bond atomRefs2="a7 a7_h1" id="a7_a7_h1" order="S"/><bond atomRefs2="a7 a7_h2" id="a7_a7_h2" order="S"/><bond atomRefs2="a11 a11_h1" id="a11_a11_h1" order="S"/><bond atomRefs2="a11 a11_h2" id="a11_a11_h2" order="S"/><bond atomRefs2="a2 a3" order="S" id="a2_a3"/><bond atomRefs2="a2 a4" order="S" id="a2_a4"/><bond atomRefs2="a7 a2" order="S" id="a7_a2"/><bond order="S" atomRefs2="a5 a6" id="a5_a6"/><bond atomRefs2="a8 a5" order="S" id="a8_a5"/></bondArray><name>/Users/pm286/workspace/xhtml2stm-dev/src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.11.svg</name></molecule>
+<molecule x2="283.5132076988977" y2="531.7425000000001" xmlns="http://www.xml-cml.org/schema"><atomArray><atom id="a8" elementType="C" x2="28.167" y2="-52.263" hydrogenCount="2"/><atom id="a9" elementType="C" x2="29.223" y2="-52.872" hydrogenCount="2"/><atom id="a11" elementType="O" x2="27.106" y2="-54.092" hydrogenCount="0"/><atom id="a12" elementType="C" x2="27.108" y2="-52.875" hydrogenCount="0"/><atom id="a8_h1" elementType="H" x2="29.167" y2="-51.263"/><atom id="a8_h2" elementType="H" x2="29.167" y2="-51.263"/><atom id="a9_h1" elementType="H" x2="30.223" y2="-51.872"/><atom id="a9_h2" elementType="H" x2="30.223" y2="-51.872"/><atom id="a2" elementType="O" x2="26.056" y2="-52.262"/><atom id="a3" elementType="H" x2="27.056" y2="-51.262"/><atom elementType="N" x2="30.28" y2="-52.256" id="a5"/><atom elementType="O" x2="31.28" y2="-51.256" id="a6"/><atom id="a4" elementType="O" x2="31.28" y2="-51.256"/></atomArray><bondArray><bond atomRefs2="a12 a11" order="D" id="a12_a11"/><bond atomRefs2="a12 a8" order="S" id="a12_a8"/><bond atomRefs2="a8 a9" order="S" id="a8_a9"/><bond atomRefs2="a8 a8_h1" id="a8_a8_h1" order="S"/><bond atomRefs2="a8 a8_h2" id="a8_a8_h2" order="S"/><bond atomRefs2="a9 a9_h1" id="a9_a9_h1" order="S"/><bond atomRefs2="a9 a9_h2" id="a9_a9_h2" order="S"/><bond atomRefs2="a2 a3" order="S" id="a2_a3"/><bond atomRefs2="a12 a2" order="S" id="a12_a2"/><bond order="D" atomRefs2="a5 a6" id="a5_a6"/><bond order="D" atomRefs2="a5 a4" id="a5_a4"/><bond atomRefs2="a9 a5" order="S" id="a9_a5"/></bondArray><name>C:\Users\pm286\workspace1\xhtml2stm-dev\src\test\resources\org\xmlcml\xhtml2stm\molecules\image.g.2.11.svg</name></molecule>

File src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.11.svg.molecule0.png

Old
Old image
New
New image

File src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.11.svg.molecule0.svg

Old
Old image
New
New image

File src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.13.svg.molecule0.cml

 <?xml version="1.0" encoding="UTF-8"?>
-<molecule x2="421.89788" y2="531.7425000000001" xmlns="http://www.xml-cml.org/schema"><atomArray><atom id="a11" elementType="C" x2="40.62" y2="-53.19" hydrogenCount="0"/><atom id="a12" elementType="C" x2="42.743" y2="-53.191" hydrogenCount="1"/><atom id="a13" elementType="C" x2="41.641" y2="-52.553" hydrogenCount="0"/><atom id="a14" elementType="C" x2="43.799" y2="-55.027" hydrogenCount="2"/><atom id="a16" elementType="C" x2="40.578" y2="-54.39" hydrogenCount="1"/><atom id="a18" elementType="O" x2="41.656" y2="-55.01" hydrogenCount="0"/><atom id="a19" elementType="C" x2="42.697" y2="-54.389" hydrogenCount="0"/><atom id="a20" elementType="O" x2="41.656" y2="-51.338" hydrogenCount="0"/><atom id="a12_h1" elementType="H" x2="43.743" y2="-52.191"/><atom id="a14_h1" elementType="H" x2="44.799" y2="-54.027"/><atom id="a14_h2" elementType="H" x2="44.799" y2="-54.027"/><atom id="a16_h1" elementType="H" x2="41.578" y2="-53.39"/><atom id="a2" elementType="O" x2="39.55" y2="-52.562"/><atom id="a3" elementType="H" x2="40.55" y2="-51.562"/><atom elementType="O" x2="44.83" y2="-54.398" id="a4"/><atom elementType="H" x2="45.83" y2="-53.398" id="a5"/></atomArray><bondArray><bond atomRefs2="a18 a19" order="S" id="a18_a19"/><bond atomRefs2="a16 a18" order="S" id="a16_a18"/><bond atomRefs2="a12 a19" order="D" id="a12_a19"/><bond atomRefs2="a12 a13" order="S" id="a12_a13"/><bond atomRefs2="a19 a14" order="S" id="a19_a14"/><bond atomRefs2="a20 a13" order="D" id="a20_a13"/><bond atomRefs2="a11 a16" order="D" id="a11_a16"/><bond atomRefs2="a13 a11" order="S" id="a13_a11"/><bond atomRefs2="a12 a12_h1" id="a12_a12_h1" order="S"/><bond atomRefs2="a14 a14_h1" id="a14_a14_h1" order="S"/><bond atomRefs2="a14 a14_h2" id="a14_a14_h2" order="S"/><bond atomRefs2="a16 a16_h1" id="a16_a16_h1" order="S"/><bond atomRefs2="a2 a3" order="S" id="a2_a3"/><bond atomRefs2="a11 a2" order="S" id="a11_a2"/><bond order="S" atomRefs2="a4 a5" id="a4_a5"/><bond atomRefs2="a14 a4" order="S" id="a14_a4"/></bondArray><name>/Users/pm286/workspace/xhtml2stm-dev/src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.13.svg</name></molecule>
+<molecule x2="421.89788" y2="531.7425000000001" xmlns="http://www.xml-cml.org/schema"><atomArray><atom id="a11" elementType="C" x2="42.72" y2="-53.178" hydrogenCount="1"/><atom id="a12" elementType="C" x2="41.658" y2="-52.563" hydrogenCount="0"/><atom id="a14" elementType="O" x2="41.656" y2="-55.01" hydrogenCount="0"/><atom id="a15" elementType="O" x2="41.656" y2="-51.338" hydrogenCount="0"/><atom id="a16" elementType="C" x2="43.776" y2="-55.014" hydrogenCount="2"/><atom id="a17" elementType="C" x2="40.599" y2="-54.402" hydrogenCount="1"/><atom id="a19" elementType="C" x2="42.72" y2="-54.402" hydrogenCount="0"/><atom id="a20" elementType="C" x2="40.599" y2="-53.178" hydrogenCount="0"/><atom id="a11_h1" elementType="H" x2="43.72" y2="-52.178"/><atom id="a16_h1" elementType="H" x2="44.776" y2="-54.014"/><atom id="a16_h2" elementType="H" x2="44.776" y2="-54.014"/><atom id="a17_h1" elementType="H" x2="41.599" y2="-53.402"/><atom id="a2" elementType="O" x2="39.55" y2="-52.562"/><atom id="a3" elementType="H" x2="40.55" y2="-51.562"/><atom elementType="O" x2="44.83" y2="-54.398" id="a4"/><atom elementType="H" x2="45.83" y2="-53.398" id="a5"/></atomArray><bondArray><bond atomRefs2="a14 a19" order="S" id="a14_a19"/><bond atomRefs2="a12 a20" order="S" id="a12_a20"/><bond atomRefs2="a20 a17" order="D" id="a20_a17"/><bond atomRefs2="a19 a16" order="S" id="a19_a16"/><bond atomRefs2="a11 a19" order="D" id="a11_a19"/><bond atomRefs2="a11 a12" order="S" id="a11_a12"/><bond atomRefs2="a15 a12" order="D" id="a15_a12"/><bond atomRefs2="a17 a14" order="S" id="a17_a14"/><bond atomRefs2="a11 a11_h1" id="a11_a11_h1" order="S"/><bond atomRefs2="a16 a16_h1" id="a16_a16_h1" order="S"/><bond atomRefs2="a16 a16_h2" id="a16_a16_h2" order="S"/><bond atomRefs2="a17 a17_h1" id="a17_a17_h1" order="S"/><bond atomRefs2="a2 a3" order="S" id="a2_a3"/><bond atomRefs2="a20 a2" order="S" id="a20_a2"/><bond order="S" atomRefs2="a4 a5" id="a4_a5"/><bond atomRefs2="a16 a4" order="S" id="a16_a4"/></bondArray><name>C:\Users\pm286\workspace1\xhtml2stm-dev\src\test\resources\org\xmlcml\xhtml2stm\molecules\image.g.2.13.svg</name></molecule>

File src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.13.svg.molecule0.png

Old
Old image
New
New image

File src/test/resources/org/xmlcml/xhtml2stm/molecules/image.g.2.13.svg.molecule0.svg

Old
Old image
New
New image