Skip to content

Commit cf78efc

Browse files
committed
Merge remote-tracking branch 'origin-github/master'
2 parents 142c162 + 373e1e8 commit cf78efc

22 files changed

Lines changed: 559 additions & 112 deletions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using CorpusExplorer.Sdk.Addon;
7+
using CorpusExplorer.Sdk.Model;
8+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
9+
using CorpusExplorer.Sdk.ViewModel;
10+
11+
namespace CorpusExplorer.Sdk.Action
12+
{
13+
public class BurrowsDeltaAction : IAction
14+
{
15+
public string Action => "burrows-delta";
16+
17+
public string Description =>
18+
"burrows-delta {META} {SIZE} - calculate burrows delta for [META] (default: Autor) with [SIZE] samples (default: 2000)";
19+
20+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
21+
{
22+
var vm = new BurrowsDeltaViewModel
23+
{
24+
Selection = selection,
25+
MetadataKey = args.Length > 0 ? args[0] : "Autor",
26+
MFWCount = args.Length > 2 ? int.Parse(args[1]) : 2000
27+
};
28+
vm.Execute();
29+
30+
writer.WriteTable(vm.GetDataTable());
31+
}
32+
}
33+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using CorpusExplorer.Sdk.Addon;
8+
using CorpusExplorer.Sdk.Blocks;
9+
using CorpusExplorer.Sdk.Blocks.Range;
10+
using CorpusExplorer.Sdk.Model;
11+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
12+
using CorpusExplorer.Sdk.ViewModel;
13+
14+
namespace CorpusExplorer.Sdk.Action
15+
{
16+
public class CooccurrenceClassicAction : IAction
17+
{
18+
public string Action => "cooccurrence-classic [LAYER] [FROM] [TO]";
19+
public string Description { get; }
20+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
21+
{
22+
if (args.Length < 4)
23+
return;
24+
25+
var block = selection.CreateBlock<CooccurrenceClassicBlock>();
26+
block.LayerDisplayname = args[0];
27+
var from = int.Parse(args[1]);
28+
var to = int.Parse(args[2]);
29+
block.Ranges = new RangeSimple(from, to);
30+
block.LayerQueries = args.Skip(3).ToArray();
31+
32+
block.Calculate();
33+
34+
var dt = new DataTable();
35+
dt.Columns.Add(args[0], typeof(string));
36+
dt.Columns.Add("Cooccurrence", typeof(string));
37+
dt.Columns.Add("Frequency", typeof(int));
38+
dt.Columns.Add("Significance", typeof(double));
39+
40+
dt.BeginLoadData();
41+
foreach (var x in block.CooccurrenceSignificance)
42+
foreach (var y in x.Value)
43+
dt.Rows.Add(x.Key, y.Key, block.CooccurrenceFrequency[x.Key][y.Key], y.Value);
44+
dt.EndLoadData();
45+
46+
writer.WriteTable(dt);
47+
}
48+
}
49+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using CorpusExplorer.Sdk.Addon;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using CorpusExplorer.Sdk.Model;
8+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
9+
using CorpusExplorer.Sdk.ViewModel;
10+
11+
namespace CorpusExplorer.Sdk.Action
12+
{
13+
public class CooccurrenceDiversityAction : IAction
14+
{
15+
public string Action => "cooccurrence-diversity";
16+
public string Description => "cooccurrence-diversity [LAYER] - calculate the diversity of cooccurrences for a given [LAYER]";
17+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
18+
{
19+
if (args.Length != 1)
20+
return;
21+
22+
var vm = new CooccurrenceDiversityViewModel
23+
{
24+
Selection = selection,
25+
LayerDisplayname = args[0]
26+
};
27+
28+
vm.Execute();
29+
30+
writer.WriteTable(vm.GetDataTable());
31+
}
32+
}
33+
}

Action/CorpusExplorer.Sdk.Action/CorpusExplorer.Sdk.Action.csproj

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>CorpusExplorer.Sdk.Action</RootNamespace>
1111
<AssemblyName>CorpusExplorer.Sdk.Action</AssemblyName>
12-
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<Deterministic>true</Deterministic>
1515
<TargetFrameworkProfile />
@@ -49,38 +49,74 @@
4949
<ItemGroup>
5050
<Reference Include="System" />
5151
<Reference Include="System.Core" />
52-
<Reference Include="System.Xml.Linq" />
52+
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
53+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
54+
<Private>True</Private>
55+
<Private>True</Private>
56+
</Reference>
57+
<Reference Include="System.Runtime, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
58+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll</HintPath>
59+
<Private>True</Private>
60+
<Private>True</Private>
61+
</Reference>
62+
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
63+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
64+
<Private>True</Private>
65+
<Private>True</Private>
66+
</Reference>
67+
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
68+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
69+
<Private>True</Private>
70+
<Private>True</Private>
71+
</Reference>
72+
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
73+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
74+
<Private>True</Private>
75+
<Private>True</Private>
76+
</Reference>
77+
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
78+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
79+
<Private>True</Private>
80+
<Private>True</Private>
81+
</Reference>
5382
<Reference Include="System.Data.DataSetExtensions" />
54-
<Reference Include="Microsoft.CSharp" />
5583
<Reference Include="System.Data" />
56-
<Reference Include="System.Net.Http" />
5784
<Reference Include="System.Xml" />
5885
</ItemGroup>
5986
<ItemGroup>
6087
<Compile Include="Abstract\AbstractFilterAction.cs" />
6188
<Compile Include="AddTaggerAction.cs" />
6289
<Compile Include="BasicInformationAction.cs" />
90+
<Compile Include="BurrowsDeltaAction.cs" />
6391
<Compile Include="CentralSnipAction.cs" />
6492
<Compile Include="ClusterAction.cs" />
6593
<Compile Include="ClusterListAction.cs" />
94+
<Compile Include="CooccurrenceClassicAction.cs" />
6695
<Compile Include="CooccurrenceCorrespondingAction.cs" />
6796
<Compile Include="CooccurrenceCrossAction.cs" />
6897
<Compile Include="CooccurrenceCrossFullAction.cs" />
98+
<Compile Include="CooccurrenceDiversityAction.cs" />
6999
<Compile Include="CooccurrencePolarisationAction.cs" />
70100
<Compile Include="CooccurrenceSelectedCorrespondingAction.cs" />
101+
<Compile Include="CorpusFiniteStateMachineAction.cs" />
71102
<Compile Include="CorrespondingValuesAction.cs" />
72103
<Compile Include="CrossFrequencyCorrespondingAction.cs" />
104+
<Compile Include="CrossFrequencySelectAction.cs" />
105+
<Compile Include="CrossFrequencySelectRangeAction.cs" />
73106
<Compile Include="CutOffPhraseAction.cs" />
74107
<Compile Include="DisambiguationeAction.cs" />
75108
<Compile Include="DispersionAction.cs" />
76109
<Compile Include="DispersionCorrespondingAction.cs" />
77110
<Compile Include="DocumentHashAction.cs" />
78111
<Compile Include="DocumentSimilarityAction.cs" />
79112
<Compile Include="EditDistanceAction.cs" />
113+
<Compile Include="Frequency1PerDocumentAction.cs" />
114+
<Compile Include="Frequency1PerSentenceAction.cs" />
80115
<Compile Include="Frequency1RawAction.cs" />
81116
<Compile Include="Frequency1RawSelectAction.cs" />
82117
<Compile Include="Frequency2RawAction.cs" />
83118
<Compile Include="CentralSnipTreeAction.cs" />
119+
<Compile Include="NGramCharAction.cs" />
84120
<Compile Include="Phrase2LayerCountAction.cs" />
85121
<Compile Include="Frequency3RawAction.cs" />
86122
<Compile Include="Helper\ConvertToDigraphHelper.cs" />
@@ -154,13 +190,16 @@
154190
<Compile Include="QueryCountDocumentsAction.cs" />
155191
<Compile Include="QueryCountSentencesAction.cs" />
156192
<Compile Include="QueryListAction.cs" />
193+
<Compile Include="ReadingEaseAction.cs" />
157194
<Compile Include="RemoveLayerAction.cs" />
158195
<Compile Include="RemoveMetaAction.cs" />
159196
<Compile Include="SentenceCountAction.cs" />
160197
<Compile Include="SizeAction.cs" />
198+
<Compile Include="SkipgramAction.cs" />
161199
<Compile Include="StopwordListAction.cs" />
162200
<Compile Include="StyleBurrowsDeltaAction.cs" />
163201
<Compile Include="StyleNgramAction.cs" />
202+
<Compile Include="TermDocumentMatrixAction.cs" />
164203
<Compile Include="TermFrequencyInverseDocumentFrequencyAction.cs" />
165204
<Compile Include="DocumentTermFrequencyAction.cs" />
166205
<Compile Include="TokenCountAction.cs" />
@@ -174,13 +213,14 @@
174213
<ItemGroup>
175214
<None Include="app.config" />
176215
<None Include="CorpusExplorerNextSnKey2019.pfx" />
216+
<None Include="packages.config" />
177217
</ItemGroup>
178218
<ItemGroup>
179-
<ProjectReference Include="..\..\..\..\Projekte-Kooperation\FuzzyHashing\Hyldahl.Hashing\Hyldahl.Hashing.csproj">
180-
<Project>{6968101f-a3d4-4a14-a481-05e373cd5dc1}</Project>
181-
<Name>Hyldahl.Hashing</Name>
219+
<ProjectReference Include="..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\CorpusExplorer.Sdk.Extern.NHunspell\CorpusExplorer.Sdk.Extern.NHunspell.csproj">
220+
<Project>{0317C4F4-D9EF-43CF-8B3E-071D96543A3F}</Project>
221+
<Name>CorpusExplorer.Sdk.Extern.NHunspell</Name>
182222
</ProjectReference>
183-
<ProjectReference Include="C:\Projekte\CorpusExplorerV2\CorpusExplorer\CorpusExplorer.Sdk\CorpusExplorer.Sdk.csproj">
223+
<ProjectReference Include="..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\CorpusExplorer.Sdk\CorpusExplorer.Sdk.csproj">
184224
<Project>{dc1b5a58-29da-476d-89f8-e73a1db11e52}</Project>
185225
<Name>CorpusExplorer.Sdk</Name>
186226
</ProjectReference>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Text;
2+
using CorpusExplorer.Sdk.Addon;
3+
using CorpusExplorer.Sdk.Model;
4+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
5+
using CorpusExplorer.Sdk.ViewModel;
6+
7+
namespace CorpusExplorer.Sdk.Action
8+
{
9+
public class CorpusFiniteStateMachineAction : IAction
10+
{
11+
public string Action => "corpus-fsm";
12+
public string Description => "corpus-fsm [ORDER] [ENTITY] [STATE] - generates a fine-state-maschine based on corpus meta-data.";
13+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
14+
{
15+
if (args.Length != 3)
16+
return;
17+
18+
var vm = new CorpusFiniteStateMachineViewModel
19+
{
20+
Selection = selection,
21+
MetadataKeyTimestamp = args[0],
22+
MetadataKeyEntity = args[1],
23+
MetadataKeyLevel = args[2]
24+
};
25+
vm.Execute();
26+
27+
var stb = new StringBuilder();
28+
stb.AppendLine("digraph G {");
29+
foreach (var edge in vm.ConnectionsAggregated)
30+
stb.AppendLine($" \"{edge.Key}\" -> \"{edge.Value}\"");
31+
stb.AppendLine("}");
32+
33+
writer.WriteDirectThroughStream(stb.ToString());
34+
}
35+
}
36+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Collections.Generic;
2+
using CorpusExplorer.Sdk.Action.Properties;
3+
using CorpusExplorer.Sdk.Addon;
4+
using CorpusExplorer.Sdk.Blocks;
5+
using CorpusExplorer.Sdk.Model;
6+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
7+
using CorpusExplorer.Sdk.ViewModel;
8+
using System.Data;
9+
using System.Linq;
10+
using CorpusExplorer.Sdk.Helper;
11+
12+
namespace CorpusExplorer.Sdk.Action
13+
{
14+
public class CrossFrequencySelectAction : IAction
15+
{
16+
public string Action => "cross-frequency-select";
17+
public string Description => "cross-frequency-select [LAYER] [WORDS] - calculates the cross-frequency for [WORDS] based on [LAYER]";
18+
19+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
20+
{
21+
if (args.Length < 2)
22+
return;
23+
24+
var queries = new HashSet<string>(args.Skip(1));
25+
26+
var layerName = args[0];
27+
var block = selection.CreateBlock<CrossFrequencySelectedBlock>();
28+
block.LayerDisplayname = layerName;
29+
block.LayerQueries = queries;
30+
block.Calculate();
31+
32+
var fdic = block.CooccurrencesFrequency.CompleteDictionaryToFullDictionary();
33+
34+
var dt = new DataTable();
35+
dt.Columns.Add("Query", typeof(string));
36+
dt.Columns.Add(layerName, typeof(string));
37+
dt.Columns.Add("Frequency", typeof(double));
38+
dt.BeginLoadData();
39+
foreach (var q in queries)
40+
if (fdic.ContainsKey(q))
41+
foreach (var x in fdic[q])
42+
dt.Rows.Add(q, x.Key, x.Value);
43+
dt.EndLoadData();
44+
45+
writer.WriteTable(selection.Displayname, dt);
46+
}
47+
}
48+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Data;
2+
using System.Linq;
3+
using CorpusExplorer.Sdk.Addon;
4+
using CorpusExplorer.Sdk.Blocks;
5+
using CorpusExplorer.Sdk.Blocks.Range;
6+
using CorpusExplorer.Sdk.Model;
7+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
8+
9+
namespace CorpusExplorer.Sdk.Action
10+
{
11+
public class CrossFrequencySelectRangeAction : IAction
12+
{
13+
public string Action => "cross-frequency-select-range";
14+
public string Description => "cross-frequency-select-range [LAYER] [WORDS] [FROM] [TO] - calculates the cross-frequency for [WORDS] based on [LAYER] in range (FROM/TO)";
15+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
16+
{
17+
var block = selection.CreateBlock<CrossFrequencySelectedRangeBlock>();
18+
block.LayerDisplayname = args[0];
19+
block.Ranges = new RangeSimple(int.Parse(args[1]), int.Parse(args[2]));
20+
block.LayerQueries = args.Skip(3).ToArray();
21+
block.Calculate();
22+
23+
var dt = new DataTable();
24+
dt.Columns.Add($"{args[0]} (A)");
25+
dt.Columns.Add($"{args[0]} (B)");
26+
dt.Columns.Add("Frequency");
27+
28+
dt.BeginLoadData();
29+
foreach (var x in block.CooccurrencesFrequency)
30+
foreach (var y in x.Value)
31+
dt.Rows.Add(x.Key, y.Key, y.Value);
32+
dt.EndLoadData();
33+
34+
writer.WriteTable(dt);
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)