Skip to content

Commit a21c93d

Browse files
NathanNathan
authored andcommitted
tree replies start
1 parent 4e230a3 commit a21c93d

File tree

2 files changed

+84
-11
lines changed

2 files changed

+84
-11
lines changed

Catalog/Catlookup.cs

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void Main()
2222
{
2323
System.Console.Title = "Board Inspector";
2424
Menu().GetAwaiter().GetResult();
25-
}
25+
}
2626

2727
private static async Task Menu()
2828
{
@@ -44,43 +44,81 @@ private static async Task Menu()
4444
}
4545
Console.WriteLine("||| loading threads");
4646
_LoadedBoardFabric loadedboard = await ThreadLoader(_Tlist);
47-
ParsePosts(loadedboard);
47+
ParsePosts(loadedboard);
4848

4949
for (int i = 0; i < loadedboard.LThreads.Count; i++)
5050
{
5151
Console.WriteLine(@"***************" + loadedboard.LThreads[i].Semantic + " | " + loadedboard.LThreads[i].JSON);
52-
52+
5353

5454

5555
}
5656
}
5757

58-
public static async Task<> ParsePosts(_LoadedBoardFabric boardfabric)
58+
public static async Task<_Pbox[]> ParsePosts(_LoadedBoardFabric boardfabric)
5959
{
6060

6161
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);
6268

6369

6470
for (int i = 0; i < boardfabric.LThreads.Count; i++)
6571
{
66-
67-
6872
string json = boardfabric.LThreads[i].JSON;
6973
var posts = JObject.Parse(json)["posts"].ToObject<JArray>();
7074
string postCom = posts[i]["com"].ToString();
7175
int postID = Int32.Parse(posts[i]["no"].ToString());
7276
int postUnix = Int32.Parse(posts[i]["time"].ToString());
7377
// string postCom = posts[i]["com"].ToString();
7478

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);
7592

93+
}
94+
}
7695

96+
var postweight = PostWeight(threadbank, pureCOM);
7797

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
8099

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];
81116

82117
}
83118

119+
SortedDisplayList = replysort(postarray, replytree);
120+
121+
return SortedDisplayList;
84122

85123
}
86124

@@ -225,6 +263,18 @@ public static Tree replies(string postContent, Tree replytree)
225263
// return replytree;
226264
}
227265
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+
228278
}
229279

230280
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
250300
return trueweight;
251301
}
252302

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+
}
253326

254327
public static async Task<_LoadedBoardFabric> ThreadLoader(ThreadList _Tlist)
255328
{
@@ -478,7 +551,7 @@ public class _Pbox
478551
public string Comment { get; private set; }
479552
public int PostID { get; private set; }
480553
public int Unix { get; private set; }
481-
public int ReplyDepth { get; private set; }
554+
public int ReplyDepth { get; set; }
482555
public PointF Dorigin { get; set; }
483556

484557
public _Pbox(string Com, int postid, int unix, PointF draworigin, int replydepth)

PostBotPrime/Form1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public class _Pbox
102102
public string Comment { get; private set; }
103103
public int PostID { get; private set; }
104104
public int Unix { get; private set; }
105-
public int ReplyDepth { get; private set; }
105+
public int ReplyDepth { get; set; }
106106
public PointF Dorigin { get; set; }
107107

108108
public _Pbox(string Com, int postid, int unix, PointF draworigin, int replydepth)
@@ -289,7 +289,7 @@ public void ReadNextPost(object sender, EventArgs e)
289289

290290

291291
Voice1.SpeakAsync(loaderposts[p].Comment);
292-
Scrolling = true;
292+
Scrolling = true;
293293
p++;
294294
}
295295
Voice1.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(ReadNextPost);

0 commit comments

Comments
 (0)