Skip to content

Commit b35fdc8

Browse files
committed
// 2020.05
1 parent 6cbafd8 commit b35fdc8

File tree

745 files changed

+144750
-6086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

745 files changed

+144750
-6086
lines changed

BitCutStudios.CorpusExplorer/Addon/AddonHost.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public IAddon GetAddonBy(string guid)
5959
/// </summary>
6060
public IHostWindow Window { get; }
6161

62+
private static string GetDirectoryPath(string directory)
63+
{
64+
return string.IsNullOrEmpty(directory)
65+
? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
66+
: directory;
67+
}
68+
6269
/// <summary>
6370
/// Sucht in einem Verzeichnis nach Dateien die Addon
6471
/// enthalten
@@ -127,7 +134,7 @@ public void SearchInDirectoryForAddons(string directory = null, string searchPat
127134
continue;
128135
if (file.EndsWith("udpipe_csharp.dll"))
129136
continue;
130-
if(ex is BadImageFormatException)
137+
if (ex is BadImageFormatException)
131138
continue;
132139

133140
InMemoryErrorConsole.Log(ex);
@@ -172,12 +179,5 @@ public void ShutDown()
172179
{
173180
}
174181
}
175-
176-
private static string GetDirectoryPath(string directory)
177-
{
178-
return string.IsNullOrEmpty(directory)
179-
? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
180-
: directory;
181-
}
182182
}
183183
}

BitCutStudios.CorpusExplorer/BitCutStudios.CorpusExplorer.csproj

+7-4
Large diffs are not rendered by default.

BitCutStudios.CorpusExplorer/Crawler/HtmlCrawler.cs

+39-39
Original file line numberDiff line numberDiff line change
@@ -143,45 +143,6 @@ public Dictionary<string, object>[] Crawl(string html)
143143
return CrawlCall(doc);
144144
}
145145

146-
/// <summary>
147-
/// Sollte überschriebe werden, wenn eine andere Bereingung gewünscht ist als alle Werte (res) durch HtmlCleanup zu
148-
/// leiten.
149-
/// </summary>
150-
/// <param name="res">Daten</param>
151-
/// <returns>Daten</returns>
152-
/// <example>
153-
/// foreach (var r in res)
154-
/// {
155-
/// var keys = r.Keys;
156-
/// foreach (var key in keys)
157-
/// {
158-
/// r[key] = HtmlCleanup(r[key]);
159-
/// }
160-
/// }
161-
/// return res;
162-
/// </example>
163-
protected virtual Dictionary<string, object>[] HtmlCleanupChannel(Dictionary<string, object>[] res)
164-
{
165-
foreach (var r in res)
166-
{
167-
var keys = r.Keys.ToArray();
168-
foreach (var key in keys)
169-
r[key] = HtmlCleanup(r[key].ToString());
170-
}
171-
172-
return res;
173-
}
174-
175-
/// <summary>
176-
/// Sollte überschrieben werden, wenn es sich um ein HTML-Dokument handelt das mehrere Beiträge enthält.
177-
/// </summary>
178-
/// <param name="res">Daten</param>
179-
/// <returns>Daten</returns>
180-
protected virtual Dictionary<string, object>[] HtmlSplitChannel(Dictionary<string, object>[] res)
181-
{
182-
return res;
183-
}
184-
185146
private Dictionary<string, object>[] CrawlCall(HtmlDocument doc)
186147
{
187148
// Erezuge Stringbuilder
@@ -256,6 +217,45 @@ private string HtmlCleanup(string html)
256217
return _criticals.Aggregate(html, (current, c) => current.Replace(c.Key, c.Value));
257218
}
258219

