Changeset 5953


Ignore:
Timestamp:
May 28, 2020, 8:45:34 AM (2 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1248: Translations for SSP plug-in should be configured in reggie-config.xml

Location:
extensions/net.sf.basedb.reggie/branches/4.27-stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/4.27-stable/config/reggie-config.xml

    r5941 r5953  
    9393        </model>
    9494      </models>
     95     
     96      <!-- Translations that should be applied to results from SSP models before stored as annotations in BASE -->
     97      <translations>
     98        <text from="Positiv" to="Positive" />
     99        <text from="Negativ" to="Negative" />
     100        <text from="Hög" to="High" />
     101        <text from="Hog" to="High" />
     102        <text from="Låg" to="Low" />
     103        <text from="Lag" to="Low" />
     104        <text from="Grad 1" to="Grade1" />
     105        <text from="Grad 2" to="Grade2" />
     106        <text from="Grad 3" to="Grade3" />
     107      </translations>
    95108    </ssp>
    96109   
  • extensions/net.sf.basedb.reggie/branches/4.27-stable/src/net/sf/basedb/reggie/ssp/SspModel.java

    r5942 r5953  
    22
    33import java.util.ArrayList;
     4import java.util.HashMap;
    45import java.util.List;
     6import java.util.Map;
    57
    68import org.jdom2.Element;
     
    98100    Element e = cfg.getElement("rscript/ssp/models/model[@name='"+name+"']");
    99101    return e == null ? null : new SspModel(e);
     102  }
     103 
     104  /**
     105    Get translations that should should be applied to results from SSP
     106    models before they are stored as annotations in BASE.
     107    @since 4.27.1
     108  */
     109  public static Map<String, String> getTranslations()
     110  {
     111    XmlConfig cfg = Reggie.getConfig();
     112    List<Element> elements = cfg.getElements("rscript/ssp/translations/text");
     113    Map<String, String> translations = new HashMap<>();
     114    for (Element e : elements)
     115    {
     116      translations.put(e.getAttributeValue("from").toLowerCase(), e.getAttributeValue("to"));
     117    }
     118    return translations;
    100119  }
    101120 
  • extensions/net.sf.basedb.reggie/branches/4.27-stable/src/net/sf/basedb/reggie/ssp/SspPlugin.java

    r5952 r5953  
    44import java.util.Arrays;
    55import java.util.Collections;
    6 import java.util.HashMap;
    76import java.util.HashSet;
    87import java.util.List;
     
    320319  {
    321320    if (word == null) return null;
    322     if (translations == null)
    323     {
    324       translations = new HashMap<String, String>();
    325       translations.put("positiv", "Positive");
    326       translations.put("negativ", "Negative");
    327       translations.put("hög", "High");
    328       translations.put("låg", "Low");
    329       translations.put("hog", "High");
    330       translations.put("lag", "Low");
    331       translations.put("grad 1", "Grade1");
    332       translations.put("grad 2", "Grade2");
    333       translations.put("grad 3", "Grade3");
    334     }
     321    if (translations == null) translations =  SspModel.getTranslations();
    335322    String translatedWord = translations.get(word.toLowerCase());
    336323    return translatedWord == null ? word : translatedWord;
Note: See TracChangeset for help on using the changeset viewer.