This commit is contained in:
simmdan 2021-03-09 20:49:16 +00:00
Родитель f5be994633
Коммит 143e7e24a0
254 изменённых файлов: 102149 добавлений и 226 удалений

Просмотреть файл

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProgramSynthesis" Version="7.27.0" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,144 +0,0 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.ProgramSynthesis.Compound.Split.Constraints;
using Constraint = Microsoft.ProgramSynthesis.Wrangling.Constraints.Constraint
<Microsoft.ProgramSynthesis.DslLibrary.StringRegion,
Microsoft.ProgramSynthesis.Wrangling.Schema.TableOutput.ITable
<Microsoft.ProgramSynthesis.DslLibrary.StringRegion>>;
namespace Microsoft.ProgramSynthesis.Compound.Split.Sample
{
/// <summary>
/// Sample of how to restrict the language expressiveness of Split API
/// and read the properties of the synthesized program.
/// </summary>
public static class SampleProgram
{
private static void Main(string[] args)
{
RestrictedDslSample();
FixedWidthOrDelimitedDemo();
Console.WriteLine("\nDone.");
}
private static void RestrictedDslSample()
{
var input =
@"#This is a comment
#number1 number2
1 2
3 4
5 6
";
var constraints = new Constraint[] { new SimpleDelimiter() };
var stringSession = new Session();
stringSession.AddInput(input);
stringSession.Constraints.Add(constraints);
var streamSession = new Session();
// Create stream from string
streamSession.AddInput(new StringReader(input));
streamSession.Constraints.Add(constraints);
Session[] sessions = { stringSession, streamSession };
foreach (Session session in sessions)
{
Program program = session.Learn();
Console.WriteLine($"Skip lines = {program.Properties.SkipLinesCount}");
Console.WriteLine($"Column delimiter = {program.Properties.ColumnDelimiter}");
Console.WriteLine($"New line string = {string.Join(",", program.Properties.NewLineStrings)}");
Console.WriteLine($"Column count = {program.Properties.ColumnCount}");
if (program.Properties.RawColumnNames != null)
{
Console.WriteLine($"Column names = {string.Join(",", program.Properties.RawColumnNames)}");
}
Console.WriteLine();
}
}
private static void FixedWidthOrDelimitedDemo()
{
// two sample files containing the same data, one in delimited format and the other in fixed-width format:
var delimitedFile =
@"#This is a comment
#num1; num2; word1
12; 21132; abc
3123; 42; d
5; 625; ef
";
var fixedWidthFile =
@"#This is a comment
#num1 num2 word1
12 21132abc
3123 42 d
5 625 ef
";
// we first consider the case where we do not know if the file is delimited or fixed width,
// and would like to determine the file type and metadata
Session session = new Session();
session.Constraints.Add(new SimpleDelimiterOrFixedWidth());
// we first check the sample fixed-width file
session.Inputs.Add(Session.CreateStringRegion(fixedWidthFile));
Program program = session.Learn();
Console.WriteLine($"Inferring the fixed-width file properties without knowing the file format:");
PrintProperties(program);
// we now check the sample delimited file
session.Inputs.Clear();
session.Inputs.Add(Session.CreateStringRegion(delimitedFile));
program = session.Learn();
Console.WriteLine($"Inferring the delimited file properties without knowing the file format:");
PrintProperties(program);
// we now consider the case where we know that the file is fixed-width and just want to get the metadata such as column start positions
session.Inputs.Clear();
session.Constraints.Clear();
session.Constraints.Add(new FixedWidth());
session.Inputs.Add(Session.CreateStringRegion(fixedWidthFile));
program = session.Learn();
Console.WriteLine($"Inferring the fixed width file properties when we know the format is fixed-width:");
PrintProperties(program);
// we now consider the case where we know the file is delimited and just want to get the metadata such as delimiters used
session.Inputs.Clear();
session.Constraints.Clear();
session.Constraints.Add(new SimpleDelimiter());
session.Inputs.Add(Session.CreateStringRegion(delimitedFile));
program = session.Learn();
Console.WriteLine($"Inferring the delimited file properties when we know the format is delimited:");
PrintProperties(program);
}
private static void PrintProperties(Program program)
{
if (program.Properties.FieldPositions == null)
{
Console.WriteLine("File type: Delimited");
Console.WriteLine($"Column delimiter = {program.Properties.ColumnDelimiter}");
}
else
{
Console.WriteLine("File type: Fixed-width");
var positions = program.Properties.FieldPositions.Select(p => $"({p.Item1}, {p.Item2?.ToString() ?? "null"})");
Console.WriteLine($"Field positions = [ {string.Join(", ", positions)} ]");
}
Console.WriteLine($"Skip lines = {program.Properties.SkipLinesCount}");
Console.WriteLine($"New line string = {string.Join(",", program.Properties.NewLineStrings)}");
Console.WriteLine($"Column count = {program.Properties.ColumnCount}");
if (program.Properties.RawColumnNames != null)
{
Console.WriteLine($"Column names = {string.Join(", ", program.Properties.RawColumnNames)}");
}
Console.WriteLine();
}
}
}

