01: /*
02: * Copyright (C) 1999-2004 <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</a>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.mandarax.examples.crm;
19:
20: import java.io.File;
21: import org.mandarax.kernel.KnowledgeBase;
22: import org.mandarax.zkb.ZKBManager;
23:
24: /**
25: * Class responsible for loading the knowledge base.
26: * In this example, we use ZKB and load the kb from a folder
27: * (alternatively, a zip file could be used as well).
28: * @author <A href="http://www-ist.massey.ac.nz/JBDietrich" target="_top">Jens Dietrich</A>
29: * @version 3.4 <7 March 05>
30: * @since 3.4
31: */
32: public class KBLoader {
33:
34: private static KnowledgeBase kb = null;
35: public static java.io.File KB_FOLDER = new File(
36: "exampledata/crm_example");
37:
38: /**
39: * Get the sample knowledge base. The knowledge base is hardcoded here,
40: * but should actually come from a data source.
41: * @return a knowledge base
42: */
43: public static KnowledgeBase getKB() {
44: if (kb == null) {
45: try {
46: kb = new ZKBManager().importKnowledgeBase(KB_FOLDER);
47: System.out.println("CRM Example kb from "
48: + KB_FOLDER.getAbsolutePath());
49: } catch (Exception x) {
50: System.out.println("Cannot load kb from "
51: + KB_FOLDER.getAbsolutePath());
52: x.printStackTrace();
53: }
54: }
55: return kb;
56:
57: }
58: }
|