Skip to content

Commit 373e1e8

Browse files
committed
// new actions
1 parent e96fb4f commit 373e1e8

7 files changed

Lines changed: 194 additions & 0 deletions

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@
9898
<Compile Include="CooccurrenceDiversityAction.cs" />
9999
<Compile Include="CooccurrencePolarisationAction.cs" />
100100
<Compile Include="CooccurrenceSelectedCorrespondingAction.cs" />
101+
<Compile Include="CorpusFiniteStateMachineAction.cs" />
101102
<Compile Include="CorrespondingValuesAction.cs" />
102103
<Compile Include="CrossFrequencyCorrespondingAction.cs" />
103104
<Compile Include="CrossFrequencySelectAction.cs" />
105+
<Compile Include="CrossFrequencySelectRangeAction.cs" />
104106
<Compile Include="CutOffPhraseAction.cs" />
105107
<Compile Include="DisambiguationeAction.cs" />
106108
<Compile Include="DispersionAction.cs" />
@@ -114,6 +116,7 @@
114116
<Compile Include="Frequency1RawSelectAction.cs" />
115117
<Compile Include="Frequency2RawAction.cs" />
116118
<Compile Include="CentralSnipTreeAction.cs" />
119+
<Compile Include="NGramCharAction.cs" />
117120
<Compile Include="Phrase2LayerCountAction.cs" />
118121
<Compile Include="Frequency3RawAction.cs" />
119122
<Compile Include="Helper\ConvertToDigraphHelper.cs" />
@@ -187,13 +190,16 @@
187190
<Compile Include="QueryCountDocumentsAction.cs" />
188191
<Compile Include="QueryCountSentencesAction.cs" />
189192
<Compile Include="QueryListAction.cs" />
193+
<Compile Include="ReadingEaseAction.cs" />
190194
<Compile Include="RemoveLayerAction.cs" />
191195
<Compile Include="RemoveMetaAction.cs" />
192196
<Compile Include="SentenceCountAction.cs" />
193197
<Compile Include="SizeAction.cs" />
198+
<Compile Include="SkipgramAction.cs" />
194199
<Compile Include="StopwordListAction.cs" />
195200
<Compile Include="StyleBurrowsDeltaAction.cs" />
196201
<Compile Include="StyleNgramAction.cs" />
202+
<Compile Include="TermDocumentMatrixAction.cs" />
197203
<Compile Include="TermFrequencyInverseDocumentFrequencyAction.cs" />
198204
<Compile Include="DocumentTermFrequencyAction.cs" />
199205
<Compile Include="TokenCountAction.cs" />
@@ -210,6 +216,10 @@
210216
<None Include="packages.config" />
211217
</ItemGroup>
212218
<ItemGroup>
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>
222+
</ProjectReference>
213223
<ProjectReference Include="..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\CorpusExplorer.Sdk\CorpusExplorer.Sdk.csproj">
214224
<Project>{dc1b5a58-29da-476d-89f8-e73a1db11e52}</Project>
215225
<Name>CorpusExplorer.Sdk</Name>
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: 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+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using CorpusExplorer.Sdk.Addon;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using CorpusExplorer.Sdk.Model;
7+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
8+
using CorpusExplorer.Sdk.ViewModel;
9+
10+
namespace CorpusExplorer.Sdk.Action
11+
{
12+
public class NGramCharAction : IAction
13+
{
14+
public string Action => "ngram-char";
15+
public string Description => "ngram-char [N] {LAYER} - [N] sized Char-N-gram based on {LAYER} (default: Wort)";
16+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
17+
{
18+
if (args.Length < 1)
19+
return;
20+
21+
var vm = new NgramPhoneticViewModel
22+
{
23+
Selection = selection,
24+
NGramSize = int.Parse(args[0]),
25+
LayerDisplayname = args.Length > 2 ? args[1] : "Wort"
26+
};
27+
vm.Execute();
28+
29+
writer.WriteTable(vm.GetDataTable());
30+
}
31+
}
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using CorpusExplorer.Sdk.Addon;
2+
using CorpusExplorer.Sdk.Extern.NHunspell.ViewModel;
3+
using CorpusExplorer.Sdk.Model;
4+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
5+
6+
namespace CorpusExplorer.Sdk.Action
7+
{
8+
public class ReadingEaseAction : IAction
9+
{
10+
public string Action => "reading-ease";
11+
public string Description => "reading-ease [LAYER] - calculates reading ease metrics based on [LAYER]";
12+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
13+
{
14+
var vm = new ReadingEaseViewModel
15+
{
16+
Selection = selection,
17+
LayerDisplayname = args[0]
18+
};
19+
vm.Execute();
20+
21+
writer.WriteTable(vm.GetDataTable());
22+
}
23+
}
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using CorpusExplorer.Sdk.Addon;
2+
using CorpusExplorer.Sdk.Model;
3+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
4+
using CorpusExplorer.Sdk.ViewModel;
5+
6+
namespace CorpusExplorer.Sdk.Action
7+
{
8+
public class SkipgramAction : IAction
9+
{
10+
public string Action => "skipgram";
11+
public string Description => "skipgram [LAYER] - calculates skipgrams for [LAYER]";
12+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
13+
{
14+
if (args.Length < 1)
15+
return;
16+
17+
var vm = new NormalizedSkipgramProbabilityViewModel
18+
{
19+
Selection = selection,
20+
LayerDisplayname = args[0],
21+
};
22+
vm.Execute();
23+
24+
writer.WriteTable(vm.GetDataTable());
25+
}
26+
}
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using CorpusExplorer.Sdk.Addon;
2+
using CorpusExplorer.Sdk.Model;
3+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
4+
using CorpusExplorer.Sdk.ViewModel;
5+
6+
namespace CorpusExplorer.Sdk.Action
7+
{
8+
public class TermDocumentMatrixAction : IAction
9+
{
10+
public string Action => "td-matrix";
11+
public string Description => "td-matrix [LAYER] [META] - calculates a term-document matrix for [LAYER] based on [META]";
12+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
13+
{
14+
if (args.Length < 2)
15+
return;
16+
17+
var vm = new TermDocumentMatrixViewModel
18+
{
19+
Selection = selection,
20+
LayerDisplayname = args[0],
21+
MetadataKey = args[2]
22+
};
23+
vm.Execute();
24+
25+
writer.WriteTable(vm.GetDataTable());
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)