Просмотреть файл

@ -1,13 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_OWNER_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INVOCABLE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OTHER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

Просмотреть файл

@ -1,35 +1,34 @@
# Microsoft Program Synthesis using Examples SDK
The Program Synthesis using Examples (PROSE) SDK includes a set of technologies for the automatic generation of
programs from input-output examples. This repo includes samples and sample data for the Microsoft PROSE SDK.
The Program Synthesis using Examples (PROSE) SDK includes a set of technologies for the automatic generation of programs
from input-output examples. This repo includes samples, release notes, and some other miscellaneous projects related to
the Microsoft PROSE SDK.
The samples are split into three categories:
The samples are split into two categories:
* Data wrangling samples in [WranglingSamples.sln](WranglingSamples.sln). This sample shows how to use the PROSE
Data Wrangling API.
* Program synthesis samples in [ProseSamples.sln](ProseSamples.sln). This sample shows how to instantiate the
framework to build a synthesizer for a new DSL.
* PROSE DSL authoring Tutorial in [DslAuthoringTutorial](DslAuthoringTutorial). This sample demonstrates in a
step-by-step manner how to instantiate the framework to build a synthesizer for a new DSL. It is mainly used
during PROSE workshops.
- Samples for using existing PROSE DSL APIs to accomplish tasks in [api-samples/api-samples.sln](WranglingSamples.sln).
- Samples for creating program synthesis solutions using the PROSE SDK by authoring a DSL in the
[dsl-samples](dsl-samples) directory:
- [DSL authoring tutorial](dsl-samples/tutorial)
- [ProseSample](dsl-samples/ProseSample/ProseSample.sln)
- [DSL for merge conflict resolution](dsl-samples/MergeConflictsResolution/MergeConflictsResolution.sln)
Find guides for these sample projects here: [https://microsoft.github.io/prose/](https://microsoft.github.io/prose/)
You can find guides for some of these sample projects and other information about the PROSE project here:
[https://microsoft.github.io/prose/](https://microsoft.github.io/prose/)
Optionally, you can get started quickly using [Docker](https://www.docker.com/get-started):
```sh
git clone https://github.com/microsoft/prose.git
cd prose
docker build -t prose-samples .
docker run -it --rm -v "$(pwd):/opt/prose-samples" -w "/opt/prose-samples" prose-samples bash
# Inside the Docker container
cd ProgramSynthesis/ProseSample # ... or the directory for any other sample
cd dsl-samples/ProseSample/ProseSample # ... or the directory for any other sample project
dotnet run # run the sample in the current directory
```
---
This project has adopted the [Microsoft Open Source Code of
Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct
FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com)
with any additional questions or comments.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

Просмотреть файл

@ -1,19 +0,0 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_OWNER_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INVOCABLE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OTHER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Split.Text", "Split.Text\Sp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Extraction.Web", "Extraction.Web\Extraction.Web.csproj", "{871F907C-5802-4315-8AE2-2946FE3B09EB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Compound.Split", "Compound.Split\Compound.Split.csproj", "{302ECB80-C621-4D1F-90DA-F34EFDD0535E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkDriver", "BenchmarkDriver\BenchmarkDriver.csproj", "{FDA8F791-363A-47E2-A265-51F84B176EAB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Read.FlatFile", "Read.FlatFile\Read.FlatFile.csproj", "{C1B7ECDF-C339-4E86-96BF-EBF652B78419}"
EndProject
Global
@ -56,18 +52,6 @@ Global
{871F907C-5802-4315-8AE2-2946FE3B09EB}.RecompileAndRelease|Any CPU.Build.0 = Release|Any CPU
{871F907C-5802-4315-8AE2-2946FE3B09EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{871F907C-5802-4315-8AE2-2946FE3B09EB}.Release|Any CPU.Build.0 = Release|Any CPU
{302ECB80-C621-4D1F-90DA-F34EFDD0535E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{302ECB80-C621-4D1F-90DA-F34EFDD0535E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{302ECB80-C621-4D1F-90DA-F34EFDD0535E}.RecompileAndRelease|Any CPU.ActiveCfg = Release|Any CPU
{302ECB80-C621-4D1F-90DA-F34EFDD0535E}.RecompileAndRelease|Any CPU.Build.0 = Release|Any CPU
{302ECB80-C621-4D1F-90DA-F34EFDD0535E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{302ECB80-C621-4D1F-90DA-F34EFDD0535E}.Release|Any CPU.Build.0 = Release|Any CPU
{FDA8F791-363A-47E2-A265-51F84B176EAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDA8F791-363A-47E2-A265-51F84B176EAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDA8F791-363A-47E2-A265-51F84B176EAB}.RecompileAndRelease|Any CPU.ActiveCfg = Debug|Any CPU
{FDA8F791-363A-47E2-A265-51F84B176EAB}.RecompileAndRelease|Any CPU.Build.0 = Debug|Any CPU
{FDA8F791-363A-47E2-A265-51F84B176EAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDA8F791-363A-47E2-A265-51F84B176EAB}.Release|Any CPU.Build.0 = Release|Any CPU
{C1B7ECDF-C339-4E86-96BF-EBF652B78419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1B7ECDF-C339-4E86-96BF-EBF652B78419}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1B7ECDF-C339-4E86-96BF-EBF652B78419}.RecompileAndRelease|Any CPU.ActiveCfg = Release|Any CPU

Просмотреть файл

@ -2,13 +2,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample", "ProgramSynthesis\ProseSample\ProseSample.csproj", "{C7FC4D3C-3CAE-42B9-AFF9-83CB07A7872F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample", "ProseSample\ProseSample.csproj", "{C7FC4D3C-3CAE-42B9-AFF9-83CB07A7872F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample.Substrings.Semantics", "ProgramSynthesis\ProseSample.Substrings.Semantics\ProseSample.Substrings.Semantics.csproj", "{997C015E-6C5F-495B-A6A7-648E0837EC6D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample.Substrings.Semantics", "ProseSample.Substrings.Semantics\ProseSample.Substrings.Semantics.csproj", "{997C015E-6C5F-495B-A6A7-648E0837EC6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample.Substrings", "ProgramSynthesis\ProseSample.Substrings\ProseSample.Substrings.csproj", "{41E9A9B1-B013-4A87-9759-E3004FEF8A81}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample.Substrings", "ProseSample.Substrings\ProseSample.Substrings.csproj", "{41E9A9B1-B013-4A87-9759-E3004FEF8A81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample.TextExtraction", "ProgramSynthesis\ProseSample.TextExtraction\ProseSample.TextExtraction.csproj", "{5AA217F9-DEAB-46BE-81BE-AFD00948AC50}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProseSample.TextExtraction", "ProseSample.TextExtraction\ProseSample.TextExtraction.csproj", "{5AA217F9-DEAB-46BE-81BE-AFD00948AC50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

Просмотреть файл

Просмотреть файл

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше