Skip to content

Commit 5744484

Browse files
committed
// CooccurrenceNetworkAction.cs
1 parent 8c98baf commit 5744484

4 files changed

Lines changed: 81 additions & 3 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using CorpusExplorer.Sdk.Action.Helper;
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 CooccurrenceNetworkAction: IAction
10+
{
11+
public string Action => "cooccurrence-network";
12+
13+
public string Description => "cooccurrence-network [LAYER] {minSIGNI} {minFREQ} - significant cooccurrence-network for all [LAYER] values";
14+
15+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
16+
{
17+
var vm = new CooccurrenceViewModel { Selection = selection };
18+
if (args.Length >= 1)
19+
vm.LayerDisplayname = args[0];
20+
if (args.Length >= 2)
21+
vm.CooccurrenceMinSignificance = double.Parse(args[1]);
22+
if (args.Length >= 3)
23+
vm.CooccurrenceMinFrequency = int.Parse(args[2]);
24+
vm.Execute();
25+
26+
writer.WriteDirectThroughStream(ConvertToDigraphHelper.Convert(vm.SignificanceDictionary));
27+
}
28+
}
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using CorpusExplorer.Sdk.Action.Helper;
2+
using CorpusExplorer.Sdk.Addon;
3+
using CorpusExplorer.Sdk.Model;
4+
using CorpusExplorer.Sdk.Utils.DataTableWriter.Abstract;
5+
using CorpusExplorer.Sdk.ViewModel;
6+
using System.Linq;
7+
8+
namespace CorpusExplorer.Sdk.Action
9+
{
10+
public class CooccurrenceNetworkSelectAction : IAction
11+
{
12+
public string Action => "cooccurrence-network-select";
13+
14+
public string Description => "cooccurrence-network-select [LAYER] [minSIGNI] [minFREQ] [WORDS] - significant cooccurrence-network for all [LAYER] values";
15+
16+
public void Execute(Selection selection, string[] args, AbstractTableWriter writer)
17+
{
18+
var vm = new CooccurrenceNetworkSelectiveViewModel
19+
{
20+
Selection = selection,
21+
LayerDisplayname = args[0],
22+
CooccurrenceMinSignificance = double.Parse(args[1]),
23+
CooccurrenceMinFrequency = int.Parse(args[2]),
24+
LayerQueries = args.Skip(3)
25+
};
26+
vm.Execute();
27+
28+
writer.WriteDirectThroughStream(ConvertToDigraphHelper.Convert(vm.SignificanceDictionary));
29+
}
30+
}
31+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<ItemGroup>
5050
<Reference Include="System" />
5151
<Reference Include="System.Core" />
52+
<Reference Include="System.Drawing" />
5253
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
5354
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
5455
<Private>True</Private>
@@ -81,7 +82,20 @@
8182
</Reference>
8283
<Reference Include="System.Data.DataSetExtensions" />
8384
<Reference Include="System.Data" />
85+
<Reference Include="System.Windows.Forms" />
8486
<Reference Include="System.Xml" />
87+
<Reference Include="Telerik.WinControls, Version=2025.1.211.462, Culture=neutral, PublicKeyToken=5bb2a467cbec794e, processorArchitecture=MSIL">
88+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\lib\RCWF\2025.1.211.462\Telerik.WinControls.dll</HintPath>
89+
<Private>True</Private>
90+
</Reference>
91+
<Reference Include="Telerik.WinControls.UI, Version=2025.1.211.462, Culture=neutral, PublicKeyToken=5bb2a467cbec794e, processorArchitecture=MSIL">
92+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\lib\RCWF\2025.1.211.462\Telerik.WinControls.UI.dll</HintPath>
93+
<Private>True</Private>
94+
</Reference>
95+
<Reference Include="TelerikCommon, Version=2025.1.211.462, Culture=neutral, PublicKeyToken=5bb2a467cbec794e, processorArchitecture=MSIL">
96+
<HintPath>..\..\..\..\Projekte\CorpusExplorerV2\CorpusExplorer\lib\RCWF\2025.1.211.462\TelerikCommon.dll</HintPath>
97+
<Private>True</Private>
98+
</Reference>
8599
</ItemGroup>
86100
<ItemGroup>
87101
<Compile Include="Abstract\AbstractFilterAction.cs" />
@@ -96,6 +110,8 @@
96110
<Compile Include="CooccurrenceCrossAction.cs" />
97111
<Compile Include="CooccurrenceCrossFullAction.cs" />
98112
<Compile Include="CooccurrenceDiversityAction.cs" />
113+
<Compile Include="CooccurrenceNetworkSelectAction.cs" />
114+
<Compile Include="CooccurrenceNetworkAction.cs" />
99115
<Compile Include="CooccurrencePolarisationAction.cs" />
100116
<Compile Include="CooccurrenceSelectedCorrespondingAction.cs" />
101117
<Compile Include="CorpusFiniteStateMachineAction.cs" />

Action/CorpusExplorer.Sdk.Action/Helper/ConvertToDigraphHelper.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
using System.Globalization;
44
using System.Linq;
55
using System.Text;
6-
using System.Threading.Tasks;
76

87
namespace CorpusExplorer.Sdk.Action.Helper
98
{
109
public static class ConvertToDigraphHelper
1110
{
12-
public static string Convert(Tuple<string, int, string>[] connections)
11+
public static string Convert(Dictionary<string, Dictionary<string, double>> connections)
12+
=> Convert((from connection in connections from connection2 in connection.Value select new Tuple<string, int, string>(connection.Key, (int)connection2.Value, connection2.Key)));
13+
14+
public static string Convert(IEnumerable<Tuple<string, int, string>> connections)
1315
{
14-
if (connections == null || connections.Length == 0)
16+
if (connections == null || !connections.Any())
1517
return string.Empty;
1618

1719
var stb = new StringBuilder();

0 commit comments

Comments
 (0)