@@ -22,7 +22,7 @@ static void Main()
22
22
{
23
23
System . Console . Title = "Board Inspector" ;
24
24
Menu ( ) . GetAwaiter ( ) . GetResult ( ) ;
25
- }
25
+ }
26
26
27
27
private static async Task Menu ( )
28
28
{
@@ -44,43 +44,81 @@ private static async Task Menu()
44
44
}
45
45
Console . WriteLine ( "||| loading threads" ) ;
46
46
_LoadedBoardFabric loadedboard = await ThreadLoader ( _Tlist ) ;
47
- ParsePosts ( loadedboard ) ;
47
+ ParsePosts ( loadedboard ) ;
48
48
49
49
for ( int i = 0 ; i < loadedboard . LThreads . Count ; i ++ )
50
50
{
51
51
Console . WriteLine ( @"***************" + loadedboard . LThreads [ i ] . Semantic + " | " + loadedboard . LThreads [ i ] . JSON ) ;
52
-
52
+
53
53
54
54
55
55
}
56
56
}
57
57
58
- public static async Task < > ParsePosts ( _LoadedBoardFabric boardfabric )
58
+ public static async Task < _Pbox [ ] > ParsePosts ( _LoadedBoardFabric boardfabric )
59
59
{
60
60
61
61
Tree replytree = new Tree ( ) ;
62
+ _Pbox [ ] postarray = new _Pbox [ 0 ] ;
63
+ _Pbox [ ] SortedDisplayList = new _Pbox [ 0 ] ;
64
+ string pattern = @"<br><br>" ;
65
+ string replacement = " " ;
66
+ Regex breakpoints = new Regex ( pattern ) ;
67
+ Dictionary < string , int > threadbank = wordBankCompiler ( boardfabric . Board ) ;
62
68
63
69
64
70
for ( int i = 0 ; i < boardfabric . LThreads . Count ; i ++ )
65
71
{
66
-
67
-
68
72
string json = boardfabric . LThreads [ i ] . JSON ;
69
73
var posts = JObject . Parse ( json ) [ "posts" ] . ToObject < JArray > ( ) ;
70
74
string postCom = posts [ i ] [ "com" ] . ToString ( ) ;
71
75
int postID = Int32 . Parse ( posts [ i ] [ "no" ] . ToString ( ) ) ;
72
76
int postUnix = Int32 . Parse ( posts [ i ] [ "time" ] . ToString ( ) ) ;
73
77
// string postCom = posts[i]["com"].ToString();
74
78
79
+ string postComBroken = breakpoints . Replace ( postCom , replacement ) ;
80
+ string pureCOM = "" ;
81
+
82
+ if ( posts [ i ] [ "no" ] . ToString ( ) != null && posts [ i ] [ "com" ] != null ) //html agility pack and encoding fix
83
+ {
84
+ var htmldoc = new HtmlAgilityPack . HtmlDocument ( ) ;
85
+ var html = postComBroken ;
86
+ if ( html != null )
87
+ {
88
+
89
+ htmldoc . LoadHtml ( html ) ;
90
+ var htmlparsed = htmldoc . DocumentNode . InnerText ;
91
+ pureCOM = WebUtility . HtmlDecode ( htmlparsed ) ;
75
92
93
+ }
94
+ }
76
95
96
+ var postweight = PostWeight ( threadbank , pureCOM ) ;
77
97
78
- replytree = replies ( postCom , replytree ) ;
79
- _Pbox postbox = new _Pbox ( postCom , postID , postUnix , new PointF ( 0 , 0 ) , 0 ) ;
98
+ replytree = replies ( pureCOM , replytree ) ; //reply tree creation
80
99
100
+ _Pbox postbox = new _Pbox ( pureCOM , postID , postUnix , new PointF ( 0 , 0 ) , 0 ) ;
101
+
102
+ if ( isreply == true )
103
+ {
104
+
105
+
106
+ postbox . ReplyDepth = replydepth ( postbox , replytree ) ;
107
+ }
108
+ if ( postweight > 0 )
109
+ {
110
+
111
+
112
+ postarray . Append ( postbox ) ;
113
+ }
114
+
115
+ //_Pbox[] SortedDisplayList = new _Pbox[0];
81
116
82
117
}
83
118
119
+ SortedDisplayList = replysort ( postarray , replytree ) ;
120
+
121
+ return SortedDisplayList ;
84
122
85
123
}
86
124
@@ -225,6 +263,18 @@ public static Tree replies(string postContent, Tree replytree)
225
263
// return replytree;
226
264
}
227
265
return replytree ;
266
+ }
267
+
268
+ public static _Pbox [ ] replysort ( _Pbox [ ] unsortedposts , Tree replytree )
269
+ {
270
+
271
+
272
+ }
273
+ public static int replydepth ( _Pbox post , Tree replytree )
274
+ {
275
+
276
+
277
+
228
278
}
229
279
230
280
public static int ThreadWeight ( Int32 replycount , Int32 imagecount , Dictionary < string , int > WordBank , string semantic )
@@ -250,6 +300,29 @@ public static int ThreadWeight(Int32 replycount, Int32 imagecount, Dictionary<st
250
300
return trueweight ;
251
301
}
252
302
303
+ public static int PostWeight ( Dictionary < string , int > WordBank , string content )
304
+ {
305
+ int collectiveMulti = 1 ;
306
+ foreach ( KeyValuePair < string , int > kvp in WordBank )
307
+ {
308
+ var keywords = kvp . Key ;
309
+ Regex RX = new Regex ( @keywords ) ;
310
+
311
+ if ( RX . IsMatch ( content ) == true )
312
+ {
313
+ MatchCollection matches = RX . Matches ( content ) ;
314
+ collectiveMulti = ( kvp . Value * matches . Count ) + collectiveMulti ;
315
+ // Console.WriteLine("collective multi " + collectiveMulti);
316
+ }
317
+
318
+ }
319
+
320
+ var replydiff = 10 ;
321
+ var preMulti = replydiff ^ 3 / 2 ;
322
+ var trueweight = preMulti * ( 1 + collectiveMulti / 4 ) ;
323
+
324
+ return trueweight ;
325
+ }
253
326
254
327
public static async Task < _LoadedBoardFabric > ThreadLoader ( ThreadList _Tlist )
255
328
{
@@ -478,7 +551,7 @@ public class _Pbox
478
551
public string Comment { get ; private set ; }
479
552
public int PostID { get ; private set ; }
480
553
public int Unix { get ; private set ; }
481
- public int ReplyDepth { get ; private set ; }
554
+ public int ReplyDepth { get ; set ; }
482
555
public PointF Dorigin { get ; set ; }
483
556
484
557
public _Pbox ( string Com , int postid , int unix , PointF draworigin , int replydepth )
0 commit comments