Project

General

Profile

Revision 07ab7ef0

ID07ab7ef05a7ff5b0794912e6ce80f8f31a4e1239
Parent c45d681a
Child 79959591

Added by Andreas Müller over 1 year ago

ref #5448 adapt parser to recognize old ranks like proles

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImpl.java
808 808
			 //infra genus
809 809
			 else if (infraGenusPattern.matcher(fullNameString).matches()){
810 810
				Rank infraGenericRank;
811
				if ("[unranked]".equals(epi[1])){
811
				if ("[unranked]".equals(epi[1])||"[ranglos]".equals(epi[1])){
812 812
					infraGenericRank = Rank.INFRAGENERICTAXON();
813 813
				}else{
814 814
				    String infraGenericRankMarker = epi[1];
......
880 880
					infraSpecEpi = epi[4];
881 881
				}
882 882
				Rank infraSpecificRank;
883
				if ("[unranked]".equals(infraSpecRankMarker)){
883
				if ("[unranked]".equals(infraSpecRankMarker)||"[ranglos]".equals(infraSpecRankMarker)){
884 884
					infraSpecificRank = Rank.INFRASPECIFICTAXON();
885 885
				}else{
886 886
					String localInfraSpecRankMarker;
......
914 914

  
915 915
			 }//old infraSpecies
916 916
			 else if (oldInfraSpeciesPattern.matcher(fullNameString).matches()){
917
				boolean implemented = false;
917
				boolean implemented = true;
918 918
				if (implemented){
919
					nameToBeFilled.setRank(Rank.getRankByNameOrIdInVoc(epi[2]));
920
					nameToBeFilled.setGenusOrUninomial(epi[0]);
921
					nameToBeFilled.setSpecificEpithet(epi[1]);
922
					//TODO result.setUnnamedNamePhrase(epi[2] + " " + epi[3]);
923
					authorString = fullNameString.substring(epi[0].length()+ 1 + epi[1].length() +1 + epi[2].length() + 1 + epi[3].length());
919
				    String infraSpecRankMarker = epi[2];
920
	                String infraSpecEpi = epi[3];
921

  
922
	                Rank infraSpecificRank = Rank.getRankByNameOrIdInVoc(infraSpecRankMarker);
923
	                nameToBeFilled.setRank(infraSpecificRank);
924
	                nameToBeFilled.setGenusOrUninomial(epi[0]);
925
	                nameToBeFilled.setSpecificEpithet(epi[1]);
926
	                nameToBeFilled.setInfraSpecificEpithet(infraSpecEpi);
927
	                authorString = fullNameString.substring(epi[0].length()+ 1 + epi[1].length() +1 + infraSpecRankMarker.length() + 1 + infraSpecEpi.length());
928

  
924 929
				}else{
925 930
					nameToBeFilled.addParsingProblem(ParserProblem.OldInfraSpeciesNotSupported);
926 931
					nameToBeFilled.setTitleCache(fullNameString, true);
927
					// FIXME Quick fix, otherwise search would not deilver results for unparsable names
932
					// FIXME Quick fix, otherwise search would not deliver results for unparsable names
928 933
					nameToBeFilled.setNameCache(fullNameString,true);
929 934
					// END
930 935
					logger.info("Name string " + fullNameString + " could not be parsed because UnnnamedNamePhrase is not yet implemented!");
931 936
				}
932
			}
937
			 }
933 938
		     //hybrid formula
934 939
			 else if (hybridFormulaPattern.matcher(fullNameString).matches()){
935 940
				 Set<HybridRelationship> existingRelations = new HashSet<>();
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplRegExBase.java
90 90
    protected static String status = "";
91 91

  
92 92
    //marker
93
    protected static String InfraGenusMarker = "(n|notho)?(subg(en)?\\.|sect\\.|subsect\\.|ser\\.|subser\\.|t\\.infgen\\.|\\[unranked\\])";
93
    protected static String InfraGenusMarker = "(n|notho)?(subg(en)?\\.|sect\\.|subsect\\.|ser\\.|subser\\.|t\\.infgen\\.|\\[unranked\\]|\\[ranglos\\])";
94 94
    protected static String aggrOrGroupMarker = "(aggr\\.|agg\\.|group)";
95
    protected static String infraSpeciesMarkerNoNotho = "(subsp\\.|convar\\.|var\\.|subvar\\.|f\\.|forma|subf\\.|f\\.\\ssp\\.|f\\.spec\\.|f\\.sp\\.|\\[unranked\\]|tax\\." + fWs + "infrasp\\.)";
95
    protected static String infraSpeciesMarkerNoNotho = "(subsp\\.|convar\\.|var\\.|subvar\\.|f\\.|forma|subf\\.|f\\.\\ssp\\.|f\\.spec\\.|f\\.sp\\.|\\[unranked\\]|\\[ranglos\\]|tax\\." + fWs + "infrasp\\.)";
96 96
    protected static String infraSpeciesMarker = "(n|notho)?" + infraSpeciesMarkerNoNotho;
97 97
    protected static String oldInfraSpeciesMarker = "(prol\\.|proles|race|taxon|sublusus)";
98 98

  
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplTest.java
602 602
        assertEquals( "infraspecific", name.getInfraSpecificEpithet());
603 603
        assertEquals( "Unranked rank should be parsed", Rank.INFRASPECIFICTAXON(), name.getRank());
604 604

  
605
        //'ranglos' infraspecific
606
        infraspecificUnranked = "Genus species [ranglos] infraspecific";
607
        name = parser.parseFullName(infraspecificUnranked);
608
        assertEquals( "Genus", name.getGenusOrUninomial());
609
        assertEquals( "species", name.getSpecificEpithet());
610
        assertEquals( "infraspecific", name.getInfraSpecificEpithet());
611
        assertEquals( "Unranked rank should be parsed", Rank.INFRASPECIFICTAXON(), name.getRank());
612

  
605 613
        //unranked infrageneric
606 614
        String infraGenericUnranked = "Genus [unranked] Infragen";
607 615
        INonViralName name2 = parser.parseFullName(infraGenericUnranked);
......
610 618
        assertEquals( "Infragen", name2.getInfraGenericEpithet());
611 619
        assertEquals( "Unranked rank should be parsed", Rank.INFRAGENERICTAXON(), name2.getRank());
612 620

  
621
        //unranked infrageneric
622
        infraGenericUnranked = "Genus [ranglos] Infragen";
623
         name2 = parser.parseFullName(infraGenericUnranked);
624
        assertEquals( "Genus", name2.getGenusOrUninomial());
625
        assertEquals( null, name2.getSpecificEpithet());
626
        assertEquals( "Infragen", name2.getInfraGenericEpithet());
627
        assertEquals( "Ranglos rank should be parsed", Rank.INFRAGENERICTAXON(), name2.getRank());
628

  
629
    }
630

  
631
    /**
632
     * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
633
     */
634
    @Test
635
    public final void testOldRanks() {
636
        try {
637
            Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
638
            testName_StringNomcodeRank(parseMethod);
639
        } catch (Exception e) {
640
            e.printStackTrace();
641
            assertTrue(false);
642
        }
643

  
644
        //proles
645
        String infraspecificUnranked = "Genus species proles infraspecific";
646
        INonViralName name = parser.parseFullName(infraspecificUnranked);
647
        assertEquals( "Genus", name.getGenusOrUninomial());
648
        assertEquals( "species", name.getSpecificEpithet());
649
        assertEquals( "infraspecific", name.getInfraSpecificEpithet());
650
        assertEquals( "Proles should be parsed", Rank.PROLES(), name.getRank());
651

  
652
        //sublusus
653
        infraspecificUnranked = "Genus species sublusus infraspecific";
654
        name = parser.parseFullName(infraspecificUnranked);
655
        assertEquals( "Genus", name.getGenusOrUninomial());
656
        assertEquals( "species", name.getSpecificEpithet());
657
        assertEquals( "infraspecific", name.getInfraSpecificEpithet());
658
        assertEquals( "Sublusus should be parsed", Rank.SUBLUSUS(), name.getRank());
659

  
660

  
661
        //race
662
        infraspecificUnranked = "Genus species race infraspecific";
663
        name = parser.parseFullName(infraspecificUnranked);
664
        assertEquals( "Genus", name.getGenusOrUninomial());
665
        assertEquals( "species", name.getSpecificEpithet());
666
        assertEquals( "infraspecific", name.getInfraSpecificEpithet());
667
        assertEquals( "Race should be parsed", Rank.RACE(), name.getRank());
668

  
669

  
670

  
613 671
    }
614 672

  
615 673

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)