Skip to content

Commit eed1c81

Browse files
committed
Initial version
See readme for more info
1 parent 3b075ad commit eed1c81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+59042
-0
lines changed

NLP_Mark02.sln

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.21005.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLP_Mark02", "NLP_Mark02\NLP_Mark02.csproj", "{3125AB22-FFFB-45B0-B8F6-BD8B0E35A996}"
7+
EndProject
8+
Global
9+
GlobalSection(SubversionScc) = preSolution
10+
Svn-Managed = True
11+
Manager = AnkhSVN - Subversion Support for Visual Studio
12+
EndGlobalSection
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{3125AB22-FFFB-45B0-B8F6-BD8B0E35A996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{3125AB22-FFFB-45B0-B8F6-BD8B0E35A996}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{3125AB22-FFFB-45B0-B8F6-BD8B0E35A996}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{3125AB22-FFFB-45B0-B8F6-BD8B0E35A996}.Release|Any CPU.Build.0 = Release|Any CPU
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
EndGlobal

NLP_Mark02.v12.suo

51.5 KB
Binary file not shown.

NLP_Mark02/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

NLP_Mark02/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="NLP_Mark02.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>

NLP_Mark02/App.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace NLP_Mark02
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

NLP_Mark02/MainWindow.xaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Window x:Class="NLP_Mark02.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
Title="Wit.ai NLP Mark 02 " Height="586.013" Width="467.006" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
5+
<Grid>
6+
<Label Content="Type a sentence and press [enter], and I will try to parse it." HorizontalAlignment="Left" Margin="32,23,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
7+
<Label Content="You:" HorizontalAlignment="Left" Margin="34,71,0,0" VerticalAlignment="Top"/>
8+
<TextBox x:Name="tbYou" HorizontalAlignment="Left" Height="41" Margin="93,75,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="340" KeyUp="tbYou_KeyUp" MaxLength="255"/>
9+
<Label Content="I:" HorizontalAlignment="Left" Margin="49,184,0,0" VerticalAlignment="Top"/>
10+
<TextBox x:Name="tbRaw" HorizontalAlignment="Left" Height="167" Margin="95,334,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="340" VerticalScrollBarVisibility="Visible"/>
11+
<Label Content="Raw:" HorizontalAlignment="Left" Margin="34,334,0,0" VerticalAlignment="Top"/>
12+
<TextBox x:Name="tbI" HorizontalAlignment="Left" Height="125" Margin="95,184,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="340"/>
13+
<Label x:Name="lblYou" Content="" HorizontalAlignment="Left" Height="49" Margin="93,121,0,0" VerticalAlignment="Top" Width="338" ScrollViewer.VerticalScrollBarVisibility="Auto"/>
14+
<Label Content="Developed by Sam Kraaijveld, powered by wit.ai" HorizontalAlignment="Left" Margin="19,513,0,0" VerticalAlignment="Top" FontSize="10"/>
15+
<Button Content="Exit" HorizontalAlignment="Left" Margin="311,514,0,0" VerticalAlignment="Top" Width="122" Click="Button_Click"/>
16+
17+
</Grid>
18+
</Window>

NLP_Mark02/MainWindow.xaml.cs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
using System.Net.Http;
16+
using System.IO;
17+
using System.Net;
18+
using System.Text.RegularExpressions;
19+
using System.Reflection;
20+
21+
namespace NLP_Mark02
22+
{
23+
/// <summary>
24+
/// Interaction logic for MainWindow.xaml
25+
/// </summary>
26+
public partial class MainWindow : Window
27+
{
28+
// O_NLP.RootObject is a respons from wit
29+
Objects.O_NLP.RootObject oNLP = new Objects.O_NLP.RootObject();
30+
31+
// NLP_Processing is the code that processes the respons from wit
32+
Vitals.NLP.NLP_Processing vitNLP = new Vitals.NLP.NLP_Processing();
33+
34+
35+
public MainWindow()
36+
{
37+
InitializeComponent();
38+
39+
tbYou.Focus();
40+
}
41+
42+
private void tbYou_KeyUp(object sender, KeyEventArgs e)
43+
{
44+
if (e.Key == Key.Enter && tbYou.Text.Length > 0)
45+
{
46+
StartProcessing(tbYou.Text);
47+
48+
lblYou.Content = "You said: " + tbYou.Text;
49+
tbYou.Text = "";
50+
tbI.Text = "Hold on..";
51+
tbYou.Focus();
52+
}
53+
}
54+
55+
// Async + wait keeps the gui thread responsive
56+
public async void StartProcessing(string text)
57+
{
58+
try
59+
{
60+
string modtext = Vitals.NLP.Pre_NLP_Processing.preprocessText(text);
61+
62+
string nlp_text = await vitNLP.ProcessNLP(modtext);
63+
tbRaw.Text = nlp_text;
64+
65+
oNLP = Vitals.NLP.Post_NLP_Processing.ParseData(nlp_text);
66+
67+
// This codeblock dynamically casts the intent to the corresponding class
68+
Assembly objAssembly;
69+
objAssembly = Assembly.GetExecutingAssembly();
70+
71+
Type classType = objAssembly.GetType("NLP_Mark02.Vitals.Brain." + oNLP.outcome.intent);
72+
73+
object obj = Activator.CreateInstance(classType);
74+
75+
MethodInfo mi = classType.GetMethod("makeSentence");
76+
77+
object[] parameters = new object[1];
78+
parameters[0] = oNLP;
79+
80+
mi = classType.GetMethod("makeSentence");
81+
string sentence;
82+
sentence = (string)mi.Invoke(obj, parameters);
83+
84+
// Show what was deducted from the sentence
85+
tbI.Text = sentence;
86+
}
87+
catch (Exception ex)
88+
{
89+
tbI.Text = "Sorry, no idea what's what. Try again later please!" + Environment.NewLine + "I bumped onto this error: " + ex.Message;
90+
}
91+
}
92+
93+
private void Button_Click(object sender, RoutedEventArgs e)
94+
{
95+
Application.Current.Shutdown();
96+
}
97+
}
98+
}

NLP_Mark02/NLP_Mark02.csproj

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{3125AB22-FFFB-45B0-B8F6-BD8B0E35A996}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>NLP_Mark02</RootNamespace>
11+
<AssemblyName>NLP_Mark02</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
15+
<WarningLevel>4</WarningLevel>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38+
<SpecificVersion>False</SpecificVersion>
39+
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
40+
</Reference>
41+
<Reference Include="System" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Drawing" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Runtime.Serialization" />
46+
<Reference Include="System.Web" />
47+
<Reference Include="System.Xml" />
48+
<Reference Include="Microsoft.CSharp" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="System.Xaml">
53+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
54+
</Reference>
55+
<Reference Include="WindowsBase" />
56+
<Reference Include="PresentationCore" />
57+
<Reference Include="PresentationFramework" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<ApplicationDefinition Include="App.xaml">
61+
<Generator>MSBuild:Compile</Generator>
62+
<SubType>Designer</SubType>
63+
</ApplicationDefinition>
64+
<Compile Include="Objects\O_NLP.cs" />
65+
<Compile Include="Vitals\Brain\Action.cs" />
66+
<Compile Include="Vitals\Brain\Appointment.cs" />
67+
<Compile Include="Vitals\Brain\Farewell.cs" />
68+
<Compile Include="Vitals\Brain\Give.cs" />
69+
<Compile Include="Vitals\Brain\Greeting.cs" />
70+
<Compile Include="Vitals\Brain\Question.cs" />
71+
<Compile Include="Vitals\NLP\Post_NLP_Processing.cs" />
72+
<Compile Include="Vitals\NLP\Pre_NLP_Processing.cs" />
73+
<Compile Include="Vitals\NLP\NLP_Processing.cs" />
74+
<Page Include="MainWindow.xaml">
75+
<Generator>MSBuild:Compile</Generator>
76+
<SubType>Designer</SubType>
77+
</Page>
78+
<Compile Include="App.xaml.cs">
79+
<DependentUpon>App.xaml</DependentUpon>
80+
<SubType>Code</SubType>
81+
</Compile>
82+
<Compile Include="MainWindow.xaml.cs">
83+
<DependentUpon>MainWindow.xaml</DependentUpon>
84+
<SubType>Code</SubType>
85+
</Compile>
86+
</ItemGroup>
87+
<ItemGroup>
88+
<Compile Include="Properties\AssemblyInfo.cs">
89+
<SubType>Code</SubType>
90+
</Compile>
91+
<Compile Include="Properties\Resources.Designer.cs">
92+
<AutoGen>True</AutoGen>
93+
<DesignTime>True</DesignTime>
94+
<DependentUpon>Resources.resx</DependentUpon>
95+
</Compile>
96+
<Compile Include="Properties\Settings.Designer.cs">
97+
<AutoGen>True</AutoGen>
98+
<DependentUpon>Settings.settings</DependentUpon>
99+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
100+
</Compile>
101+
<EmbeddedResource Include="Properties\Resources.resx">
102+
<Generator>ResXFileCodeGenerator</Generator>
103+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
104+
</EmbeddedResource>
105+
<None Include="packages.config" />
106+
<None Include="Properties\Settings.settings">
107+
<Generator>SettingsSingleFileGenerator</Generator>
108+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
109+
</None>
110+
<AppDesigner Include="Properties\" />
111+
</ItemGroup>
112+
<ItemGroup>
113+
<None Include="App.config" />
114+
</ItemGroup>
115+
<ItemGroup>
116+
<WCFMetadata Include="Service References\" />
117+
</ItemGroup>
118+
<ItemGroup>
119+
<Folder Include="Resources\" />
120+
</ItemGroup>
121+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
122+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
123+
Other similar extension points exist, see Microsoft.Common.targets.
124+
<Target Name="BeforeBuild">
125+
</Target>
126+
<Target Name="AfterBuild">
127+
</Target>
128+
-->
129+
</Project>

0 commit comments

Comments
 (0)