Changeset 5929


Ignore:
Timestamp:
May 5, 2020, 1:24:33 PM (4 weeks ago)
Author:
Nicklas Nordborg
Message:

References #1239: Include Single Sample Predictor models in the StringTie? pipeline

Added support for translating results from the SSP models. The main reason is that some models generate swedish text but we would like to keep annotations in english. Currently there are two translations:

  • positiv -> Positive
  • negativ -> Negative
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/ssp/SspPlugin.java

    r5926 r5929  
    44import java.util.Arrays;
    55import java.util.Collections;
     6import java.util.HashMap;
    67import java.util.HashSet;
    78import java.util.List;
     9import java.util.Map;
    810import java.util.Set;
    911
     
    4850import net.sf.basedb.reggie.dao.Rawdatatype;
    4951import net.sf.basedb.reggie.dao.Subtype;
    50 import net.sf.basedb.reggie.ssp.SspAnalysis;
    51 import net.sf.basedb.reggie.ssp.SspModel;
    5252import net.sf.basedb.util.Enumeration;
    5353import net.sf.basedb.util.Values;
     
    202202            try
    203203            {
    204               Object value = model.getAnnotationType(dc).getValueType().parseString(modelResult.getResult());
     204              Object value = model.getAnnotationType(dc).getValueType().parseString(translate(modelResult.getResult()));
    205205              Change change = batcher.setValue(model.getAnnotationType(dc), value, null, false);
    206206              if (change != Change.NO_CHANGE) numAnnotations++;
     
    293293    }
    294294   
     295  }
     296 
     297  private Map<String, String> translations;
     298  private String translate(String word)
     299  {
     300    if (word == null) return null;
     301    if (translations == null)
     302    {
     303      translations = new HashMap<String, String>();
     304      translations.put("positiv", "Positive");
     305      translations.put("negativ", "Negative");
     306    }
     307    String translatedWord = translations.get(word.toLowerCase());
     308    return translatedWord == null ? word : translatedWord;
    295309  }
    296310
Note: See TracChangeset for help on using the changeset viewer.