-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSummarizer.cs
More file actions
50 lines (42 loc) · 1.09 KB
/
Summarizer.cs
File metadata and controls
50 lines (42 loc) · 1.09 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
using System.Collections.Generic;
public class Summarizer{
List<Entry> entries = new List<Entry>();
public string AddAll(List<string> arg){
Entry sel = null;
string selValue = null;
foreach(var str in arg){
if(str.Contains("✗")) continue;
var e = Add(str);
if(sel == null || sel.count > e.count){
sel = e;
selValue = str;
}
}
return selValue;
}
Entry Add(string arg){
arg = Strip(arg);
var e = entries.Find( x => x.value == arg);
if(e == null){
e = new Entry(1, arg);
entries.Add(e);
return e;
}else{
e.count ++;
return e;
}
}
string Strip(string arg){
int i = arg.IndexOf("(");
if(i >= 0) return arg.Substring(0, i);
else return arg;
}
class Entry{
public int count;
public string value;
public Entry(int count, string value){
this.count = count;
this.value = value;
}
}
}