220+
/// <summary>
221+
/// Sollte überschriebe werden, wenn eine andere Bereingung gewünscht ist als alle Werte (res) durch HtmlCleanup zu
222+
/// leiten.
223+
/// </summary>
224+
/// <param name="res">Daten</param>
225+
/// <returns>Daten</returns>
226+
/// <example>
227+
/// foreach (var r in res)
228+
/// {
229+
/// var keys = r.Keys;
230+
/// foreach (var key in keys)
231+
/// {
232+
/// r[key] = HtmlCleanup(r[key]);
233+
/// }
234+
/// }
235+
/// return res;
236+
/// </example>
237+
protected virtual Dictionary<string, object>[] HtmlCleanupChannel(Dictionary<string, object>[] res)
238+
{
239+
foreach (var r in res)
240+
{
241+
var keys = r.Keys.ToArray();
242+
foreach (var key in keys)
243+
r[key] = HtmlCleanup(r[key].ToString());
244+
}
245+
246+
return res;
247+
}
248+
249+
/// <summary>
250+
/// Sollte überschrieben werden, wenn es sich um ein HTML-Dokument handelt das mehrere Beiträge enthält.
251+
/// </summary>
252+
/// <param name="res">Daten</param>
253+
/// <returns>Daten</returns>
254+
protected virtual Dictionary<string, object>[] HtmlSplitChannel(Dictionary<string, object>[] res)
255+
{
256+
return res;
257+
}
258+
259259
private void InitializeCriticals()
260260
{
261261
_criticals = new Dictionary<string, string>

BitCutStudios.CorpusExplorer/Crawler/HtmlMultipageCrawler.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
using System;
1+
#region
2+
3+
using System;
24
using System.Collections.Generic;
35
using Bcs.Crawler.Interface;
46
using HtmlAgilityPack;
57

8+
#endregion
9+
610
namespace Bcs.Crawler
711
{
812
[Serializable]
@@ -11,7 +15,6 @@ public class HtmlMultipageCrawler : ICrawler
1115
public HtmlCrawler Crawler { get; set; }
1216

1317
public string DocumentSeperatorXPath { get; set; }
14-
public string Url { get; set; }
1518

1619
public Dictionary<string, object>[] Crawl()
1720
{
@@ -40,5 +43,7 @@ public Dictionary<string, object>[] Crawl()
4043

4144
return res.ToArray();
4245
}
46+
47+
public string Url { get; set; }
4348
}
4449
}

BitCutStudios.CorpusExplorer/Crawler/HtmlPagedCrawler.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
using System;
1+
#region
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Globalization;
46
using System.Xml.Serialization;
57
using Bcs.Crawler.Interface;
68
using HtmlAgilityPack;
79

