van and von authors (#3373)
authorAndreas Müller <a.mueller@bgbm.org>
Mon, 13 May 2013 16:42:24 +0000 (16:42 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 13 May 2013 16:42:24 +0000 (16:42 +0000)
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 800b98e46a6beb1aa1e2d2b002b79ee08d02d43e..f95623526090ad9b0a5d279b578d27bf0ad7ebe8 100644 (file)
@@ -81,7 +81,7 @@ public abstract class NonViralNameParserImplRegExBase  {
     \r
     \r
     //AuthorString\r
-    protected static String authorPart = "(" + "(d'|D'|L'|'t\\s)?" + capitalDotWord + "('" + nonCapitalDotWord + ")?" + "|da|de(n|l|\\sla)?)" ;\r
+    protected static String authorPart = "(" + "(d'|D'|L'|'t\\s)?" + capitalDotWord + "('" + nonCapitalDotWord + ")?" + "|v[ao]n|da|de(n|l|\\sla)?)" ;\r
     protected static String author = "(" + authorPart + "(" + fWs + "|-)" + ")+" + "(f.|fil.|secundus)?";\r
     protected static String finalTeamSplitter = fWs + "(&)" + fWs;\r
     protected static String notFinalTeamSplitter = "(" + fWs + "," + fWs + "|" + finalTeamSplitter + ")";\r
index 50ab51a378466f67de3688383216ea3cb2758ba0..9ac151fd74e9c28ad5f31ac6b7122077b8b21d06 100644 (file)
@@ -52,6 +52,7 @@ import eu.etaxonomy.cdm.model.reference.ReferenceType;
  */\r
 public class NonViralNameParserImplTest {\r
        private static final NomenclaturalCode ICBN = NomenclaturalCode.ICBN;\r
+       private static final NomenclaturalCode ICZN = NomenclaturalCode.ICZN;\r
 \r
        private static final Logger logger = Logger.getLogger(NonViralNameParserImplTest.class);\r
        \r
@@ -201,19 +202,19 @@ public class NonViralNameParserImplTest {
        @Test\r
        public final void testParseFullNameUnicode() {\r
 \r
-               NonViralName nameAuthor = parser.parseFullName(strNameAbiesAuthor1Unicode, null, Rank.SPECIES());\r
+               NonViralName<?> nameAuthor = parser.parseFullName(strNameAbiesAuthor1Unicode, null, Rank.SPECIES());\r
                assertEquals("Abies", nameAuthor.getGenusOrUninomial());\r
                assertEquals("alba", nameAuthor.getSpecificEpithet());\r
                assertEquals("M\u00FCller", nameAuthor.getCombinationAuthorTeam().getNomenclaturalTitle());\r
                \r
-               NonViralName nameBasionymAuthor = parser.parseFullName(strNameAbiesBasionymAuthor1Unicode, null, Rank.SPECIES());\r
+               NonViralName<?> nameBasionymAuthor = parser.parseFullName(strNameAbiesBasionymAuthor1Unicode, null, Rank.SPECIES());\r
                assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());\r
                assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());\r
                assertEquals("D'M\u00FCller", nameBasionymAuthor.getCombinationAuthorTeam().getNomenclaturalTitle());\r
                INomenclaturalAuthor basionymTeam = nameBasionymAuthor.getBasionymAuthorTeam();\r
                assertEquals("Ciardelli", basionymTeam.getNomenclaturalTitle());\r
                \r
-               NonViralName nameBasionymExAuthor = parser.parseFullName(strNameAbiesBasionymExAuthor1Unicode, null, Rank.SPECIES());\r
+               NonViralName<?> nameBasionymExAuthor = parser.parseFullName(strNameAbiesBasionymExAuthor1Unicode, null, Rank.SPECIES());\r
                assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());\r
                assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());\r
                assertEquals("D'M\u00FCller", nameBasionymExAuthor.getExCombinationAuthorTeam().getNomenclaturalTitle());\r
@@ -252,7 +253,7 @@ public class NonViralNameParserImplTest {
                }\r
                \r
                //Team\r
-               NonViralName nameTeam1 = parser.parseFullName(strNameTeam1);\r
+               NonViralName<?> nameTeam1 = parser.parseFullName(strNameTeam1);\r
                assertEquals( "Abies", nameTeam1.getGenusOrUninomial());\r
                assertEquals( "alba", nameTeam1.getSpecificEpithet());\r
                assertEquals("Mueller & L.",  nameTeam1.getCombinationAuthorTeam().getNomenclaturalTitle());\r
@@ -285,19 +286,20 @@ public class NonViralNameParserImplTest {
                \r
                \r
                //empty\r
-               NonViralName nameEmpty = parser.parseFullName(strNameEmpty);\r
+               NonViralName<?> nameEmpty = parser.parseFullName(strNameEmpty);\r
                assertNotNull(nameEmpty);\r
                assertEquals("", nameEmpty.getTitleCache());\r
                \r
                //null\r
-               NonViralName nameNull = parser.parseFullName(strNameNull);\r
+               NonViralName<?> nameNull = parser.parseFullName(strNameNull);\r
                assertNull(nameNull);\r
                \r
                //some authors\r
                String fullNameString = "Abies alba (Greuther & L'Hiver & al. ex M\u00FCller & Schmidt)Clark ex Ciardelli"; \r
-               BotanicalName authorname = (BotanicalName)parser.parseFullName(fullNameString);\r
+               NonViralName<?> authorname = (BotanicalName)parser.parseFullName(fullNameString);\r
                assertFalse(authorname.hasProblem());\r
                assertEquals("Basionym author should have 3 authors", 3, ((Team)authorname.getExBasionymAuthorTeam()).getTeamMembers().size());\r
+\r
        }\r
        \r
        /**\r
@@ -315,7 +317,7 @@ public class NonViralNameParserImplTest {
                \r
                //Species hybrid\r
 //             NonViralName nameTeam1 = parser.parseFullName("Aegilops \u00D7insulae-cypri H. Scholz");\r
-               NonViralName name1 = parser.parseFullName("Aegilops \u00D7insulae Scholz", botanicCode, null);\r
+               NonViralName<?> name1 = parser.parseFullName("Aegilops \u00D7insulae Scholz", botanicCode, null);\r
                assertTrue("Name must have binom hybrid bit set", name1.isBinomHybrid());\r
                assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());\r
                assertFalse("Name must not have trinom hybrid bit set", name1.isTrinomHybrid());\r
@@ -434,23 +436,23 @@ public class NonViralNameParserImplTest {
        \r
        private void testName_StringNomcodeRank(Method parseMethod) \r
                        throws InvocationTargetException, IllegalAccessException  {\r
-               NonViralName<?> name1 = (NonViralName)parseMethod.invoke(parser, strNameAbies1, null, Rank.SPECIES());\r
+               NonViralName<?> name1 = (NonViralName<?>)parseMethod.invoke(parser, strNameAbies1, null, Rank.SPECIES());\r
                //parser.parseFullName(strNameAbies1, null, Rank.SPECIES());\r
                assertEquals("Abies", name1.getGenusOrUninomial());\r
                assertEquals("alba", name1.getSpecificEpithet());\r
                \r
-               NonViralName nameAuthor = (NonViralName)parseMethod.invoke(parser, strNameAbiesAuthor1, null, Rank.SPECIES());\r
+               NonViralName<?> nameAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesAuthor1, null, Rank.SPECIES());\r
                assertEquals("Abies", nameAuthor.getGenusOrUninomial());\r
                assertEquals("alba", nameAuthor.getSpecificEpithet());\r
                assertEquals("Mueller", nameAuthor.getCombinationAuthorTeam().getNomenclaturalTitle());\r
                \r
-               NonViralName<?> nameBasionymAuthor = (NonViralName)parseMethod.invoke(parser, strNameAbiesBasionymAuthor1, null, Rank.SPECIES());\r
+               NonViralName<?> nameBasionymAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesBasionymAuthor1, null, Rank.SPECIES());\r
                assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());\r
                assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());\r
                assertEquals("D'Mueller", nameBasionymAuthor.getCombinationAuthorTeam().getNomenclaturalTitle());\r
                assertEquals("Ciardelli", nameBasionymAuthor.getBasionymAuthorTeam().getNomenclaturalTitle());\r
                \r
-               NonViralName<?> nameBasionymExAuthor = (NonViralName)parseMethod.invoke(parser, strNameAbiesBasionymExAuthor1, null, Rank.SPECIES());\r
+               NonViralName<?> nameBasionymExAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesBasionymExAuthor1, null, Rank.SPECIES());\r
                assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());\r
                assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());\r
                assertEquals("D'Mueller", nameBasionymExAuthor.getExCombinationAuthorTeam().getNomenclaturalTitle());\r
@@ -458,7 +460,7 @@ public class NonViralNameParserImplTest {
                assertEquals("Ciardelli", nameBasionymExAuthor.getExBasionymAuthorTeam().getNomenclaturalTitle());\r
                assertEquals("Doering", nameBasionymExAuthor.getBasionymAuthorTeam().getNomenclaturalTitle());\r
                \r
-               NonViralName<?> name2 = (NonViralName)parseMethod.invoke(parser, strNameAbiesSub1, null, Rank.SPECIES());\r
+               NonViralName<?> name2 = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesSub1, null, Rank.SPECIES());\r
                assertEquals("Abies", name2.getGenusOrUninomial());\r
                assertEquals("alba", name2.getSpecificEpithet());\r
                assertEquals("beta", name2.getInfraSpecificEpithet());\r
@@ -695,16 +697,16 @@ public class NonViralNameParserImplTest {
                String strFullWhiteSpcaceAndDot = "Abies alba Mill.,  Sp.   Pl.  4:  455 .  1987 .";\r
                NonViralName<?> namefullWhiteSpcaceAndDot = parser.parseReferencedName(strFullWhiteSpcaceAndDot, null, rankSpecies);\r
                assertFullRefStandard(namefullWhiteSpcaceAndDot);\r
-               assertTrue(((Reference)namefullWhiteSpcaceAndDot.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));\r
+               assertTrue(((Reference<?>)namefullWhiteSpcaceAndDot.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));\r
                assertEquals( "Abies alba Mill., Sp. Pl. 4: 455. 1987", namefullWhiteSpcaceAndDot.getFullTitleCache());\r
 \r
                //Book\r
                String fullReference = "Abies alba Mill., Sp. Pl. 4: 455. 1987";\r
                NonViralName<?> name1 = parser.parseReferencedName(fullReference, null, rankSpecies);\r
                assertFullRefStandard(name1);\r
-               assertTrue(((Reference)name1.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));\r
+               assertTrue(((Reference<?>)name1.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));\r
                assertEquals(fullReference, name1.getFullTitleCache());\r
-               assertTrue("Name author and reference author should be the same", name1.getCombinationAuthorTeam() == ((Reference)name1.getNomenclaturalReference()).getAuthorTeam());\r
+               assertTrue("Name author and reference author should be the same", name1.getCombinationAuthorTeam() == ((Reference<?>)name1.getNomenclaturalReference()).getAuthorTeam());\r
                \r
                //Book Section\r
                fullReference = "Abies alba Mill. in Otto, Sp. Pl. 4(6): 455. 1987";\r
@@ -713,7 +715,7 @@ public class NonViralNameParserImplTest {
                assertEquals(fullReference, name2.getFullTitleCache());\r
                assertFalse(name2.hasProblem());\r
                INomenclaturalReference ref = name2.getNomenclaturalReference();\r
-               assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.BookSection, ((Reference)ref).getType());\r
+               assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.BookSection, ((Reference<?>)ref).getType());\r
                IBookSection bookSection = (IBookSection) ref;\r
                IBook inBook = bookSection.getInBook();\r
                assertNotNull(inBook);\r
@@ -722,7 +724,7 @@ public class NonViralNameParserImplTest {
                assertEquals("Otto, Sp. Pl. 4(6)", inBook.getTitleCache());\r
                assertEquals("Sp. Pl.", inBook.getTitle());\r
                assertEquals("4(6)", inBook.getVolume());\r
-               assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorTeam() == ((Reference)name2.getNomenclaturalReference()).getAuthorTeam());\r
+               assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorTeam() == ((Reference<?>)name2.getNomenclaturalReference()).getAuthorTeam());\r
                \r
                //Article\r
                fullReference = "Abies alba Mill. in Sp. Pl. 4(6): 455. 1987";\r
@@ -737,7 +739,7 @@ public class NonViralNameParserImplTest {
                IJournal journal = ((IArticle)ref).getInJournal();\r
                assertNotNull(journal);\r
                //assertEquals("Sp. Pl. 4(6)", inBook.getTitleCache());\r
-               assertEquals("Sp. Pl.",((Reference) journal).getTitleCache());\r
+               assertEquals("Sp. Pl.",((Reference<?>) journal).getTitleCache());\r
                assertEquals("Sp. Pl.", journal.getTitle());\r
                assertEquals("4(6)",((IArticle)ref).getVolume());\r
                assertTrue("Name author and reference author should be the same", name3.getCombinationAuthorTeam() == name3.getNomenclaturalReference().getAuthorTeam());\r
@@ -759,7 +761,7 @@ public class NonViralNameParserImplTest {
                assertEquals(parsedYear, ref.getYear());\r
                journal = ((IArticle)ref).getInJournal();\r
                assertNotNull(journal);\r
-               assertEquals(journalTitle, ((Reference) journal).getTitleCache());\r
+               assertEquals(journalTitle, ((Reference<?>) journal).getTitleCache());\r
                assertEquals(journalTitle, journal.getTitle());\r
                assertEquals("4(6)", ((IArticle)ref).getVolume());\r
                \r
@@ -1089,9 +1091,47 @@ public class NonViralNameParserImplTest {
 \r
                testParsable = "Cichorium intybus subsp. glaucum (Hoffmanns. & Link) Tzvelev in Komarov, Fl. SSSR 29: 17. 1964";\r
                assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICBN));\r
+\r
+               \r
        }\r
        \r
        \r
+       /**\r
+        * Test author with name parts van, von, de, de la, d', da, del.\r
+        * See also http://dev.e-taxonomy.eu/trac/ticket/3373\r
+        */\r
+       @Test\r
+       public final void  testComposedAuthorNames(){\r
+                       \r
+               //van author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               String testParsable = "Aphelocoma unicolor subsp. griscomi van Rossem, 1928"; \r
+               assertTrue("Author with 'van' should be parsable", isParsable(testParsable, ICZN));\r
+\r
+               //von author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               testParsable = "Aphelocoma unicolor subsp. griscomi von Rossem, 1928"; \r
+               assertTrue("Author with 'von' should be parsable", isParsable(testParsable, ICZN));\r
+\r
+               //de author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               testParsable = "Aphelocoma unicolor subsp. griscomi de Rossem, 1928"; \r
+               assertTrue("Author with 'de' should be parsable", isParsable(testParsable, ICZN));\r
+\r
+               //de la author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               testParsable = "Aphelocoma unicolor subsp. griscomi de la Rossem, 1928"; \r
+               assertTrue("Author with 'de la' should be parsable", isParsable(testParsable, ICZN));\r
+\r
+               //d' author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               testParsable = "Aphelocoma unicolor subsp. griscomi d'Rossem, 1928"; \r
+               assertTrue("Author with \"'d'\" should be parsable", isParsable(testParsable, ICZN));\r
+\r
+               //da author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               testParsable = "Aphelocoma unicolor subsp. griscomi da Rossem, 1928"; \r
+               assertTrue("Author with 'da' should be parsable", isParsable(testParsable, ICZN));\r
+\r
+               //del author (see https://dev.e-taxonomy.eu/trac/ticket/3373)\r
+               testParsable = "Aphelocoma unicolor subsp. griscomi del Rossem, 1928"; \r
+               assertTrue("Author with 'del' should be parsable", isParsable(testParsable, ICZN));\r
+\r
+       }       \r
        \r
        \r
        \r
@@ -1127,8 +1167,7 @@ public class NonViralNameParserImplTest {
                assertNotNull(name.getNomenclaturalReference());\r
                INomenclaturalReference ref = (INomenclaturalReference)name.getNomenclaturalReference();\r
                assertEquals("1987", ref.getYear());\r
-               Reference refBase = (Reference)ref;\r
-               assertEquals("Sp. Pl.", refBase.getTitle());\r
+               assertEquals("Sp. Pl.", ref.getTitle());\r
        }\r
        \r
        \r
@@ -1152,7 +1191,7 @@ public class NonViralNameParserImplTest {
                Assert.assertEquals("If this line reached everything should be ok", "Scorzonera", nvn.getGenusOrUninomial());\r
                \r
                String unparsable = "Taraxacum nevskii L., Trudy Bot. Inst. Nauk S.S.S.R., Ser. 1, Fl. Sist. Vyssh. Rast. 4: 293. 1937.";\r
-               String unparsableA = "Taraxacum nevskii L. in Trudy Bot. Inst. Nauk: 293. 1937.";\r
+//             String unparsableA = "Taraxacum nevskii L. in Trudy Bot. Inst. Nauk: 293. 1937.";\r
                nvn = this.parser.parseReferencedName(unparsable, ICBN, null);\r
                Assert.assertEquals("Titlecache", "Taraxacum nevskii L.", nvn.getTitleCache());\r
                Assert.assertEquals("If this line reached everything should be ok", "Taraxacum", nvn.getGenusOrUninomial());\r
@@ -1160,7 +1199,7 @@ public class NonViralNameParserImplTest {
                Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);\r
                \r
                String unparsable2 = "Hieracium pxxx Dahlst., Kongl. Svenska Vetensk. Acad. Handl. ser. 2, 26(3): 255. 1894";\r
-               String unparsable2A = "Hieracium pxxx Dahlst., Kongl Svenska Vetensk Acad Handl, 26: 255. 1894.";\r
+//             String unparsable2A = "Hieracium pxxx Dahlst., Kongl Svenska Vetensk Acad Handl, 26: 255. 1894.";\r
                nvn = this.parser.parseReferencedName(unparsable2, ICBN, null);\r
                Assert.assertEquals("Titlecache", "Hieracium pxxx Dahlst.", nvn.getTitleCache());\r
                Assert.assertEquals("If this line reached everything should be ok", "Hieracium", nvn.getGenusOrUninomial());\r