ref #9014 handle Pt|Sect|Abt with number as title, not series part
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 27 Apr 2023 10:23:23 +0000 (12:23 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 27 Apr 2023 10:24:16 +0000 (12:24 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImpl.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplRegExBase.java
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplTest.java

index af350a1a8d349700e117cef4d3d8a3a577418391..aeba77378fdfd23af4db98351c24a79a257005bc 100644 (file)
@@ -799,6 +799,10 @@ public class NonViralNameParserImpl
                Reference result = ReferenceFactory.newArticle();
                reference = makeVolumeAndSeries(result, reference);
                Reference inJournal = ReferenceFactory.newJournal();
+               if (isNotBlank(result.getSeriesPart()) && result.getSeriesPart().matches(notReallySeriesPart)) {
+                   reference += ", " + result.getSeriesPart();
+                   result.setSeriesPart(null);
+               }
                inJournal.setAbbrevTitle(reference);
                result.setInReference(inJournal);
                return result;
index dcab88321b0c89a6c92ca117cf27a1660b6f3978..431fc542d2373b515ce2a536d2cfadc5e988612a 100644 (file)
@@ -192,7 +192,8 @@ public abstract class NonViralNameParserImplRegExBase  {
 
     protected static int authorSeparatorMaxPosition = 3;  //author may have a maximum of 2 words
     protected static String pTitleWordSeparator = "(\\."+ fWs+"|" + oWs + "|\\.?[-\u2013]"+oWs+"|\\.?" + oWs + "&(?!\\s*al\\.)" + oWs + ")";
-    protected static String pSeriesPart = fWs + ",?" + fWs + "(([sS][e\u00E9]r|сер)("+oWs+"|\\."+fWs+")(\\d{1,2}|[A-Z](\\s*\\d{1,2})?)|n(ov)?\\.\\s*[sS](er)?\\.|Jerusalem Ser\\.|(Pt|Sect)\\.\\s*\\d{1,2}),?";  //Pt. (Part) and Sect. (Section) currently handled as series part, which is part of title, may be handled different later
+    protected static String notReallySeriesPart = "(Pt|Sect|Abt)\\.\\s*\\d{1,2}";//Pt. (Part) and Sect. (Section) and Abt. currently handled as series part, which is part of title, may be handled different later
+    protected static String pSeriesPart = fWs + ",?" + fWs + "(([sS][e\u00E9]r|сер)("+oWs+"|\\."+fWs+")(\\d{1,2}|[A-Z](\\s*\\d{1,2})?)|n(ov)?\\.\\s*[sS](er)?\\.|Jerusalem Ser\\.|" + notReallySeriesPart +"),?";
 
     protected static String authorPrefix = "(Da(lla)?|Van|La|De)" + oWs; //should not include words allowed in first part of reference title
     protected static String firstTitleWord = "(?!"+authorPrefix+")" + word + "('\\p{javaLowerCase}*|\\.?[-\u2013]"+dotWord+")?"; //word with optional apostrophe in between
index c4b87d7321ba1509df98e1b09319ae642213c284..901156a71e4ed949fdf5c122d023172790f4d663 100644 (file)
@@ -2222,6 +2222,21 @@ public class NonViralNameParserImplTest extends TermTestBase {
 
         matcher = seriesPattern.matcher("nov. Ser.");
         Assert.assertTrue("", matcher.matches());
+
+        //not really series  "Abt. 2"
+        String nameStr = "Hydrogonium consanguineum Hilp. in Beih. Bot. Centralbl., Abt. 2, 50(3): 626. 1933";
+        TaxonName name = parser.parseReferencedName(nameStr);
+        Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
+        Reference ref = name.getNomenclaturalReference();
+        Assert.assertEquals(ReferenceType.Article, ref.getType());
+        Reference inRef = ref.getInReference();
+        //TODO handling of Abt. not fully correct, should better go into title
+        Assert.assertEquals("Beih. Bot. Centralbl., Abt. 2", inRef.getAbbrevTitle());
+        Assert.assertEquals(null, ref.getSeriesPart());
+        Assert.assertEquals("50(3)", ref.getVolume());
+        Assert.assertEquals(nameStr, name.getFullTitleCache());
+        String detail = name.getNomenclaturalMicroReference();
+        Assert.assertEquals("626", detail);
     }
 
     @Test
@@ -3349,6 +3364,21 @@ public class NonViralNameParserImplTest extends TermTestBase {
         assertEquals(ReferenceType.BookSection, nomRef.getType());
         assertEquals( "Strid & Kit Tan", nomRef.getInReference().getAuthorship().getNomenclaturalTitleCache());
         assertEquals( "Mount. Fl. Greece", nomRef.getInReference().getAbbrevTitle());
+
+
+        //, Ser. B, Div. 2, Bot.   from E+M mosses import
+        nameStr = "Schistidium subconfertum (Broth.) Deguchi in J. Sci. Hiroshima Univ., Ser. B, Div. 2, Bot. 16: 240. 1979";
+        name = parser.parseReferencedName(nameStr);
+        Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
+        Reference ref = name.getNomenclaturalReference();
+        Assert.assertEquals(ReferenceType.Article, ref.getType());
+        Reference inRef = ref.getInReference();
+        Assert.assertEquals("J. Sci. Hiroshima Univ., Ser. B, Div. 2, Bot.", inRef.getAbbrevTitle());
+        Assert.assertEquals(null, ref.getSeriesPart());
+        Assert.assertEquals("60", ref.getVolume());
+        Assert.assertEquals(nameStr, name.getFullTitleCache());
+        String detail = name.getNomenclaturalMicroReference();
+        Assert.assertEquals("240", detail);
     }
 
     //this is a slot for testing new string, once the Strings tested here work move the according test