Skip to content

Commit e96fb4f

Browse files
committed
// BurrowsDeltaAction.cs
// CooccurrenceClassicAction.cs // CooccurrenceDiversityAction.cs
1 parent 2cd369c commit e96fb4f

4 files changed

Lines changed: 118 additions & 0 deletions

File tree

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@
8787
<Compile Include="Abstract\AbstractFilterAction.cs" />
8888
<Compile Include="AddTaggerAction.cs" />
8989
<Compile Include="BasicInformationAction.cs" />
90+
<Compile Include="BurrowsDeltaAction.cs" />
9091
<Compile Include="CentralSnipAction.cs" />
9192
<Compile Include="ClusterAction.cs" />
9293
<Compile Include="ClusterListAction.cs" />
94+
<Compile Include="CooccurrenceClassicAction.cs" />
9395
<Compile Include="CooccurrenceCorrespondingAction.cs" />
9496
<Compile Include="CooccurrenceCrossAction.cs" />
9597
<Compile Include="CooccurrenceCrossFullAction.cs" />
98+
<Compile Include="CooccurrenceDiversityAction.cs" />
9699
<Compile Include="CooccurrencePolarisationAction.cs" />
97100
<Compile Include="CooccurrenceSelectedCorrespondingAction.cs" />
98101
<Compile Include="CorrespondingValuesAction.cs" />

0 commit comments

Comments
 (0)