PageRenderTime 38ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/code/Learned_DT.java

http://silkin.googlecode.com/
Java | 1061 lines | 956 code | 33 blank | 72 comment | 295 complexity | 3e50607e286b91346b3be2682b924ed1 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. import java.util.*;
  2. import javax.swing.JOptionPane;
  3. import java.io.*;
  4. import java.text.*;
  5. /**
  6. A Learned_DT is just a special kind of DomainTheory -- one that is learned, like a ConstextUnderConstruction.
  7. It holds records of test results for Leave-One-Out testing.
  8. @author Gary Morris, Northern Virginia Community College garymorris2245@verizon.net
  9. */
  10. public class Learned_DT extends DomainTheory implements Serializable {
  11. static boolean doBaseCBs = false,
  12. doInduction = false,
  13. tempFlag = false;
  14. TreeMap learningHistory = new TreeMap(), // (Integer)RoundNmbr => (Integer) SubRnd => ArrayList<Object> of things_learned (also ALists)
  15. rejectedDefs = new TreeMap(), // (String)kinTerm => list of DT.ProposedDef's
  16. dataReqCounter = new TreeMap();
  17. Oracle wiseGuy = new Oracle();
  18. AuxPredRegistry auxPreds = new AuxPredRegistry();
  19. public Learned_DT(DomainTheory papa) {
  20. languageName = papa.languageName;
  21. ctxt = papa.ctxt;
  22. author = papa.author;
  23. createDate = UDate.today(); // really holds the test date = today.
  24. nonTerms = papa.nonTerms;
  25. nonTermFlags = papa.nonTermFlags;
  26. polygamyOK = papa.polygamyOK;
  27. addressTerms = papa.addressTerms;
  28. levelsOfRecursion = papa.levelsOfRecursion;
  29. theory = new TreeMap(papa.theory);
  30. synonyms = papa.synonyms;
  31. if (synonyms == null) synonyms = new TreeMap();
  32. umbrellas = papa.umbrellas;
  33. if (umbrellas == null) umbrellas = new TreeMap();
  34. potUmbrellas = new TreeMap();
  35. nonSynonyms = papa.nonSynonyms;
  36. if (nonSynonyms == null) nonSynonyms = new ArrayList();
  37. nonUmbrellas = papa.nonUmbrellas;
  38. if (nonUmbrellas == null) nonUmbrellas = new TreeMap();
  39. overlaps = papa.overlaps;
  40. if (overlaps == null) overlaps = new TreeMap();
  41. nonOverlaps = papa.nonOverlaps;
  42. if (nonOverlaps == null) nonOverlaps = new TreeMap();
  43. if (!nonTerms.contains("no__term")) {
  44. nonTerms.add("no__term");
  45. }
  46. userDefinedProperties = papa.ctxt.userDefinedProperties;
  47. dyadsUndefined = (DyadTMap)papa.dyadsUndefined.clone();
  48. dyadsDefined = (DyadTMap)papa.dyadsDefined.clone();
  49. wiseGuy.synonyms = papa.synonyms;
  50. wiseGuy.umbrellas = papa.umbrellas;
  51. wiseGuy.overlaps = papa.overlaps;
  52. // Loop thru Context.LearningHistory. Post all rejected-prop-defs to rejectedDefs
  53. TreeMap<String, ArrayList<Context.HistoryItem>> history;
  54. history = (addressTerms ? ctxt.learningHistoryAdr : ctxt.learningHistoryRef);
  55. if (history != null) {
  56. Iterator hIter = history.entrySet().iterator();
  57. while (hIter.hasNext()) {
  58. Map.Entry<String, ArrayList<Context.HistoryItem>> entry =
  59. (Map.Entry<String, ArrayList<Context.HistoryItem>>)hIter.next();
  60. String kinTerm = entry.getKey();
  61. ArrayList<Context.HistoryItem> items = entry.getValue();
  62. for (Context.HistoryItem hi : items) {
  63. if (hi instanceof Context.RejectedPropDefPtr && ! hi.rescinded) {
  64. Context.RejectedPropDefPtr reject = (Context.RejectedPropDefPtr)hi;
  65. ProposedDef propDef = new ProposedDef();
  66. // Give this PropDef only enough data to create a match in DT.findKTMatches
  67. propDef.ktd = new KinTermDef(reject.eqcProtoKinTerm);
  68. propDef.ktd.domTh = new DomainTheory(reject.eqcProtoLangName);
  69. if (rejectedDefs.get(kinTerm) == null) {
  70. rejectedDefs.put(kinTerm, new ArrayList<Object>());
  71. }
  72. ((ArrayList<Object>)rejectedDefs.get(kinTerm)).add(propDef);
  73. } // end of we-got-a-hit
  74. } // end of for-loop thru History Items
  75. } // end of iteration
  76. }
  77. } // end of principle constructor
  78. public boolean allDone(int minDyadsPerPCStr, DomainTheory sourceDT) {
  79. Iterator iter = sourceDT.theory.values().iterator();
  80. while (iter.hasNext()) {
  81. KinTermDef ktd = (KinTermDef) iter.next();
  82. if (printableTerm(ktd) && theory.get(ktd.kinTerm) == null) {
  83. return false;
  84. }
  85. }
  86. return true;
  87. } // end of method allDone
  88. public void learnKinTermLGG(String kinTerm, int maxNoise, int ignorable)
  89. throws KSInternalErrorException, KSParsingErrorException, KSBadHornClauseException, KSNoChainOfRelations2Alter,
  90. KSConstraintInconsistency, ClassNotFoundException, JavaSystemException, FileNotFoundException, IOException {
  91. if (kinTerm.equals("no__term")) {
  92. return; // Don't consider dyads that define 'out-of-bounds' for all kinTerms
  93. }
  94. if (theory.containsKey(kinTerm)) {
  95. return; // Don't consider already-defined terms -- wait until accepted def is rescinded.
  96. }
  97. Library.CB_Ptr.clearCache();
  98. Library.KTD_Ptr.clearCacheDTs();
  99. TreeMap pos = MainPane.treeMapDeepCopy((TreeMap) dyadsUndefined.get(kinTerm)),
  100. neg = makeNEG(kinTerm, pos);
  101. if (countLeaves(neg) < 12) {
  102. return; // there aren't enough terms to make negative examples.
  103. }
  104. ArrayList<Object> solution = new ArrayList<Object>(),
  105. pos2Cover = harvestLeaves(pos),
  106. negTokensCovered = new ArrayList<Object>(),
  107. anomalies = new ArrayList<Object>(),
  108. barriers = new ArrayList<Object>(),
  109. octuple = null;
  110. int maxMisses = (int) Math.floor(countLeaves(pos) * ignorable / 100d);
  111. System.out.println("Inducing " + kinTerm);
  112. KinTermDef composedKTD = new KinTermDef();
  113. composedKTD.kinTerm = kinTerm;
  114. composedKTD.domTh = this;
  115. composedKTD.composed = true;
  116. try { // if induction bombs out, just fail on this try. Don't halt entire test.
  117. tempFlag = true;
  118. if (induceSolution(solution, pos, neg, pos2Cover, negTokensCovered, barriers, maxMisses, composedKTD)) {
  119. simplifyCBs(solution, composedKTD);
  120. octuple = tidyUpSolution(kinTerm, solution, composedKTD, pos2Cover, negTokensCovered, this);
  121. proposeDefinition(kinTerm, octuple);
  122. }
  123. tempFlag = false;
  124. // if (kinTerm.equals("ancestor")) Context.breakpoint();
  125. if (octuple == null && Library.errorCorrectionOn) { // EC is on. Try to identify noise.
  126. maxMisses = (int) Math.floor(countLeaves(pos) * maxNoise / 100d);
  127. if (induceSolution(solution, pos, neg, pos2Cover, negTokensCovered, barriers, maxMisses, composedKTD)) {
  128. octuple = tidyUpSolution(kinTerm, solution, composedKTD, pos2Cover, negTokensCovered, this);
  129. Anomaly anomaly = makeAnomaly(kinTerm, octuple, ignorable, pos, neg);
  130. if (anomaly != null) {
  131. anomalies.add(anomaly);
  132. }
  133. }
  134. }
  135. } catch (Exception exc) {
  136. String warning = "\n*********************************************************************";
  137. warning += "\n*\tWhile Inducing " + kinTerm + ", hit fatal error.";
  138. warning += "\n*\t" + exc;
  139. warning += "\n*\tOctuple = " + octuple + ". solution = " + solution;
  140. warning += "\n*********************************************************************";
  141. System.out.println(warning);
  142. }
  143. if (anomalies.size() > 0) {
  144. postAnomaliesForUser(kinTerm, anomalies); // improve next round
  145. }
  146. if (Library.synUmbDetectOn) {
  147. detectSynonymsAndUmbrellas(kinTerm, pos, neg, maxNoise);
  148. }
  149. Context.current = ctxt;
  150. } // end of method learnKinTermLGG
  151. public void learnKinTerm(String kinTerm, int maxNoise, int ignorable, int maxConf, DomainTheory sourceDT)
  152. throws KSInternalErrorException, KSParsingErrorException, KSBadHornClauseException, KSNoChainOfRelations2Alter,
  153. KSConstraintInconsistency, ClassNotFoundException, JavaSystemException, FileNotFoundException, IOException {
  154. // NOTE: Before this method is called on a Context Under Construction, dt.resolveSynonymsInDyads MUST be called.
  155. if (kinTerm.equals("no__term")) {
  156. return; // Don't consider dyads that define 'out-of-bounds' for all kinTerms
  157. }
  158. // if (kinTerm.equals("uncle")) {
  159. // Context.breakpoint();
  160. // }
  161. if (theory.containsKey(kinTerm)) {
  162. return; // Don't consider already-defined terms -- wait until accepted def is rescinded.
  163. }
  164. if (Library.cbIndex == null) {
  165. BufferedReader file = new BufferedReader(new FileReader(Library.libraryDirectory + "ClauseIndex"));
  166. Library.cbIndex = new Library.ClauseIndex(file);
  167. }
  168. if (Library.baseCBIndex == null && doBaseCBs) {
  169. BufferedReader file = new BufferedReader(new FileReader(Library.libraryDirectory + "BaseCBIndex"));
  170. Library.baseCBIndex = new Library.ClauseIndex(file);
  171. }
  172. if (Library.cbCounts == null) {
  173. Library.ClauseCounts.loadFromDisk();
  174. }
  175. Library.CB_Ptr.clearCache();
  176. Library.KTD_Ptr.clearCacheDTs();
  177. ArrayList<Object> solidCBMatches = new ArrayList<Object>(), potFalseNeg = new ArrayList<Object>(), potFalsePos = new ArrayList<Object>(),
  178. solidKTMatches = new ArrayList<Object>(), anomalies = new ArrayList<Object>(), noisyKTMatches = new ArrayList<Object>();
  179. // POS & NEG = the positive and negative examples of this kinship concept
  180. TreeMap pos = MainPane.treeMapDeepCopy((TreeMap) dyadsUndefined.get(kinTerm)),
  181. neg = makeNEG(kinTerm, pos);
  182. if (countLeaves(neg) < 12) {
  183. String msg = "SILKin aborted learning " + kinTerm + " because there are\n";
  184. msg += "not enough negative examples (dyads for OTHER kin terms).";
  185. JOptionPane.showMessageDialog(null, msg,
  186. "SILKin learning module failure", JOptionPane.ERROR_MESSAGE);
  187. MainPane.activity.log.append(msg);
  188. return; // there aren't enough terms to make negative examples.
  189. }
  190. Library.ClauseIndex cbEQCs = Library.cbIndex;
  191. Counter maxDist = new Counter();
  192. TreeMap candidates = findCandidates(cbEQCs, pos, Library.cbCounts, sourceDT, maxDist); // candidates is exactStr -> List of CB_EQCs
  193. evalCandidates(candidates, solidCBMatches, potFalseNeg, potFalsePos, pos, neg, maxNoise);
  194. findKTMatches(kinTerm, solidCBMatches, potFalseNeg, potFalsePos, pos, neg, maxNoise, ignorable,
  195. solidKTMatches, noisyKTMatches, anomalies, rejectedDefs);
  196. if (solidKTMatches.size() > 0) {
  197. dataSelection(kinTerm, solidKTMatches, pos, neg, dataReqCounter); // best result
  198. } else { // if we have a solid match, then anomalies & noise may not be real. Else, both are.
  199. if (noisyKTMatches.size() > 0) {
  200. dataSelection(kinTerm, noisyKTMatches, pos, neg, dataReqCounter); // 2nd best
  201. } else if (doBaseCBs) { // try to compose a KTD from BaseCBs
  202. ArrayList<Object> baseCB_Matches = findBaseCBMatches(kinTerm, solidCBMatches, potFalseNeg, pos, neg, anomalies,
  203. ignorable, maxConf, maxDist, sourceDT, doInduction, this);
  204. if (baseCB_Matches != null) {
  205. proposeDefinition(kinTerm, baseCB_Matches); // 3rd best
  206. } else if (Library.errorCorrectionOn) {
  207. baseCB_Matches = findBaseCBMatches(kinTerm, solidCBMatches, potFalseNeg, pos, neg, anomalies,
  208. maxNoise, ignorable, maxDist, sourceDT, doInduction, this);
  209. if (baseCB_Matches != null) {
  210. Anomaly anomaly = makeAnomaly(kinTerm, baseCB_Matches, ignorable, pos, neg);
  211. if (anomaly != null) {
  212. anomalies.add(anomaly); // 4th best
  213. }
  214. }
  215. }
  216. } // end of doBaseCBs
  217. if (anomalies.size() > 0) {
  218. postAnomaliesForUser(kinTerm, anomalies); // improve next round
  219. }
  220. }
  221. detectSynonymsAndUmbrellas(kinTerm, pos, neg, maxNoise); // always
  222. Context.current = ctxt;
  223. } // end of method learnKinTerm
  224. public void processSuggestions(int round, int subRound, DomainTheory sourceDT, int maxNoise,
  225. int ignorable, int minDyadsPerPCStr)
  226. throws KSBadHornClauseException, KSInternalErrorException, KSConstraintInconsistency, ClassNotFoundException, KinshipSystemException,
  227. KSParsingErrorException, JavaSystemException, KSInternalErrorException, FileNotFoundException, IOException {
  228. // issuesForUser = a TreeMap: kinTerm => List of Issues
  229. // 1. If any Issues are generated:
  230. // a. Test suggested definitions against the real answer. Accept if 100% right. If the proposed def is
  231. // a sub-set of the right answer, generate NUMBER_OF_EGOS dyads from outside the subset. If accepted, post records to
  232. // the Learned_DT showing the number of dyads used, amount of noise, round#, etc.
  233. // b. Challenged dyads will be corrected if the Oracle's records show them to be noise. Else, they're validated.
  234. // c. Proposals of synonyms and umbrellas will be evaluated piece-wise: e.g. if "grandparent" is proposed as an
  235. // umbrella term encompassing "grandfather" and "granxfathar" confirm the relationship for
  236. // "grandfather" but correct the dyads which led to the incorrect suggestion that "granxfathar" is a valid
  237. // kinTerm. (Assumption: User will recognize a bogus dyad when it is highlighted in any context.) In other words,
  238. // give partial credit for proposing partly-correct relationships.
  239. // d. Data Requests will trigger creation of a single validated dyad for the kin type requested. It will provide
  240. // the correct kinTerm if one exists. Otherwise it will assign the special kinTerm "no__term" to indicate that
  241. // the target language does not have any term for that kin type.
  242. // 2. If any Issues were generated besides Data Requests, launch a sub-round with just the responses to these
  243. // suggestions (no new interview dyads). i.e. go back to Step 1 with just the dyads generated by the suggestions.
  244. boolean anotherRound = false, result;
  245. String roundLearned = "" + round + "." + subRound;
  246. Iterator issuIter = issuesForUser.entrySet().iterator();
  247. ArrayList<Object> lrndCompDefs = new ArrayList<Object>();
  248. while (issuIter.hasNext()) {
  249. Map.Entry entry = (Map.Entry) issuIter.next();
  250. String kinTerm = (String) entry.getKey();
  251. ArrayList<Object> issueList = (ArrayList<Object>) entry.getValue();
  252. // if (kinTerm.equals("aiya")) Context.breakpoint();
  253. while (issueList.size() > 0) {
  254. Issue issue = (Issue) issueList.remove(0);
  255. issue.removeChallengedDyads();
  256. // 2 next lines caused umbrella for single-kintype to be missed. 7/5/07
  257. // SynonymCandidate syn = swapSingleUmbrella(issue);
  258. // if (syn != null) issue = syn;
  259. if (issue.stillViable) {
  260. if (issue instanceof ProposedDef) {
  261. ProposedDef propDef = (ProposedDef) issue;
  262. KinTermDef realDef = (KinTermDef) sourceDT.theory.get(kinTerm);
  263. if (propDef.sameAs(realDef)) { // BINGO
  264. theory.put(kinTerm, realDef);
  265. clearAllButDiscriminators(issueList); // All others are unnecessary now.
  266. // validateNewDyads checks for noise, moves dyads to DyadsDefined, & returns any Anomalies
  267. ArrayList<Object> validationIssues = validateNewDyads(kinTerm, 100);
  268. issueList.addAll(validationIssues);
  269. ArrayList<Object> lrnRec = new ArrayList<Object>();
  270. lrnRec.add("Def: " + kinTerm + " = ");
  271. lrnRec.add(propDef.ktd.domTh.languageName + ":" + propDef.ktd.kinTerm);
  272. postLrnHist(roundLearned, lrnRec);
  273. ctxt.featuresHaveChanged = true;
  274. anotherRound = true;
  275. } else if (realDef == null) { // this 'kinTerm' is just noise
  276. if (Library.errorCorrectionOn) {
  277. TreeMap bogusPOS = (TreeMap) dyadsUndefined.get(kinTerm);
  278. Iterator bogusIter = bogusPOS.values().iterator();
  279. while (bogusIter.hasNext()) {
  280. ArrayList<Object> badDys = (ArrayList<Object>) bogusIter.next();
  281. for (int i = 0; i < badDys.size(); i++) { // scan for noise dyads
  282. Dyad badDy = (Dyad) badDys.get(i),
  283. goodDy = wiseGuy.correction(badDy, this, sourceDT, roundLearned);
  284. if (goodDy == null) {
  285. throw new KSInternalErrorException("A dyad for a 'noise-term' was not corrected.");
  286. }
  287. } // end of loop thru badDys
  288. } // end of loop thru kinTypes of this noise term
  289. }
  290. issueList.clear(); // case closed.
  291. } else {
  292. ArrayList<Object> egoBag = ctxt.getPair(); // 1 male + 1 female ego
  293. propDef.refute(egoBag, sourceDT, this); // makes dyads to refute
  294. System.out.println("\n\n**** REJECTED " + propDef);
  295. ArrayList<Object> lrnRec = new ArrayList<Object>();
  296. lrnRec.add("Data Request - Refutation for : " + kinTerm + ". Up to ");
  297. lrnRec.add(MainPane.NUMBER_OF_EGOS);
  298. lrnRec.add(" dyads.");
  299. postLrnHist(roundLearned, lrnRec);
  300. if (rejectedDefs.get(kinTerm) == null) {
  301. rejectedDefs.put(kinTerm, new ArrayList<Object>());
  302. }
  303. ArrayList<Object> rejects = (ArrayList<Object>) rejectedDefs.get(kinTerm);
  304. rejects.add(propDef);
  305. anotherRound = true;
  306. }
  307. } else if (issue instanceof ComposedDef) {
  308. ComposedDef compDef = (ComposedDef) issue;
  309. KinTermDef realDef = (KinTermDef) sourceDT.theory.get(kinTerm);
  310. if (realDef != null && compDef.sameAs(realDef, ignorable, this, sourceDT, roundLearned)) { // BINGO
  311. makeCompDefDiscriminators(compDef, realDef, issueList);
  312. clearAllButDiscriminators(issueList); // All others are unnecessary now.
  313. acceptCompDef(compDef);
  314. String defType = (compDef.languagesUsed.contains("LGG_Induction") ? "CompDef-Induced: " : "CompDef-Pure: ");
  315. ArrayList<Object> lrnRec = new ArrayList<Object>();
  316. lrnRec.add(defType + kinTerm);
  317. int numCBs = compDef.cbsUsed.size(),
  318. numLangs = compDef.languagesUsed.size();
  319. String pl1 = (numCBs > 1 ? "s" : ""),
  320. pl2 = (numLangs > 1 ? "s" : "");
  321. lrnRec.add(" = " + numCBs + " clause" + pl1 + " from " + numLangs + " language" + pl2);
  322. postLrnHist(roundLearned, lrnRec);
  323. lrndCompDefs.add(compDef);
  324. ctxt.featuresHaveChanged = true;
  325. anotherRound = true;
  326. }
  327. } else if (issue instanceof Anomaly) {
  328. result = ((Anomaly) issue).correctOrValidate(this, sourceDT, roundLearned, ignorable);
  329. if (result) {
  330. anotherRound = true;
  331. }
  332. } else if (issue instanceof DataRequest) {
  333. DataRequest disc = (DataRequest) issue;
  334. int num = Math.min(3, disc.relatedCB_Ptrs.size());
  335. num *= MainPane.NUMBER_OF_EGOS;
  336. disc.buildDiscrimDyads(this, sourceDT);
  337. ArrayList<Object> lrnRec = new ArrayList<Object>();
  338. lrnRec.add("Data Request - Discriminators for : " + kinTerm + ". Up to ");
  339. lrnRec.add(num);
  340. lrnRec.add(" dyads.");
  341. anotherRound = true;
  342. postLrnHist(roundLearned, lrnRec);
  343. } else if (issue instanceof SynonymCandidate) {
  344. result = ((SynonymCandidate) issue).correctOrValidate(this, sourceDT, roundLearned);
  345. if (result) {
  346. anotherRound = true;
  347. }
  348. } else if (issue instanceof OverlapCandidate) {
  349. result = ((OverlapCandidate) issue).correctOrValidate(this, sourceDT, roundLearned);
  350. if (result) {
  351. anotherRound = true;
  352. }
  353. } else if (issue instanceof UmbrellaCandidate) {
  354. result = (((UmbrellaCandidate) issue).correctOrValidate(this, sourceDT, roundLearned));
  355. if (result) {
  356. anotherRound = true;
  357. }
  358. } // end of brilliant processing of issues
  359. } // end of still-viable
  360. } // end of while-issueList.size() > 0
  361. issuIter.remove();
  362. } // end of issue-iterator
  363. validateSynonymsAndUmbrellas();
  364. if (lrndCompDefs.size() > 0) {
  365. System.out.println("\n\t\t******** Composed Definitions *********");
  366. }
  367. for (int i = 0; i < lrndCompDefs.size(); i++) {
  368. ComposedDef compDef = (ComposedDef) lrndCompDefs.get(i);
  369. if (!theory.containsKey(compDef.ktd.kinTerm)) {
  370. Context.breakpoint();
  371. }
  372. System.out.println(compDef.ktd.eqcSigExact);
  373. System.out.println(compDef.toString() + "\nBase Clauses:");
  374. for (int j = 0; j < compDef.ktd.definitions.size(); j++) {
  375. System.out.println(((ClauseBody) compDef.ktd.definitions.get(j)).toThyString());
  376. }
  377. if (compDef.auxiliaries.size() > 0) {
  378. System.out.println("\nAuxiliaries:");
  379. }
  380. for (int j = 0; j < compDef.auxiliaries.size(); j++) {
  381. System.out.println(((KinTermDef) compDef.auxiliaries.get(j)).toString(3));
  382. }
  383. System.out.println("\n");
  384. } // end of loop thru compDefs
  385. if (anotherRound) {
  386. int subRdNext = subRound + 1;
  387. if (subRdNext >= 12) {
  388. return;
  389. }
  390. System.out.println("*** Round " + round + "." + subRdNext);
  391. int maxConf = (subRdNext < 5 ? 99 : MainPane.NUMBER_OF_EGOS);
  392. MainPane.topPane.doLv1ActiveLearning(this, maxNoise, ignorable, maxConf, minDyadsPerPCStr, sourceDT);
  393. printSuggestions("" + round + "." + subRdNext);
  394. processSuggestions(round, subRdNext, sourceDT, maxNoise, ignorable, minDyadsPerPCStr);
  395. }
  396. } // end of method processSuggestions
  397. public void clearAllButDiscriminators(ArrayList<Object> issueList) {
  398. // Remove all issues except Discriminators (right after accepting a definition)
  399. Iterator iter = issueList.iterator();
  400. while (iter.hasNext()) {
  401. Issue issue = (Issue) iter.next();
  402. if (!(issue instanceof DataRequest)) {
  403. iter.remove();
  404. }
  405. }
  406. } // end of method clearAllButDiscriminators
  407. public void makeCompDefDiscriminators(ComposedDef compDef, KinTermDef realDef,
  408. ArrayList<Object> issueList) throws KSInternalErrorException, JavaSystemException {
  409. // A composed Def may cover more kinTypes than have been seen yet -- or more than necessary.
  410. // Build Discriminators for up to 3 'nearby' kinTypes not yet seen that are within the approximate
  411. // string distance found on covered dyads seen so far.
  412. // If the realDef covers some KTs that the CompDef doesn't, build Discriminators for up to 6 of those
  413. // if they are no longer than Library.maxExpansionStringDist.
  414. // if (compDef.kinTerm.equals("mavsa")) Context.breakpoint();
  415. TreeMap dyUndefTM = (TreeMap) dyadsUndefined.get(compDef.ktd.kinTerm); // PC_Str => ArrayList<Object> of dyads
  416. ArrayList<Object> seenSoFar = new ArrayList<Object>(dyUndefTM.keySet()),
  417. questions = new ArrayList<Object>();
  418. ArrayList<Library.CB_Ptr> cbPtrs = new ArrayList<Library.CB_Ptr>();
  419. for (int i = 0; i < compDef.negsCovered.size(); i++) {
  420. String kType = (String) ((Dyad) compDef.negsCovered.get(i)).kinTerm;
  421. if (!seenSoFar.contains(kType)) {
  422. seenSoFar.add(kType);
  423. }
  424. }
  425. int longestSeen = 0;
  426. for (int i = 0; i < seenSoFar.size(); i++) {
  427. String kType = (String) seenSoFar.get(i);
  428. if (kType.length() > longestSeen) {
  429. longestSeen = kType.length();
  430. }
  431. }
  432. // Look for KTs covered by CompDef's CBs but not yet seen
  433. TreeMap proposedCoverageSorter = new TreeMap(); // length => ArrayList<Object> of CBs
  434. for (int i = 0; i < compDef.origXCBs.size(); i++) {
  435. ClauseBody expCB = (ClauseBody) compDef.origXCBs.get(i);
  436. if (!seenSoFar.contains(expCB.pcString)
  437. && expCB.pcString.length() <= longestSeen + 2) {
  438. Integer len = new Integer(expCB.pcString.length());
  439. if (proposedCoverageSorter.get(len) == null) {
  440. proposedCoverageSorter.put(len, new ArrayList<Object>());
  441. }
  442. ArrayList<Object> lst = (ArrayList<Object>) proposedCoverageSorter.get(len);
  443. lst.add(expCB);
  444. } // found a kin type not yet seen about same length as those seen
  445. } // end of loop thru original Expanded Defs
  446. if (proposedCoverageSorter.size() > 0) {
  447. Iterator iter = proposedCoverageSorter.values().iterator();
  448. int count = 0;
  449. while (iter.hasNext() && count < 3) {
  450. ArrayList<Object> lst = (ArrayList<Object>) iter.next();
  451. for (int i = 0; i < lst.size() && count < 3; i++) {
  452. // Require that discriminator dyads are within Library.maxExpansionStringDist
  453. ClauseBody disCB = (ClauseBody) lst.get(i);
  454. int stringDist = Math.min(Math.max((disCB.pcString.length() / 2) - 1, 0), Library.ClauseCounts.maxDist);
  455. if (stringDist < Library.maxExpansionStringDist && disCB.level < Library.maxLevelForExpansion) {
  456. count++;
  457. cbPtrs.add(new Library.CB_Ptr(disCB));
  458. }
  459. }
  460. } // end of loop thru proposedCoverageSorter.values
  461. } // end of proposedCoverageSorter.size > 0
  462. // Look for KTs covered by actual def'n but not covered by the CompDef. I.E. answer the
  463. // standard confirmation question:
  464. // "Are there any other people called by this kinTerm that do not fit this definition?"
  465. TreeMap actualCoverageSorter = new TreeMap(); // length => ArrayList<Object> of CBs
  466. for (int i = 0; i < realDef.expandedDefs.size(); i++) {
  467. ClauseBody expCB = (ClauseBody) realDef.expandedDefs.get(i);
  468. String kinType = expCB.pcString;
  469. Integer len = new Integer(kinType.length());
  470. ArrayList<Object> propCovers = (ArrayList<Object>) proposedCoverageSorter.get(len);
  471. if (!seenSoFar.contains(expCB.pcString)
  472. && (propCovers == null || !propCovers.contains(kinType))) {
  473. if (actualCoverageSorter.get(len) == null) {
  474. actualCoverageSorter.put(len, new ArrayList<Object>());
  475. }
  476. ArrayList<Object> lst = (ArrayList<Object>) actualCoverageSorter.get(len);
  477. lst.add(expCB);
  478. } // found a kin type not covered by proposed definition
  479. } // end of loop thru realDef's Expanded Defs
  480. if (actualCoverageSorter.size() > 0) {
  481. Iterator iter = actualCoverageSorter.values().iterator();
  482. int count = 0;
  483. while (iter.hasNext() && count < 6) {
  484. ArrayList<Object> lst = (ArrayList<Object>) iter.next();
  485. for (int i = 0; i < lst.size() && count < 6; i++) {
  486. ClauseBody disCB = (ClauseBody) lst.get(i);
  487. int stringDist = Math.min(Math.max((disCB.pcString.length() / 2) - 1, 0), Library.ClauseCounts.maxDist);
  488. if (stringDist < Library.maxExpansionStringDist && disCB.level < Library.maxLevelForExpansion) {
  489. count++;
  490. cbPtrs.add(new Library.CB_Ptr(disCB));
  491. }
  492. }
  493. } // end of loop thru actualCoverageSorter.values
  494. } // end of actualCoverageSorter.size > 0
  495. if (cbPtrs.size() > 0) {
  496. questions.add("These kin types, not yet seen in your data, may or may not belong in this definition. "
  497. + "Please gather some data about these.");
  498. DataRequest disc = new DataRequest(compDef.kinTerm, questions, cbPtrs);
  499. issueList.add(disc);
  500. }
  501. } // end of method makeCompDefDiscriminators
  502. public void acceptCompDef(ComposedDef compDef) throws KSParsingErrorException, ClassNotFoundException,
  503. KSInternalErrorException, KSConstraintInconsistency, KSBadHornClauseException {
  504. if (compDef.auxiliaries.size() > 0) {
  505. if (!nonTermFlags.contains("aux")) {
  506. nonTermFlags.add("aux");
  507. }
  508. if (!nonTermFlags.contains("temp_aux")) {
  509. nonTermFlags.add("temp_aux");
  510. }
  511. }
  512. String kinTerm = compDef.ktd.kinTerm;
  513. Counter cntr = new Counter();
  514. // We previously posted aux's (under "temp_aux" names) to theory for expansion purposes
  515. Iterator iter = compDef.auxiliaries.iterator();
  516. while (iter.hasNext()) {
  517. KinTermDef auxKTD = (KinTermDef) iter.next();
  518. theory.remove(auxKTD.kinTerm);
  519. }
  520. // There could be some auxes left over from prior attempts
  521. iter = theory.keySet().iterator();
  522. while (iter.hasNext()) {
  523. String predName = (String) iter.next();
  524. if (predName.indexOf(kinTerm + "<aux>") > -1 || predName.indexOf(kinTerm + "<temp_aux>") > -1) {
  525. iter.remove();
  526. }
  527. }
  528. simplifyAuxs(compDef.ktd, compDef.auxiliaries);
  529. renameAuxPreds(compDef.auxiliaries, compDef.ktd, kinTerm, "aux", cntr);
  530. compDef.ktd.simplifyClauses();
  531. TreeMap unDefTM = (TreeMap) dyadsUndefined.remove(compDef.ktd.kinTerm); // PC_Str => ArrayList<Object> of dyads
  532. if (dyadsDefined == null) {
  533. dyadsDefined = new DyadTMap();
  534. }
  535. dyadsDefined.put(compDef.ktd.kinTerm, unDefTM);
  536. // Unify Variables on all these freshly-minted definitions
  537. for (int i = 0; i < compDef.ktd.expandedDefs.size(); i++) {
  538. ((ClauseBody) compDef.ktd.expandedDefs.get(i)).unifyVariables();
  539. }
  540. for (int i = 0; i < compDef.auxiliaries.size(); i++) {
  541. KinTermDef auxKTD = (KinTermDef) compDef.auxiliaries.get(i);
  542. for (int j = 0; j < auxKTD.expandedDefs.size(); j++) {
  543. ((ClauseBody) auxKTD.expandedDefs.get(j)).unifyVariables();
  544. } // end of loop thru expanded Defs
  545. } // end of loop theu auxiliary KTDs
  546. if (theory.containsKey(compDef.ktd.kinTerm)) {
  547. Context.breakpoint();
  548. }
  549. addTerm(compDef.ktd);
  550. compDef.ktd.composed = true;
  551. } // end of method acceptCompDef
  552. public void renameAuxPreds(ArrayList<Object> auxiliaries, KinTermDef compKTD, String kinTerm, String tag, Counter cntr)
  553. throws KSParsingErrorException, ClassNotFoundException, KSInternalErrorException,
  554. KSConstraintInconsistency, KSBadHornClauseException {
  555. if (auxiliaries.isEmpty()) {
  556. return;
  557. }
  558. String[] oldNames = new String[auxiliaries.size()],
  559. newNames = new String[auxiliaries.size()];
  560. int colon, auxNmbr = 0;
  561. Iterator iter = auxiliaries.iterator();
  562. while (iter.hasNext()) {
  563. KinTermDef aux = (KinTermDef) iter.next();
  564. String oldPredName = (String) ((ClauseBody) aux.expandedDefs.get(0)).expansionPath.get(0);
  565. colon = oldPredName.indexOf(":");
  566. oldPredName = oldPredName.substring(0, colon);
  567. oldNames[auxNmbr] = oldPredName;
  568. // Temporarily stop checking for duplication of auxiliaries. Let each CompDef have its
  569. // own complete set.
  570. // String existingAuxName = auxPreds.newNameOf(aux);
  571. // if (existingAuxName != null) {
  572. // iter.remove(); // duplicates an existing auxiliary
  573. // newNames[auxNmbr] = existingAuxName;
  574. // }else {
  575. cntr.incr(); // cntr = serial number of this auxiliary
  576. aux.kinTerm = kinTerm + "[" + tag + "]" + (cntr.total());
  577. newNames[auxNmbr] = aux.kinTerm;
  578. Predicate headPred = new Predicate(aux.kinTerm);
  579. headPred.category = new CulturalCategory();
  580. aux.clauseHead = new Literal(headPred, new Variable("Alter"), new Variable("Ego"));
  581. if (aux.flags == null) {
  582. aux.flags = new ArrayList<Object>();
  583. }
  584. if (!aux.flags.contains(tag)) {
  585. aux.flags.add(tag);
  586. }
  587. addTerm(aux);
  588. // } // end of else-not-duplicate
  589. auxNmbr++;
  590. }
  591. for (int i = 0; i < auxNmbr; i++) {
  592. auxPreds.addAux(kinTerm, oldNames[i], newNames[i]);
  593. }
  594. for (int i = 0; i < compKTD.definitions.size(); i++) {
  595. ClauseBody bcb = (ClauseBody) compKTD.definitions.get(i);
  596. for (int j = 0; j < bcb.body.size(); j++) {
  597. Literal lit = (Literal) bcb.body.get(j);
  598. for (int k = 0; k < auxNmbr; k++) {
  599. if (lit.predicate.name.equals(oldNames[k])) {
  600. lit.predicate.name = newNames[k];
  601. k = oldNames.length; // end the loop
  602. }
  603. }
  604. } // end of loop thru literals in base clause
  605. } // end of loop thru base clauses
  606. for (int i = 0; i < compKTD.expandedDefs.size(); i++) {
  607. ClauseBody xcb = (ClauseBody) compKTD.expandedDefs.get(i);
  608. for (int j = 0; j < xcb.expansionPath.size(); j++) {
  609. String expansion = (String) xcb.expansionPath.get(j);
  610. colon = expansion.indexOf(":");
  611. if (expansion.length() > 5 && expansion.substring(0, 4).equals("(not")) {
  612. Context.breakpoint();
  613. }
  614. if (colon > 0) {
  615. for (int k = 0; k < auxNmbr; k++) {
  616. if (expansion.substring(0, colon).equals(oldNames[k])) {
  617. xcb.expansionPath.set(j, newNames[k] + expansion.substring(colon));
  618. k = auxNmbr;
  619. }
  620. }
  621. }
  622. } // end of loop thru expansionPath
  623. } // end of loop thru Expanded Def clauses
  624. for (int i = 0; i < auxiliaries.size(); i++) {
  625. KinTermDef aux = (KinTermDef) auxiliaries.get(i);
  626. for (int j = 0; j < aux.expandedDefs.size(); j++) {
  627. ClauseBody cb = (ClauseBody) aux.expandedDefs.get(j);
  628. for (int k = 0; k < cb.expansionPath.size(); k++) {
  629. String expansion = (String) cb.expansionPath.get(k);
  630. colon = expansion.indexOf(":");
  631. for (int nam = 0; nam < auxNmbr; nam++) {
  632. if (expansion.substring(0, colon).equals(oldNames[nam])) {
  633. cb.expansionPath.set(k, newNames[nam] + expansion.substring(colon));
  634. nam = auxNmbr;
  635. }
  636. } // end of loop thru old & new names
  637. } // end of loop thru expansionPath
  638. } // end of loop thru expandedDefs
  639. for (int auxBCB = 0; auxBCB < aux.definitions.size(); auxBCB++) {
  640. ClauseBody bcb = (ClauseBody) aux.definitions.get(auxBCB);
  641. for (int j = 0; j < bcb.body.size(); j++) {
  642. Literal lit = (Literal) bcb.body.get(j);
  643. for (int k = 0; k < auxNmbr; k++) {
  644. if (lit.predicate.name.equals(oldNames[k])) {
  645. lit.predicate.name = newNames[k];
  646. k = auxNmbr; // end the loop
  647. }
  648. }
  649. } // end of loop thru literals in base clause
  650. } // end of loop thru aux's base clauses
  651. } // end of auxiliary processing
  652. } // end of method renameAuxPreds
  653. public void retractDef(String kinTerm) {
  654. // Retract this proposed definition; it has been disproved.
  655. // Remove it & all its auxilliaries from this LearnedDT
  656. theory.remove(kinTerm);
  657. Iterator iter = theory.keySet().iterator();
  658. while (iter.hasNext()) {
  659. String kTerm = (String) iter.next();
  660. if (kTerm.indexOf(kinTerm + "<aux>") > -1) {
  661. iter.remove();
  662. }
  663. }
  664. TreeMap oldDefDyads = (TreeMap) dyadsDefined.remove(kinTerm),
  665. oldUnDefDyads = (TreeMap) dyadsUndefined.remove(kinTerm);
  666. dyadsUndefined.put(kinTerm, mergeTrees(oldDefDyads, oldUnDefDyads));
  667. auxPreds.retract(kinTerm);
  668. } // end of method retractDef
  669. public void printSuggestions(String rnd) throws KSParsingErrorException, JavaSystemException,
  670. KSInternalErrorException, KSConstraintInconsistency {
  671. Iterator issuIter = issuesForUser.entrySet().iterator();
  672. if (issuIter.hasNext()) {
  673. System.out.println("\n\n*** ISSUES IDENTIFIED in Round " + rnd + " ***");
  674. }
  675. while (issuIter.hasNext()) {
  676. Map.Entry entry = (Map.Entry) issuIter.next();
  677. ArrayList<Object> issueList = (ArrayList<Object>) entry.getValue();
  678. for (int i = 0; i < issueList.size(); i++) {
  679. Issue issue = (Issue) issueList.get(i);
  680. if (issue.stillViable) {
  681. issue.presentToUser();
  682. }
  683. }
  684. }
  685. } // end of method printSuggestions
  686. public int postNoiseCounts(int roundNmbr, int oldTotal) {
  687. int cumTotalNoise = countLeaves(wiseGuy.noiseFacts);
  688. ArrayList<Object> noiseRec = new ArrayList<Object>();
  689. noiseRec.add("Noise created: ");
  690. noiseRec.add(new Integer(cumTotalNoise - oldTotal));
  691. noiseRec.add(" dyads.");
  692. postLrnHist("" + roundNmbr + ".0", noiseRec);
  693. return cumTotalNoise;
  694. } // end of method postNoiseCounts
  695. public void postLrnHist(String roundLearned, Object learningRecord) {
  696. ArrayList<Object> pair = parseRound(roundLearned); // { Rnd, SubRnd }
  697. Integer rnd = (Integer) pair.get(0),
  698. sub = (Integer) pair.get(1);
  699. if (learningHistory.get(rnd) == null) {
  700. learningHistory.put(rnd, new TreeMap());
  701. }
  702. TreeMap rndTree = (TreeMap) learningHistory.get(rnd);
  703. if (rndTree.get(sub) == null) {
  704. rndTree.put(sub, new ArrayList<Object>());
  705. }
  706. ArrayList<Object> thisRound = (ArrayList<Object>) rndTree.get(sub);
  707. thisRound.add(learningRecord);
  708. } // end of method postLrnHist
  709. ArrayList<Object> parseRound(String round) {
  710. int dot = round.indexOf("."),
  711. rnd = (dot > -1 ? Integer.parseInt(round.substring(0, dot)) : Integer.parseInt(round)),
  712. subRnd = (dot > -1 ? Integer.parseInt(round.substring(dot + 1)) : 0);
  713. ArrayList<Object> pair = new ArrayList<Object>();
  714. pair.add(new Integer(rnd));
  715. pair.add(new Integer(subRnd));
  716. return pair;
  717. } // end of method parseRound
  718. public void printLearningHistory(String round) {
  719. ArrayList<Object> pair = parseRound(round); // { Rnd, SubRnd }
  720. Integer rnd = (Integer) pair.get(0),
  721. sub = (Integer) pair.get(1);
  722. if (learningHistory.get(rnd) == null) {
  723. return;
  724. }
  725. TreeMap rndTree = (TreeMap) learningHistory.get(rnd);
  726. if (rndTree.get(sub) == null) {
  727. return;
  728. }
  729. ArrayList<Object> thisRound = (ArrayList<Object>) rndTree.get(sub);
  730. System.out.println("\t\t*** Learned In Round " + round);
  731. for (int i = 0; i < thisRound.size(); i++) {
  732. System.out.println("\t\t\t" + thisRound.get(i));
  733. }
  734. System.out.println("\t\t# # #");
  735. } // end of method printLearningHistory
  736. public void writeTestResults(PrintWriter outFile, PrintWriter tabFile, DomainTheory sourceDT)
  737. throws KSInternalErrorException {
  738. if (learningHistory.isEmpty()) {
  739. return;
  740. }
  741. int size = 0,
  742. line = -1;
  743. Iterator branchIter = learningHistory.values().iterator();
  744. while (branchIter.hasNext()) {
  745. TreeMap branch = (TreeMap) branchIter.next();
  746. size += branch.size();
  747. }
  748. String[] rndNmbr = new String[size];
  749. int[] defCnt = new int[size + 1], // last cell holds totals
  750. compDefIndCnt = new int[size + 1],
  751. compDefPurCnt = new int[size + 1],
  752. noiseCnt = new int[size + 1],
  753. falseNoiseCnt = new int[size + 1],
  754. noiseCreate = new int[size + 1],
  755. synCnt = new int[size + 1],
  756. umbCnt = new int[size + 1],
  757. olapCnt = new int[size + 1],
  758. dyadCnt = new int[size + 1],
  759. dataReqs = new int[size + 1];
  760. for (int i = 0; i < size + 1; i++) {
  761. defCnt[i] = 0;
  762. compDefIndCnt[i] = 0;
  763. compDefPurCnt[i] = 0;
  764. noiseCnt[i] = 0;
  765. falseNoiseCnt[i] = 0;
  766. noiseCreate[i] = 0;
  767. synCnt[i] = 0;
  768. umbCnt[i] = 0;
  769. olapCnt[i] = 0;
  770. dyadCnt[i] = 0;
  771. dataReqs[i] = 0;
  772. } // end of array initialization
  773. Iterator rndIter = learningHistory.entrySet().iterator();
  774. String langName = languageName.substring(0, languageName.lastIndexOf("-test"));
  775. outFile.println("\nFor language " + langName);
  776. while (rndIter.hasNext()) {
  777. Map.Entry entry1 = (Map.Entry) rndIter.next();
  778. Integer rndInteger = (Integer) entry1.getKey();
  779. String mainRound = rndInteger.toString();
  780. TreeMap rndTree = (TreeMap) entry1.getValue();
  781. Iterator subIter = rndTree.entrySet().iterator();
  782. while (subIter.hasNext()) {
  783. Map.Entry entry2 = (Map.Entry) subIter.next();
  784. Integer subRndInteger = (Integer) entry2.getKey();
  785. String round = mainRound + "." + subRndInteger;
  786. rndNmbr[++line] = round;
  787. ArrayList<Object> lessons = (ArrayList<Object>) entry2.getValue();
  788. outFile.println("Round " + round + ":");
  789. for (int i = 0; i < lessons.size(); i++) {
  790. ArrayList<Object> lesson = (ArrayList<Object>) lessons.get(i);
  791. outFile.print("\t");
  792. for (int j = 0; j < lesson.size(); j++) {
  793. outFile.print(lesson.get(j));
  794. }
  795. outFile.println();
  796. String leader = (String) lesson.get(0);
  797. if (leader.indexOf("CompDef-Induced: ") > -1) {
  798. compDefIndCnt[line]++;
  799. } else if (leader.indexOf("CompDef-Pure: ") > -1) {
  800. compDefPurCnt[line]++;
  801. } else if (leader.indexOf("Repudiated ") > -1) {
  802. int typ = typeDefRepudiated(leader, rndInteger, subRndInteger);
  803. if (typ == 0) {
  804. compDefIndCnt[line]--;
  805. } else if (typ == 1) {
  806. compDefPurCnt[line]--;
  807. } else {
  808. defCnt[line]--;
  809. }
  810. } else if (leader.indexOf("Def: ") > -1) {
  811. defCnt[line]++;
  812. } else if (leader.indexOf("noise correction: ") > -1) {
  813. noiseCnt[line]++;
  814. } else if (leader.indexOf("false noise check:") > -1) {
  815. falseNoiseCnt[line]++;
  816. } else if (leader.indexOf("Noise created: ") > -1) {
  817. noiseCreate[line] += ((Integer) lesson.get(1)).intValue();
  818. } else if (leader.indexOf("Data Request") > -1) {
  819. dataReqs[line]++;
  820. } else if (leader.indexOf("synonym: ") > -1) {
  821. synCnt[line]++;
  822. } else if (leader.indexOf("umbrella: ") > -1) {
  823. umbCnt[line]++;
  824. } else if (leader.indexOf("overlapping terms:") > -1) {
  825. olapCnt[line]++;
  826. } else if (leader.indexOf("Total Dyads thru Round ") > -1) {
  827. dyadCnt[line] = ((Integer) lesson.get(3)).intValue();
  828. }
  829. } // end of loop thru lessons learned
  830. outFile.println();
  831. } // end of loop thru sub-rounds
  832. } // end of loop thru rounds
  833. outFile.flush();
  834. outFile.close();
  835. tabFile.println("Language\tRound\tNoise Made\tNoise Fixed\tFalse Noise\tDefs Lrnd"
  836. + "\tCompDef-I Lrnd\tCompDef-P Lrnd\tSyns Lrnd\tUmbs Lrnd\toLaps Lrnd\tDyad Reqs\tDyad Total");
  837. String roundNmbr = "" + rndNmbr[0];
  838. if (roundNmbr.indexOf(".") == -1) {
  839. roundNmbr += ".0";
  840. }
  841. tabFile.println(langName + "\t" + roundNmbr + "\t"
  842. + (noiseCreate[0] == 0 ? " " : noiseCreate[0]) + "\t"
  843. + (noiseCnt[0] == 0 ? " " : noiseCnt[0]) + "\t"
  844. + (falseNoiseCnt[0] == 0 ? "" : falseNoiseCnt[0]) + "\t"
  845. + (defCnt[0] == 0 ? " " : defCnt[0]) + "\t"
  846. + (compDefIndCnt[0] == 0 ? " " : compDefIndCnt[0]) + "\t"
  847. + (compDefPurCnt[0] == 0 ? " " : compDefPurCnt[0]) + "\t"
  848. + (synCnt[0] == 0 ? " " : synCnt[0]) + "\t"
  849. + (umbCnt[0] == 0 ? " " : umbCnt[0]) + "\t"
  850. + (olapCnt[0] == 0 ? " " : olapCnt[0]) + "\t"
  851. + (dataReqs[0] == 0 ? " " : dataReqs[0]) + "\t"
  852. + (dyadCnt[0] == 0 ? " " : dyadCnt[0]));
  853. for (int i = 1; i < size; i++) {
  854. roundNmbr = "" + rndNmbr[i];
  855. if (roundNmbr.indexOf(".") == -1) {
  856. roundNmbr += ".0";
  857. }
  858. tabFile.println("\t" + roundNmbr + "\t"
  859. + (noiseCreate[i] == 0 ? " " : noiseCreate[i]) + "\t"
  860. + (noiseCnt[i] == 0 ? " " : noiseCnt[i]) + "\t"
  861. + (falseNoiseCnt[i] == 0 ? "" : falseNoiseCnt[i]) + "\t"
  862. + (defCnt[i] == 0 ? " " : defCnt[i]) + "\t"
  863. + (compDefIndCnt[i] == 0 ? " " : compDefIndCnt[i]) + "\t"
  864. + (compDefPurCnt[i] == 0 ? " " : compDefPurCnt[i]) + "\t"
  865. + (synCnt[i] == 0 ? " " : synCnt[i]) + "\t"
  866. + (umbCnt[i] == 0 ? " " : umbCnt[i]) + "\t"
  867. + (olapCnt[i] == 0 ? " " : olapCnt[i]) + "\t"
  868. + (dataReqs[i] == 0 ? " " : dataReqs[i]) + "\t"
  869. + (dyadCnt[i] == 0 ? " " : dyadCnt[i]));
  870. }
  871. for (int i = 0; i < size; i++) { // add up totals, place in last cell
  872. noiseCreate[size] += noiseCreate[i];
  873. noiseCnt[size] += noiseCnt[i];
  874. falseNoiseCnt[size] += falseNoiseCnt[i];
  875. defCnt[size] += defCnt[i];
  876. compDefIndCnt[size] += compDefIndCnt[i];
  877. compDef

Large files files are truncated, but you can click here to view the full file