10+
#endregion
11+
812
namespace Bcs.Crawler
913
{
1014
/// <summary>

BitCutStudios.CorpusExplorer/Crawler/HtmlStaticIndexCrawler.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
#region
2+
13
using System;
24
using System.Collections.Generic;
35
using Bcs.Crawler.Interface;
46
using HtmlAgilityPack;
57

8+
#endregion
9+
610
namespace Bcs.Crawler
711
{
812
public class HtmlStaticIndexCrawler : ICrawler

BitCutStudios.CorpusExplorer/Crawler/HtmlStaticIndexCrawlerFilterLinks.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
#region
2+
13
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using Bcs.Crawler.Interface;
57
using HtmlAgilityPack;
68

9+
#endregion
10+
711
namespace Bcs.Crawler
812
{
913
public class HtmlStaticIndexCrawlerFilterLinks : ICrawler

BitCutStudios.CorpusExplorer/Crawler/Interface/ICrawler.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using System.Collections.Generic;
1+
#region
2+
3+
using System.Collections.Generic;
4+
5+
#endregion
26

37
namespace Bcs.Crawler.Interface
48
{

BitCutStudios.CorpusExplorer/IO/FileAccessHelper.cs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
using System;
1+
#region
2+
3+
using System;
24
using System.IO;
35
using System.Threading;
46

7+
#endregion
8+
59
namespace Bcs.IO
610
{
711
public static class FileAccessHelper
812
{
9-
public static void WaitForFileAccess(string path, int timeout = 200)
10-
{
11-
SpinWait.SpinUntil(() => IsFileReady(path));
12-
}
13-
1413
public static bool IsFileReady(string path)
1514
{
1615
try
@@ -28,5 +27,10 @@ public static bool IsFileReady(string path)
2827
return false;
2928
}
3029
}
30+
31+
public static void WaitForFileAccess(string path, int timeout = 200)
32+
{
33+
SpinWait.SpinUntil(() => IsFileReady(path));
34+
}
3135
}
3236
}

BitCutStudios.CorpusExplorer/IO/FileSizeCalculator.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ namespace Bcs.IO
1111
public static class FileSizeCalculator
1212
{
1313
/// <summary>
14-
/// String der die Größe der Datei lesbar für den Nutzer angiebt
14+
/// Gibt die Dateigröße zurück.
1515
/// </summary>
1616
/// <param name="file">Datei</param>
1717
/// <returns>
18-
/// SizeString
18+
/// Dateigröße
1919
/// </returns>
20-
// ReSharper disable once UnusedMember.Global
21-
public static string GetSizeString(string file)
20+
private static long GetFileSize(string file)
2221
{
23-
return GetSizeString(GetFileSize(file));
22+
return new FileInfo(file).Length;
2423
}
2524

2625
/// <summary>
27-
/// Gibt die Dateigröße zurück.
26+
/// String der die Größe der Datei lesbar für den Nutzer angiebt
2827
/// </summary>
2928
/// <param name="file">Datei</param>
3029
/// <returns>
31-
/// Dateigröße
30+
/// SizeString
3231
/// </returns>
33-
private static long GetFileSize(string file)
32+
// ReSharper disable once UnusedMember.Global
33+
public static string GetSizeString(string file)
3434
{
35-
return new FileInfo(file).Length;
35+
return GetSizeString(GetFileSize(file));
3636
}
3737

3838
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
#region
2+
3+
using System.Net;
4+
5+
#endregion
66

77
namespace Bcs.Network
88
{
@@ -12,11 +12,13 @@ public static long GetFileSize(string url)
1212
{
1313
try
1414
{
15-
var req = System.Net.WebRequest.Create(url);
15+
var req = WebRequest.Create(url);
1616
req.Method = "HEAD";
1717
using (var resp = req.GetResponse())
18-
if (long.TryParse(resp.Headers.Get("Content-Length"), out long ContentLength))
18+
{
19+
if (long.TryParse(resp.Headers.Get("Content-Length"), out var ContentLength))
1920
return ContentLength;
21+
}
2022
}
2123
catch
2224
{
@@ -26,4 +28,4 @@ public static long GetFileSize(string url)
2628
return -1;
2729
}
2830
}
29-
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using System;
2-
using System.Collections.Generic;
1+
#region
2+
33
using System.IO;
4-
using System.Linq;
54
using System.Net;
6-
using System.Text;
7-
using System.Threading.Tasks;
5+
6+
#endregion
87

98
namespace Bcs.Network
109
{
1110
public static class WebRequestHelper
1211
{
13-
public static string SendPostData(string url, string jsonData, string contentType = "application/json", string method = "POST")
12+
public static string SendPostData(string url, string jsonData, string contentType = "application/json",
13+
string method = "POST")
1414
{
1515
try
1616
{
@@ -19,16 +19,20 @@ public static string SendPostData(string url, string jsonData, string contentTyp
1919
httpWebRequest.Method = method;
2020

2121
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
22+
{
2223
streamWriter.Write(jsonData);
24+
}
2325

2426
var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
2527
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
28+
{
2629
return streamReader.ReadToEnd();
30+
}
2731
}
2832
catch
2933
{
3034
return null;
3135
}
3236
}
3337
}
34-
}
38+
}

BitCutStudios.CorpusExplorer/Properties/AssemblyInfo.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#region
22

3+
#region
4+
35
using System;
46
using System.Reflection;
57
using System.Runtime.InteropServices;
68

9+
#endregion
10+
711
[assembly: CLSCompliant(false)]
812

913
#endregion

0 commit comments

Comments
 (0)