Browse Source

Fix dataset adaptability

1. Auto detect the three basic type ids instead of predefining them.
tags/v0.1.2
knightmarehs 6 years ago
parent
commit
241cb998b5
2 changed files with 20 additions and 9 deletions
  1. +0
    -1
      src/qa/GAnswer.java
  2. +20
    -8
      src/qa/extract/TypeRecognition.java

+ 0
- 1
src/qa/GAnswer.java View File

@@ -274,7 +274,6 @@ public class GAnswer {
outputs.add("[" + Math.min(MAX_SPQ_NUM+1, idx) + "]" + "score=" + 1000 + "\n" + stdSPQwoPrefix + "\n");
}
}
outputs.add(qlog.match.toString());
FileUtil.writeFile(outputs, "E:/Linyinnian/qald6_special_out.txt", true);
}


+ 20
- 8
src/qa/extract/TypeRecognition.java View File

@@ -24,15 +24,10 @@ import rdf.TypeMapping;
* 3、Add some extend variable, (generalization of [variable with inherit type] -> [variable with inherit triples]) eg, ?canadian <birthPlace> <Canada>
* */
public class TypeRecognition {
// dbpedia 2014
//public static final int[] type_Person = {180,279};
//public static final int[] type_Place = {49,228};
//public static final int[] type_Organisation = {419,53};
//dbpedia 2016
public static final int[] type_Person = {5828,15985};
public static final int[] type_Place = {11197,2188};
public static final int[] type_Organisation = {1335,4716};
public static ArrayList<Integer> type_Person = new ArrayList<Integer>();
public static ArrayList<Integer> type_Place = new ArrayList<Integer>();
public static ArrayList<Integer> type_Organisation = new ArrayList<Integer>();
public static HashMap<String, String> extendTypeMap = null;
public static HashMap<String, Triple> extendVariableMap = null;
@@ -53,6 +48,23 @@ public class TypeRecognition {
extendTypeMap.put("USStates", "yago:StatesOfTheUnitedStates");
extendTypeMap.put("Europe", "yago:EuropeanCountries");
extendTypeMap.put("Africa", "yago:AfricanCountries");
//Types for wh-word
if(TypeFragment.typeShortName2IdList != null)
{
if(TypeFragment.typeShortName2IdList.containsKey("Person"))
type_Person.addAll(TypeFragment.typeShortName2IdList.get("Person"));
if(TypeFragment.typeShortName2IdList.containsKey("NaturalPerson"))
type_Person.addAll(TypeFragment.typeShortName2IdList.get("NaturalPerson"));
if(TypeFragment.typeShortName2IdList.containsKey("Location"))
type_Place.addAll(TypeFragment.typeShortName2IdList.get("Location"));
if(TypeFragment.typeShortName2IdList.containsKey("Place"))
type_Place.addAll(TypeFragment.typeShortName2IdList.get("Place"));
if(TypeFragment.typeShortName2IdList.containsKey("Organisation"))
type_Organisation.addAll(TypeFragment.typeShortName2IdList.get("Organisation"));
if(TypeFragment.typeShortName2IdList.containsKey("Organization"))
type_Organisation.addAll(TypeFragment.typeShortName2IdList.get("Organization"));
}
}
public static void recognizeExtendVariable(Word w)


Loading…
Cancel
Save