1- using F23 . StringSimilarity ;
2- using System ;
3- using System . Collections . Generic ;
4- using System . Linq ;
5- using System . Text ;
6- using System . Threading . Tasks ;
1+ using System . Collections . Concurrent ;
2+ using PCLIssueHelper . Similaries ;
73
84namespace PCLIssueHelper
95{
@@ -18,23 +14,55 @@ public IssueSimilarityChecker(List<Issues> issues)
1814
1915 public ( IOrderedEnumerable < KeyValuePair < string , double > > , IOrderedEnumerable < KeyValuePair < string , double > > ) CheckSimilarity ( string title , string body )
2016 {
21- Dictionary < string , double > check1 = new ( ) ;
22- Dictionary < string , double > check2 = new ( ) ;
17+ ConcurrentDictionary < string , double > check1 = new ( ) ;
18+ ConcurrentDictionary < string , double > check2 = new ( ) ;
2319 var checker = new Jaccard ( ) ;
24- foreach ( var issue in _issues )
20+ //foreach (var issue in _issues)
21+ //{
22+ // var _body = issue.body ?? "";
23+ // _body = BodyReplace(_body);
24+
25+ // var similarity1 = checker.Similarity(title, issue.title ?? "");
26+ // var similarity2 = checker.Similarity(body, _body);
27+ // if (similarity1 != 0)
28+ // {
29+ // check1.Add(issue.number.ToString() ?? "", similarity1);
30+ // }
31+ // if (similarity2 != 0)
32+ // {
33+ // check2.Add(issue.number.ToString() ?? "", similarity2);
34+ // }
35+ //}
36+ Parallel . ForEach ( _issues , issue =>
2537 {
2638 var _body = issue . body ?? "" ;
27- _body = _body
39+ _body = BodyReplace ( _body ) ;
40+
41+ var similarity1 = checker . Similarity ( title , issue . title ?? "" ) ;
42+ var similarity2 = checker . Similarity ( body , _body ) ;
43+ if ( similarity1 != 0 )
44+ {
45+ //check1.Add(issue.number.ToString() ?? "", similarity1);
46+ check1 . AddOrUpdate ( issue . number . ToString ( ) ?? "" , similarity1 , ( x , y ) => y ) ;
47+ }
48+ if ( similarity2 != 0 )
49+ {
50+ //check2.Add(issue.number.ToString() ?? "", similarity2);
51+ check2 . AddOrUpdate ( issue . number . ToString ( ) ?? "" , similarity2 , ( x , y ) => y ) ;
52+ }
53+ } ) ;
54+ var result1 = check1 . OrderByDescending ( x => x . Value ) ;
55+ var result2 = check2 . OrderByDescending ( x => x . Value ) ;
56+ return ( result1 , result2 ) ;
57+ }
58+
59+ private static string BodyReplace ( string body )
60+ {
61+ return body
2862 . Replace ( """我已在 [Issues 页面](https://github.com/Hex-Dragon/PCL2/issues?q=is%3Aissue+) 和 [常见&难检反馈及问题列表](https://github.com/Hex-Dragon/PCL2/discussions/1930) 中搜索,确认了这一建议未被提交过。""" , "" )
2963 . Replace ( """我已查看 [功能投票页面](https://github.com/Hex-Dragon/PCL2/discussions/categories/%E5%8A%9F%E8%83%BD%E6%8A%95%E7%A5%A8/),确认了这一建议未在投票列表中。""" , "" )
3064 . Replace ( """**我所启动的游戏不是整合包,且未安装任何 Mod。** 安装 Mod 后的游戏崩溃基本不是 PCL 的原因,请 **不要** 提交反馈。你可以在论坛或社区找人求助,但这里并不是你求助的地方。\n- [X] **我已尝试使用 HMCL 启动,HMCL 没有出现问题。** 如果 HMCL 也无法启动就不是 PCL 导致的问题,请 **不要** 提交反馈。[下载 HMCL](https://hmcl.huangyuhui.net/download)""" , "" )
3165 . Replace ( """我已在 [Issues 页面](https://github.com/Hex-Dragon/PCL2/issues?q=is%3Aissue+) 和 [常见&难检反馈及问题列表](https://github.com/Hex-Dragon/PCL2/discussions/1930) 中搜索,确认了这一 Bug 未被提交过。""" , "" ) ;
32- check1 . Add ( issue . number . ToString ( ) ?? "" , checker . Similarity ( title , issue . title ?? "" ) ) ;
33- check2 . Add ( issue . number . ToString ( ) ?? "" , checker . Similarity ( body , _body ) ) ;
34- }
35- var result1 = check1 . OrderByDescending ( x => x . Value ) ;
36- var result2 = check2 . OrderByDescending ( x => x . Value ) ;
37- return ( result1 , result2 ) ;
3866 }
3967 }
4068}
0 commit comments