package org.gbif.nameparser;

import org.gbif.nameparser.api.ParsedAuthorship;
import org.gbif.nameparser.api.ParsedName;

import java.util.HashMap;
import java.util.Map;

public class ParserConfigs {

  private final Map<String, ParsedName> names = new HashMap<>();
  private final Map<String, ParsedAuthorship> authorships = new HashMap<>();

  public ParsedName forName(String name) {
    name = ParsingJob.preClean(name, null);
    return names.get(name);
  }

  public ParsedAuthorship forAuthorship(String authorship) {
    authorship = ParsingJob.preClean(authorship, null);
    return authorships.get(authorship);
  }

  public void setName(String sciname, ParsedName pn) {
    names.put(ParsingJob.preClean(sciname, null), pn);
  }

  public ParsedName deleteName(String name) {
    return names.remove(ParsingJob.preClean(name, null));
  }

  public void setAuthorship(String authorship, ParsedAuthorship pn) {
    authorships.put(ParsingJob.preClean(authorship, null), pn);
  }

  public ParsedAuthorship deleteAuthorship(String authorship) {
    return authorships.remove(ParsingJob.preClean(authorship, null));
  }
}

@@ -385,52 +385,8 @@
 ) %7B%0A
-    name = ParsingJob.preClean(name, null);%0A
     
@@ -402,21 +402,27 @@
 mes.get(
+norm(
 name)
+)
 ;%0A  %7D%0A%0A 
@@ -485,64 +485,8 @@
 ) %7B%0A
-    authorship = ParsingJob.preClean(authorship, null);%0A
     
@@ -508,16 +508,21 @@
 ips.get(
+norm(
 authorsh
@@ -524,16 +524,17 @@
 horship)
+)
 ;%0A  %7D%0A%0A 
@@ -561,19 +561,16 @@
 (String 
-sci
 name, Pa
@@ -602,41 +602,17 @@
 put(
-ParsingJob.preClean(sciname, null
+norm(name
 ), p
@@ -694,38 +694,17 @@
 ove(
-ParsingJob.preClean(name, null
+norm(name
 ));%0A
@@ -798,35 +798,20 @@
 ips.put(
-ParsingJob.preClean
+norm
 (authors
@@ -813,22 +813,16 @@
 thorship
-, null
 ), pn);%0A
@@ -924,45 +924,125 @@
 ove(
-ParsingJob.preClean(authorship, null)
+norm(authorship));%0A  %7D%0A%0A  private static String norm(String x) %7B%0A    return ParsingJob.preClean(x, null).toLowerCase(
 );%0A 

normalize config keys further