From 241cb998b564103991f80b38748d2a5e72cf581a Mon Sep 17 00:00:00 2001 From: knightmarehs Date: Sat, 26 Jan 2019 15:09:43 +0800 Subject: [PATCH] Fix dataset adaptability 1. Auto detect the three basic type ids instead of predefining them. --- src/qa/GAnswer.java | 1 - src/qa/extract/TypeRecognition.java | 28 ++++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/qa/GAnswer.java b/src/qa/GAnswer.java index 564b7b9..000be6e 100644 --- a/src/qa/GAnswer.java +++ b/src/qa/GAnswer.java @@ -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); } diff --git a/src/qa/extract/TypeRecognition.java b/src/qa/extract/TypeRecognition.java index b9bc1bb..91af418 100644 --- a/src/qa/extract/TypeRecognition.java +++ b/src/qa/extract/TypeRecognition.java @@ -24,15 +24,10 @@ import rdf.TypeMapping; * 3、Add some extend variable, (generalization of [variable with inherit type] -> [variable with inherit triples]) eg, ?canadian * */ 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 type_Person = new ArrayList(); + public static ArrayList type_Place = new ArrayList(); + public static ArrayList type_Organisation = new ArrayList(); public static HashMap extendTypeMap = null; public static HashMap 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)