-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOverCalc.cs
More file actions
879 lines (669 loc) · 23 KB
/
OverCalc.cs
File metadata and controls
879 lines (669 loc) · 23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
/*
* Created by SharpDevelop.
* User: User
* Date: 10/30/2011
* Time: 1:56 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
/*
* Class to calculate the GDNT, GWMT and the overstemming index
* from the regrouped files
* Rob Hooper
* 07/01/2004
*/
// *** set package
//package Evaluation;
using System;
using System.IO;
using System.Text;
using System.Collections;
using JavaConvert.Data;
using System.Windows.Forms;
//using MyLogger;
namespace WordListAnalyser2
{
public class OverCalc
{
//static string sifile, wifile, snifile, wnifile;//File
static StreamReader stronginput, weakinput, strongnumberinput, weaknumberinput;//BufferedReader
static porterData pd_stronginput, pd_weakinput, pd_strongnumberinput, pd_weaknumberinput;
static ArrayList stemgroup = new ArrayList();// Vector stemgroup = new Vector();
static ArrayList numbergroup = new ArrayList();//Vector numbergroup = new Vector();
static int[] stemnumbergroup;
static string currentline = "";
static string nextline = "";
static int samplesize = 0;
static double strongGDNT, strongGWMT, strongGAMT, strongOIG, strongOIL, strongDI,
weakGDNT, weakGWMT, weakGAMT, weakOIG, weakOIL , weakDI;
public static int numStrongOILZero = 0;
public static int numStrongOILNonZero = 0;
// Constructor methods
public OverCalc(string si, string wi, string sni, string wni, int ss)
{
try {
stronginput = new StreamReader(new FileStream(si, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); //BufferedReader(new FileReader(new File(si)));
weakinput = new StreamReader (new FileStream(wi, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));//BufferedReader(new FileReader(new File(wi)));
strongnumberinput = new StreamReader(new FileStream(sni, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));//BufferedReader(new FileReader(new File(sni)));
weaknumberinput = new StreamReader(new FileStream(wni, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));//BufferedReader(new FileReader(new File(wni)));
samplesize = ss;
strongGDNT = 0;strongGWMT = 0;strongGAMT = 0;strongOIG = 0;strongOIL = 0;strongDI = 0;
weakGDNT = 0; weakGWMT = 0; weakGAMT = 0; weakOIG = 0; weakOIL = 0; weakDI = 0;
System.Diagnostics.Debug.WriteLine("OverCalc 60: si=" + si + "\n wi=" + wi + "\n sni=" + sni + "\n wni=" + wni + "\n ss=" + ss);
} catch (Exception ex ) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "OverCalc");
}
} //end of constructor
public OverCalc(porterData si ,porterData wi, porterData sni, porterData wni, int ss)
{
pd_stronginput = si;
pd_weakinput = wi;
pd_strongnumberinput = sni;
pd_weaknumberinput = wni;
si.resetCursor();
wi.resetCursor();
sni.resetCursor();
wni.resetCursor();
samplesize = ss;
strongGDNT = 0;strongGWMT = 0;strongGAMT = 0;strongOIG = 0;strongOIL = 0;strongDI = 0;
weakGDNT = 0; weakGWMT = 0; weakGAMT = 0; weakOIG = 0; weakOIL = 0; weakDI = 0;
} //end of constructor
public OverCalc(){} //end of null constructor
// Method to retrieve the next stem group from the strong input file
public static void getNextStrongStemGroup()
{
try {
string[] splitcl;
string[] splitnl;
string currentstem;
string nextstem;
//int count = 0; //not used?
//obtain and split nextline
stemgroup.Clear();
stemgroup.Add(currentline);
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
while(currentstem.Equals(nextstem))
{
stemgroup.Add(nextline);//was AddElement
currentline = nextline;
nextline = stronginput.ReadLine();
if(nextline == null)
{
//stronginput.
//MessageBox.Show("Overcalc(99): nextLine was null?");
break;
}
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
}
}
sortStemGroup();
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextStrongStemGroup");
}
} //end of method "getNextStrongStemGroup"
public static void pd_getNextStrongStemGroup()
{
try {
string[] splitcl;
string[] splitnl;
string currentstem;
string nextstem;
//int count = 0; //not used?
//obtain and split nextline
stemgroup.Clear();
stemgroup.Add(currentline);
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
//add elements matching stem
while(currentstem.Equals(nextstem))
{
stemgroup.Add(nextline);//was AddElement
currentline = nextline;
nextline = pd_stronginput.readLine();
if(nextline == null)
{
//stronginput.
//MessageBox.Show("Overcalc(99): nextLine was null?");
break;
}
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
}
}
//end of while 'currentstem.equals ...'
sortStemGroup();
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextStrongStemGroup");
}
} //end of method "getNextStrongStemGroup"
//Method to retrieve the next stem group from the weak input file *****
public static void getNextWeakStemGroup() {
try {
string[] splitcl, splitnl;
string currentstem, nextstem;
//obtain and split nextline
stemgroup.Clear();
stemgroup.Add(currentline);
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
//add elements to group while equal to stem
while(currentstem.Equals(nextstem))
{
stemgroup.Add(nextline);
currentline = nextline;
nextline = weakinput.ReadLine();
if(nextline == null) break;
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
}
} //end of while 'currentstem.equals ...'
sortStemGroup();
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextWeakStemGroup");
}
} //end of method "getNextWeakStemGroup"
public static void pd_getNextWeakStemGroup() {
try {
string[] splitcl, splitnl;
string currentstem, nextstem;
//obtain and split nextline
stemgroup.Clear();
stemgroup.Add(currentline);
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
//add elements to group while equal to stem
while(currentstem.Equals(nextstem))
{
stemgroup.Add(nextline);
currentline = nextline;
nextline = pd_weakinput.readLine();
if(nextline == null) break;
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentstem = splitcl[1];
nextstem = splitnl[1];
}
} //end of while 'currentstem.equals ...'
sortStemGroup();
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextWeakStemGroup");
}
} //end of method "getNextWeakStemGroup"
//Method to retrieve the next number group from the weak input file *****
public static void getNextWeakNumberGroup()
{
try {
string[] splitcl, splitnl;
int currentno, nextno;
//clear group and split next line
numbergroup.Clear();
numbergroup.Add(currentline);
splitcl = currentline.Split(' ');//was ("\\s")
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]);
//whilst group numbers match add element
while(currentno == nextno)
{
numbergroup.Add(nextline);
currentline = nextline;
nextline = weaknumberinput.ReadLine();
if(nextline == null) break;
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);//Integer.ParseInt(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]);
}
} // end of while 'currentno == nextno'
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextWeakNumberGroup");
}
} //end of method 'getNextWeakNumberGroup'
public static void pd_getNextWeakNumberGroup()
{
try {
string[] splitcl, splitnl;
int currentno, nextno;
//clear group and split next line
numbergroup.Clear();
numbergroup.Add(currentline);
splitcl = currentline.Split(' ');//was ("\\s")
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]);
//whilst group numbers match add element
while(currentno == nextno)
{
numbergroup.Add(nextline);
currentline = nextline;
nextline = pd_weaknumberinput.readLine();
if(nextline == null) break;
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);//Integer.ParseInt(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]);
}
} // end of while 'currentno == nextno'
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextWeakNumberGroup");
}
} //end of method 'getNextWeakNumberGroup'
//Method to retrieve the next number group from the strong input file *****
public static void getNextStrongNumberGroup()
{
try {
string[] splitcl, splitnl;
int currentno, nextno;
//clear current group and split next line
numbergroup.Clear();
numbergroup.Add(currentline);
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]); //was 0
//while group numbers match, add element
while(currentno == nextno)
{
numbergroup.Add(nextline);
currentline = nextline;
nextline = strongnumberinput.ReadLine();
if(nextline == null) break;
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]); // was 0
}
} //end of while 'currentno == nextno'
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextStrongNumberGroup");
}
} //end of method 'getNextStrongNumberGroup'
public static void pd_getNextStrongNumberGroup()
{
try {
string[] splitcl, splitnl;
int currentno, nextno;
//clear current group and split next line
numbergroup.Clear();
numbergroup.Add(currentline);
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]); //was 0
//while group numbers match, add element
while(currentno == nextno)
{
numbergroup.Add(nextline);
currentline = nextline;
nextline = pd_strongnumberinput.readLine();
if(nextline == null) break;
else
{
splitcl = currentline.Split(' ');
splitnl = nextline.Split(' ');
currentno = Convert.ToInt32(splitcl[0]);
nextno = Convert.ToInt32(splitnl[0]); // was 0
}
} //end of while 'currentno == nextno'
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getNextStrongNumberGroup");
}
} //end of method 'getNextStrongNumberGroup'
//Method to take a stem group and sort it with bubble sort *****
public static void sortStemGroup()
{
try {
string str1, str2;
StringTokenizer st1, st2;
int no1;
int no2; //was set to 0
//set loop variables
bool change = true;
int stemgroupsize = stemgroup.Count;
//while changes are still being made sort group
while(change)
{
//reset change boolean
change = false;
//check adjacent pairs and swap if necessary
for(int x = 0; x+1 < stemgroupsize; x++)
{
str1 = (string)stemgroup[x];//.ElementAt(x);
str2 = (string)stemgroup[x+1];//.ElementAt(x+1);
st1 = new StringTokenizer(str1);
st2 = new StringTokenizer(str2);
no1 = Convert.ToInt32(st1.NextToken);
no2 = Convert.ToInt32(st2.NextToken);//Added 9 July 2013
if(no1 > no2)
{
// HACK Tom 03/11/2015 Replacing
// .Insert with a replace operation as Java was replacing not adding
stemgroup[x+1] = str1;
stemgroup[x] = str2;
//stemgroup.Insert(x+1,str1);//.setElementAt(str1, x+1);
//stemgroup.Insert(x, str2);//setElementAt(str2, x);
change = true;
}
}
} //end of while 'change'
//MessageBox.Show("sort complete", "sortStemGroup");
} catch (Exception ex ) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "sortStemGroup");
}
} //end of method 'sortStemGroup'
//Method to retrieve the next number group from a sorted stem group *****
public static void getStemNumberGroup() //getNextStemNumberGroup' ??
{
try {
//method variables
string str1;
StringTokenizer st1;
//set variables
int stemgrouplength = stemgroup.Count;
stemnumbergroup = new int[stemgrouplength];
//retrieve the assigned number for stem group
for(int i = 0; i < stemgrouplength; i++) //25 June 2013 i was initially 0
{
str1 = (string)stemgroup[i];//.ElementAt(i);
st1 = new StringTokenizer(str1);
stemnumbergroup[i] = Convert.ToInt32(st1.NextToken);
//MessageBox.Show("StemNumberGroup = " + stemnumbergroup[i].ToString());
}
} catch (Exception ex ) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "getStemNumberGroup");
}
} //end of method 'getNextStemNumberGroup'
//Method to calculate the 'wrongly-merged total' for a stem group
public static double WMT()
{
try {
double wmt = 0;
int no1, no2;
int Ns = stemgroup.Count;
int nsi = 1;
//obtain number group and perform calculations
getStemNumberGroup();
for(int i = 0; i < Ns-1; i++)
{
no1 = stemnumbergroup[i];
no2 = stemnumbergroup[i+1];
if(no1 == no2){
nsi++;
//MessageBox.Show("nsi = " + nsi.ToString(), "WMT() - no1 = no2");
} else
{
wmt = (double)(wmt + (double)(0.5*nsi*(Ns-nsi)));
//MessageBox.Show("wmt in loop = " + wmt.ToString(), "WMT()");
nsi = 1;
}
}
//MessageBox.Show("WMT 348, nsi = " + nsi + " , Ns = " + Ns + " , wmt = " + wmt);
wmt = (double)(wmt + (double)(0.5*nsi*(Ns-nsi)));
//MessageBox.Show("wmt = " + wmt.ToString(), "WMT()");
//MessageBox.Show("WMT 352, wmt = " + wmt);
return wmt;
} catch (Exception ex ) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "WMT");
return 0;
}
} //end of method 'WMT'
//Method to calculate the "desired non-merge total" for a number group *****
public static double DNT()
{
try {
//set variables and calculate
double dnt = 0;
int Ng = numbergroup.Count;
dnt = (double)(Ng * (samplesize - Ng));
dnt = (double)0.5 * dnt;
return dnt;
} catch (Exception ex ) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "DNT()");
return 0;
}
} //end of method 'DNT'
//Method to calculate the "actual merge total" for a stem group
public static double AMT()
{
try {
//set variables and calculate
double amt = 0.00;
int Ns = stemgroup.Count;
//MessageBox.Show("Ns = " + Ns, "AMT()");
amt = (double)((0.5) * Ns);
amt = (double)(amt * (Ns - 1));
//MessageBox.Show("amt = " + amt, "AMT()");
return amt;
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "AMT");
return 0;
}
} //end of method 'AMT'
//Method to calculate the indices for strong values
public static void strongCalc()
{
try {
//read lines from buffers
currentline = stronginput.ReadLine();
nextline = stronginput.ReadLine();
//calculate stemgroup based metrics
// 21/10/2015.. counting loop iterations for debug purposes
int tomsCount = 0;
while(nextline != null)
{
//MessageBox.Show("OverCalc 430, currentline :" + currentline);
getNextStrongStemGroup();
strongGAMT = (double)strongGAMT + AMT();
strongGWMT = (double)strongGWMT + WMT();
currentline = nextline;
nextline = stronginput.ReadLine();
tomsCount++;
} //end of while 'nextline != null'
// Tom 21/10/2015 messagebox to say we exited this
//MessageBox.Show("Overcalc exited first while-loop in strongCalc (439) \n \n tomsCount = " + tomsCount);
//calculate numbergroup based metrics
currentline = strongnumberinput.ReadLine();
//MessageBox.Show("currentline = " + currentline, "strongCalc");
nextline = strongnumberinput.ReadLine();
while(nextline != null)
{
getNextStrongNumberGroup();
strongGDNT = (double)strongGDNT + DNT();
currentline = nextline;
nextline = strongnumberinput.ReadLine();
} //end of while 'nextline != null'
//MessageBox.Show("OverCalc 452, lastLine :" + currentline);
//MessageBox.Show("OverCalc exited second while-loop in strongCalc (453)");
//calculate combined metrics
// HACK Tom 21/10/2015 - There is a warning from the compiler on the commented out comparison logic
// about the numbers having different precisions
// using a workaround by comparing with .equals and .000000000000
//if(strongGDNT == 0.0) strongOIG = 0.0;#
//MessageBox.Show("strong GDNT" + strongGDNT);
//MessageBox.Show("strong GWMT" + strongGWMT);
//MessageBox.Show("strong GAMT" + strongGAMT);
if (strongGDNT.Equals(0.0000000000000)) strongOIG = 0.0;
else strongOIG = strongGWMT / strongGDNT;
//if(strongGAMT == 0.0) strongOIL = 0.0;
if (strongGAMT.Equals(0.0000000000000)) {strongOIL = 0.0; numStrongOILZero++;}
else {strongOIL = (double)strongGWMT / strongGAMT; numStrongOILNonZero++;
System.Diagnostics.Debug.WriteLine("OverCalc 498: strongOIL:" + strongOIL);}
strongDI = (double)1 - strongOIL;
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "strongCalc");
}
} // end of method 'strongCalc'
public static void pd_strongCalc()
{
try {
//read lines from buffers
currentline = pd_stronginput.readLine();
nextline = pd_stronginput.readLine();
//calculate stemgroup based metrics
// 21/10/2015.. counting loop iterations for debug purposes
int tomsCount = 0;
while(nextline != null)
{
//MessageBox.Show("OverCalc 430, currentline :" + currentline);
pd_getNextStrongStemGroup();
strongGAMT = (double)strongGAMT + AMT();
strongGWMT = (double)strongGWMT + WMT();
currentline = nextline;
nextline = pd_stronginput.readLine();
tomsCount++;
} //end of while 'nextline != null'
// Tom 21/10/2015 messagebox to say we exited this
//MessageBox.Show("Overcalc exited first while-loop in strongCalc (439) \n \n tomsCount = " + tomsCount);
//calculate numbergroup based metrics
currentline = pd_strongnumberinput.readLine();
//MessageBox.Show("currentline = " + currentline, "strongCalc");
nextline = pd_strongnumberinput.readLine();
while(nextline != null)
{
pd_getNextStrongNumberGroup();
strongGDNT = (double)strongGDNT + DNT();
currentline = nextline;
nextline = pd_strongnumberinput.readLine();
} //end of while 'nextline != null'
//MessageBox.Show("OverCalc 452, lastLine :" + currentline);
//MessageBox.Show("OverCalc exited second while-loop in strongCalc (453)");
//calculate combined metrics
// HACK Tom 21/10/2015 - There is a warning from the compiler on the commented out comparison logic
// about the numbers having different precisions
// using a workaround by comparing with .equals and .000000000000
//if(strongGDNT == 0.0) strongOIG = 0.0;#
//MessageBox.Show("strong GDNT" + strongGDNT);
//MessageBox.Show("strong GWMT" + strongGWMT);
//MessageBox.Show("strong GAMT" + strongGAMT);
if (strongGDNT.Equals(0.0000000000000)) strongOIG = 0.0;
else strongOIG = strongGWMT / strongGDNT;
//if(strongGAMT == 0.0) strongOIL = 0.0;
if (strongGAMT.Equals(0.0000000000000)) {strongOIL = 0.0; numStrongOILZero++;}
else {strongOIL = (double)strongGWMT / strongGAMT; numStrongOILNonZero++;
System.Diagnostics.Debug.WriteLine("OverCalc 498: strongOIL:" + strongOIL);}
strongDI = (double)1 - strongOIL;
} catch (Exception ex) {
MessageBox.Show(ex.Message + "\n \n" + ex.StackTrace, "strongCalc");
}
} // end of method 'strongCalc'
//Method to calculate the indices for weak values
public static void weakCalc()
{
//read lines from buffers
currentline = weakinput.ReadLine();
nextline = weakinput.ReadLine();
//calculate stemgroup based metrics
while(nextline != null)
{
getNextWeakStemGroup();
weakGAMT = weakGAMT + AMT();
weakGWMT = weakGWMT + WMT();
currentline = nextline;
nextline = weakinput.ReadLine();
} //end of while 'nextline != null'
//calculate numbergroup based metrics
currentline = weaknumberinput.ReadLine();
nextline = weaknumberinput.ReadLine();
while(nextline != null && currentline != null)
{
getNextWeakNumberGroup();
weakGDNT = weakGDNT + DNT();
currentline = nextline;
nextline = weaknumberinput.ReadLine();
} // *** end of while 'nextline != null'
// *** calculate combined metrics
if(weakGDNT == 0.0) weakOIG = 0.0;
else weakOIG = weakGWMT / weakGDNT;
if(weakGAMT == 0.0) weakOIL = 0.0;
else weakOIL = weakGWMT / weakGAMT;
weakDI = 1 - weakOIL;
} // end of method 'weakCalc'
public static void pd_weakCalc()
{
//read lines from buffers
currentline = pd_weakinput.readLine();
nextline = pd_weakinput.readLine();
//calculate stemgroup based metrics
while(nextline != null)
{
pd_getNextWeakStemGroup();
weakGAMT = weakGAMT + AMT();
weakGWMT = weakGWMT + WMT();
currentline = nextline;
nextline = pd_weakinput.readLine();
} //end of while 'nextline != null'
//calculate numbergroup based metrics
currentline = pd_weaknumberinput.readLine();
nextline = pd_weaknumberinput.readLine();
while(nextline != null && currentline != null)
{
pd_getNextWeakNumberGroup();
weakGDNT = weakGDNT + DNT();
currentline = nextline;
nextline = pd_weaknumberinput.readLine();
} // *** end of while 'nextline != null'
// *** calculate combined metrics
if(weakGDNT == 0.0) weakOIG = 0.0;
else weakOIG = weakGWMT / weakGDNT;
if(weakGAMT == 0.0) weakOIL = 0.0;
else weakOIL = weakGWMT / weakGAMT;
weakDI = 1 - weakOIL;
} // end of method 'weakCalc'
//Method to call both calulation methods
public static void calculateResults() {
strongCalc();
weakCalc();
stronginput.Close();
weakinput.Close();
strongnumberinput.Close();
weaknumberinput.Close();
} //end of method 'calculateResults'
public static void pd_calculateResults() {
pd_strongCalc();
pd_weakCalc();
}
//Methods to return indices
public double getStrongGDNT(){return strongGDNT;}
public double getStrongGWMT(){return strongGWMT;}
public double getStrongGAMT(){return strongGAMT;}
public double getStrongOIG(){return strongOIG;}
public double getStrongOIL(){return strongOIL;}
public double getStrongDI(){return strongDI;}
public double getWeakGDNT(){return weakGDNT;}
public double getWeakGWMT(){return weakGWMT;}
public double getWeakGAMT(){return weakGAMT;}
public double getWeakOIG(){return weakOIG;}
public double getWeakOIL(){return weakOIL;}
public double getWeakDI(){return weakDI;}
} // *** end of class 'OverCalc'
}