Initial commit

This commit is contained in:
2022-07-06 21:35:05 +02:00
commit b2494052ff
97220 changed files with 2449256 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
@@ -0,0 +1,18 @@
using Autofac;
using Gos.Infrastructure.CompositionRoot;
using Gos.Services.CompositionRoot;
namespace Gos.Console.CompositionRoot
{
public class ConsoleBootstrapper
{
public IContainer Bootstrap()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new InfrastructureModule());
builder.RegisterModule(new ServicesModule());
builder.RegisterModule(new ConsoleModule());
return builder.Build();
}
}
}
@@ -0,0 +1,14 @@
using Autofac;
using Gos.Core.Interfaces;
using Gos.Infrastructure.Sessions;
namespace Gos.Console.CompositionRoot;
public class ConsoleModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<DefaultSessionIdResolver>().As<ISessionIdResolver>().SingleInstance();
builder.RegisterType<DefaultTraceIdentifierResolver>().As<ITraceIdentifierResolver>().SingleInstance();
}
}
+3
View File
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base
COPY ["./publish", "."]
CMD tail -f /dev/null
+19
View File
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="CommandLineParser" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Gos.Infrastructure\Gos.Infrastructure.csproj" />
<ProjectReference Include="..\Gos.Services\Gos.Services.csproj" />
</ItemGroup>
</Project>
+109
View File
@@ -0,0 +1,109 @@
using System.Threading.Tasks;
using Autofac;
using CommandLine;
using Gos.Console.CompositionRoot;
using Gos.ServiceModel.Requests.Corpus;
using Gos.Services.Framework;
using MediatR;
namespace Gos.Console
{
internal class Program
{
private static IContainer container;
private static async Task<int> HandleDeleteCorpusIndex(IMediator mediator, DeleteCorpusIndexOptions opt)
{
await mediator.Send(new DeleteCorpusIndex());
return 3;
}
private static async Task<int> HandleImportCorpus(IMediator mediator, ImportCorpusOptions opt)
{
await mediator.Send(
new ImportCorpus
{
SourcePath = opt.SourcePath
});
return 1;
}
private static async Task<int> HandleIndexCorpus(IMediator mediator, IndexCorpusOptions opt)
{
// Warm up cache with part of speeches and msds
container.Resolve<CacheWarmUp>().WarmUp();
await mediator.Send(new IndexCorpus());
return 2;
}
private static async Task<int> HandleImportCounters(IMediator mediator, ImportCountersOptions opt)
{
await mediator.Send(
new ImportCounters
{
SourcePath = opt.SourcePath,
});
return 3;
}
private static async Task<int> HandleImportLexicon(IMediator mediator, ImportLexiconOptions opt)
{
await mediator.Send(
new ImportLexicon()
{
SourcePath = opt.SourcePath,
});
return 4;
}
public static async Task Main(string[] args)
{
container = new ConsoleBootstrapper().Bootstrap();
var mediator = container.Resolve<IMediator>();
await Parser.Default
.ParseArguments<ImportCorpusOptions, IndexCorpusOptions, DeleteCorpusIndexOptions, ImportCountersOptions, ImportLexiconOptions>(args)
.MapResult(
(ImportCorpusOptions opt) => HandleImportCorpus(mediator, opt),
(DeleteCorpusIndexOptions opt) => HandleDeleteCorpusIndex(mediator, opt),
(IndexCorpusOptions opt) => HandleIndexCorpus(mediator, opt),
(ImportCountersOptions opt) => HandleImportCounters(mediator, opt),
(ImportLexiconOptions opt) => HandleImportLexicon(mediator, opt),
errs => Task.FromResult(0));
System.Console.WriteLine("Finished. Press any key to continue...");
System.Console.ReadKey();
}
[Verb("deleteindex", HelpText = "Delete corpus index")]
private class DeleteCorpusIndexOptions
{
}
[Verb("import", HelpText = "Imports corpus to database")]
private class ImportCorpusOptions
{
[Option("path", HelpText = "Full path to xml file")]
public string SourcePath { get; set; }
}
[Verb("index", HelpText = "Indexes corpus to ElasticSearch")]
private class IndexCorpusOptions
{
}
[Verb("counters", HelpText = "Imports counters and forms/lemmas to database")]
private class ImportCountersOptions
{
[Option("path", HelpText = "Full path to xml file")]
public string SourcePath { get; set; }
}
[Verb("lexicon", HelpText = "Imports lexicon forms/lemmas to database")]
private class ImportLexiconOptions
{
[Option("path", HelpText = "Full path to xml file")]
public string SourcePath { get; set; }
}
}
}