package com.github.bot.curiosone.core.analysis;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Loading the dictionary from a file.
 *
 * @author Cosmo Pugliese && Francesco Natale.
 *
 */

public class DictionaryLoader {
  /**
   *The Uri containing the .properties file.
   */
  private static final String uri = "resources/Dictionary/DataDict.properties";
  
  /**
   * The map which contains words and their sentiment's score.
   */
  private static Map<String, Double> dict = new HashMap<>();
  
  /**
   * Initializing of the properties.
   */
  private static Properties properties = new Properties();
  

  /**
   * Loading the .properties file in the dictionary.
   * @Return the loaded dictionary
   */
  public static Map<String, Double> loadDict() {
    try {
      properties.load(new FileInputStream(uri));
    } catch (IOException e) {
      e.printStackTrace();
    }
    for (String key : properties.stringPropertyNames()) {
      dict.put(key, Double.parseDouble(properties.get(key).toString()));
    }
    return dict;
  }
  
}

@@ -42,16 +42,156 @@
 lysis;%0A%0A
+import java.net.URISyntaxException;%0Aimport java.net.URL;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0A
 import j
@@ -551,19 +551,10 @@
  = %22
-resources/D
+/d
 icti
@@ -581,18 +581,16 @@
 rties%22;%0A
-  
 %0A  /**%0A 
@@ -702,30 +702,10 @@
 dict
- = new HashMap%3C%3E();%0A  
+;%0A
 %0A  /
@@ -809,18 +809,16 @@
 ties();%0A
-  
 %0A%0A  /**%0A
@@ -968,13 +968,139 @@
     
-try %7B
+Path path = null;%0A    try %7B%0A      URL resource = DictionaryLoader.class.getResource(uri);%0A      path = Paths.get(resource.toURI());
 %0A   
@@ -1138,19 +1138,31 @@
 tStream(
-uri
+path.toString()
 ));%0A    
@@ -1181,16 +1181,35 @@
 xception
+%7CURISyntaxException
  e) %7B%0A  
@@ -1397,13 +1397,11 @@
 ct;%0A  %7D%0A
-  
 %0A%7D%0A

fix Dictionary file path