00001
00002
00003
00004
00005
00006
00007 package com.dapissarenko.hierarchy;
00008
00009 import java.io.IOException;
00010 import java.util.ArrayList;
00011
00012 import org.opencyc.api.CycAccess;
00013 import org.opencyc.api.CycApiException;
00014 import org.opencyc.cycobject.CycConstant;
00015 import org.opencyc.cycobject.CycFort;
00016
00017
00018
00019
00020
00021 public class OrdussianPoliticalSystemMtWriter {
00022 private static final String COLLECTION = "Collection";
00023 public OrdussianPoliticalSystemMtWriter()
00024 {
00025 }
00026 public CycConstant writeMicroTheoryToCyc(CycAccess cyc) throws IOException, CycApiException
00027 {
00028 CycConstant ordus=null;
00029 CycConstant department=null;
00030 CycConstant mt=null;
00031 CycConstant depIntAff=null;
00032 CycConstant depEthSup=null;
00033 CycConstant fieldOfWork=null;
00034 CycConstant headOfDepartment=null;
00035 CycConstant alimagomedov=null;
00036 CycConstant civilServant=null;
00037 CycConstant lobo=null;
00038 CycConstant ouiantsevSu=null;
00039 CycConstant rabinovich=null;
00040 CycFort givenNames=null;
00041 CycFort familyName=null;
00042 CycFort superiors=null;
00043
00044
00045
00046
00047
00048 mt=cyc.createMicrotheory("OrdussianPoliticalSystemMt",
00049 "This microtheory describes the political system of Ordus'",
00050 "Microtheory",
00051 new ArrayList());
00052
00053
00054
00055
00056
00057
00058
00059
00060 this.createCountry("Russia", "Russian Federation", cyc, mt);
00061 this.createCountry("Belarus", "Belorussia", cyc, mt);
00062 this.createCountry("Austria", "Republic of Austria", cyc, mt);
00063 this.createCountry("Germany", "Federative Republic of Germany", cyc, mt);
00064
00065
00066
00067
00068
00069 ordus=cyc.createNewPermanent("Ordus");
00070 cyc.assertComment(ordus, "Hypothetical country", mt);
00071 cyc.assertIsa(ordus, cyc.getKnownConstantByName("Country"), mt);
00072
00073
00074
00075
00076 department=cyc.createNewPermanent("Department");
00077 cyc.assertIsa(department, cyc.getKnownConstantByName(COLLECTION), mt);
00078 cyc.assertGenls(department, cyc.getKnownConstantByName("Organization"), mt);
00079
00080
00081
00082
00083 depIntAff=cyc.createNewPermanent("DepartmentOfInternalAffairs");
00084 cyc.assertIsa(depIntAff, department, mt);
00085
00086
00087
00088
00089 depEthSup=cyc.createNewPermanent("DepartmentOfEthicalSupervision");
00090 cyc.assertIsa(depEthSup, department, mt);
00091
00092
00093
00094
00095 fieldOfWork=cyc.createNewPermanent("fieldOfWork");
00096 cyc.assertIsa(fieldOfWork, cyc.getKnownConstantByName("BinaryPredicate"), mt);
00097 cyc.assertComment(fieldOfWork, "(fieldOfWork a b) means that b is field of work of a", mt);
00098
00099
00100
00101
00102 cyc.assertGaf(mt, fieldOfWork, depIntAff, "Protection of citizens against criminals");
00103
00104
00105
00106
00107 cyc.assertGaf(mt, fieldOfWork, depEthSup, "Ensuring that the laws of Ordus are followed by its subjects");
00108
00109
00110
00111
00112 headOfDepartment=cyc.createNewPermanent("headOfDepartment");
00113 cyc.assertIsa(headOfDepartment, cyc.getKnownConstantByName("BinaryPredicate"), mt);
00114 cyc.assertComment(headOfDepartment, "(fieldOfWork a b) means that b is head of department a", mt);
00115
00116
00117
00118
00119
00120 civilServant=cyc.createNewPermanent("CivilServant");
00121 cyc.assertIsa(civilServant, cyc.getKnownConstantByName(COLLECTION), mt);
00122 cyc.assertGenls(civilServant, cyc.getKnownConstantByName("Person"), mt);
00123
00124
00125
00126
00127
00128
00129 givenNames=cyc.getKnownConstantByName("givenNames");
00130 familyName=cyc.getKnownConstantByName("familyName");
00131
00132 alimagomedov=cyc.createNewPermanent("RededyaAlimagomedov");
00133 cyc.assertIsa(alimagomedov, civilServant, mt);
00134 cyc.assertGaf(mt, givenNames, alimagomedov, "Rededya Peresvetovich");
00135 cyc.assertGaf(mt, familyName, alimagomedov, "Alimagomedov");
00136
00137
00138
00139
00140
00141
00142 lobo=cyc.createNewPermanent("BagaturLobo");
00143 cyc.assertIsa(lobo, civilServant, mt);
00144 cyc.assertGaf(mt, givenNames, lobo, "Bagatur");
00145 cyc.assertGaf(mt, familyName, lobo, "Lobo");
00146
00147
00148
00149
00150 superiors=cyc.getKnownConstantByName("superiors");
00151 cyc.assertGaf(mt, superiors, alimagomedov, lobo);
00152
00153
00154
00155
00156 cyc.assertGaf(mt, fieldOfWork, lobo, "Finding and catching criminals");
00157
00158
00159
00160
00161
00162
00163
00164 rabinovich=cyc.createNewPermanent("MokiiNilovichRabinovich");
00165 cyc.assertIsa(rabinovich, civilServant, mt);
00166 cyc.assertGaf(mt, givenNames, rabinovich, "Mokii Nilovich");
00167 cyc.assertGaf(mt, familyName, rabinovich, "Rabinovich");
00168
00169
00170
00171
00172
00173
00174
00175 ouiantsevSu=cyc.createNewPermanent("BogdanRukhovichOuiantsevSu");
00176 cyc.assertIsa(ouiantsevSu, civilServant, mt);
00177 cyc.assertGaf(mt, givenNames, ouiantsevSu, "Bogdan Rukhovich");
00178 cyc.assertGaf(mt, familyName, ouiantsevSu, "Ouiantsev-Su");
00179
00180
00181
00182
00183 cyc.assertGaf(mt, fieldOfWork, ouiantsevSu, "Legal advice to Bagatur Lobo");
00184
00185
00186
00187
00188 cyc.assertGaf(mt, superiors, rabinovich, ouiantsevSu);
00189
00190
00191
00192
00193 cyc.assertGaf(mt, headOfDepartment, depIntAff, alimagomedov);
00194
00195
00196
00197
00198 cyc.assertGaf(mt, headOfDepartment, depEthSup, rabinovich);
00199
00200 return mt;
00201 }
00202 private void createCountry(String countryName, String comment, CycAccess cyc, CycConstant mt) throws IOException, CycApiException
00203 {
00204 CycConstant country=null;
00205
00206 country=cyc.createNewPermanent(countryName);
00207 cyc.assertComment(country, comment, mt);
00208 cyc.assertIsa(country, cyc.getKnownConstantByName("Country"), mt);
00209 }
00210 }