1   package eu.fbk.dh.tint.heideltime.annotator;
2   
3   import de.unihd.dbs.heideltime.standalone.Config;
4   import de.unihd.dbs.heideltime.standalone.DocumentType;
5   import de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone;
6   import de.unihd.dbs.heideltime.standalone.OutputType;
7   import de.unihd.dbs.uima.annotator.heideltime.resources.Language;
8   import org.slf4j.Logger;
9   import org.slf4j.LoggerFactory;
10  
11  import java.util.Properties;
12  
13  /**
14   * Created by alessio on 25/05/15.
15   */
16  
17  public class HeidelTimeModel {
18  
19      private static HeidelTimeModel instance;
20      private HeidelTimeStandalone tagger;
21      private static final Logger LOGGER = LoggerFactory.getLogger(HeidelTimeModel.class);
22  
23      // /Users/alessio/Documents/scripts/simpatico-dashboard/config.props
24  
25      private HeidelTimeModel(String configFile, DocumentType documentType) {
26          LOGGER.trace("Loading tagger for HeidelTime");
27          tagger = new HeidelTimeStandalone(Language.ITALIAN, documentType, OutputType.XMI, configFile);
28      }
29  
30      private HeidelTimeModel(Properties properties, DocumentType documentType) {
31          LOGGER.trace("Loading tagger for HeidelTime");
32  
33          Config.setProps(properties);
34          tagger = new HeidelTimeStandalone(Language.ITALIAN, documentType, OutputType.XMI);
35      }
36  
37      public static HeidelTimeModel getInstance(String configFile, DocumentType documentType) {
38          if (instance == null) {
39              instance = new HeidelTimeModel(configFile, documentType);
40          }
41  
42          return instance;
43      }
44  
45      public static HeidelTimeModel getInstance(Properties properties, DocumentType documentType) {
46          if (instance == null) {
47              instance = new HeidelTimeModel(properties, documentType);
48          }
49  
50          return instance;
51      }
52  
53      public HeidelTimeStandalone getTagger() {
54          return tagger;
55      }
56  }