├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── Phraser.sln ├── Phraser ├── AppWizReadMe.txt ├── Phraser.cpp ├── Phraser.vcxproj ├── Phraser.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── PhraserGram ├── App.config ├── PhraserGram.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Roslyn cache directories 20 | *.ide/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | 100 | # MightyMoose 101 | *.mm.* 102 | AutoTest.Net/ 103 | 104 | # Web workbench (sass) 105 | .sass-cache/ 106 | 107 | # Installshield output folder 108 | [Ee]xpress/ 109 | 110 | # DocProject is a documentation generator add-in 111 | DocProject/buildhelp/ 112 | DocProject/Help/*.HxT 113 | DocProject/Help/*.HxC 114 | DocProject/Help/*.hhc 115 | DocProject/Help/*.hhk 116 | DocProject/Help/*.hhp 117 | DocProject/Help/Html2 118 | DocProject/Help/html 119 | 120 | # Click-Once directory 121 | publish/ 122 | 123 | # Publish Web Output 124 | *.[Pp]ublish.xml 125 | *.azurePubxml 126 | ## TODO: Comment the next line if you want to checkin your 127 | ## web deploy settings but do note that will include unencrypted 128 | ## passwords 129 | #*.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/* 133 | ## TODO: If the tool you use requires repositories.config 134 | ## uncomment the next line 135 | #!packages/repositories.config 136 | 137 | # Enable "build/" folder in the NuGet Packages folder since 138 | # NuGet packages use it for MSBuild targets. 139 | # This line needs to be after the ignore of the build folder 140 | # (and the packages folder if the line above has been uncommented) 141 | !packages/build/ 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # LightSwitch generated files 187 | GeneratedArtifacts/ 188 | _Pvt_Extensions/ 189 | ModelManifest.xml -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Peder Sparell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Phraser.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Phraser", "Phraser\Phraser.vcxproj", "{CA51586D-0565-4B43-AE76-8D8BD1D36438}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{58D3B1EB-7CF7-44F0-B256-FC3EFF820A2F}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhraserGram", "PhraserGram\PhraserGram.csproj", "{4DEF8280-F526-4FCA-9492-419EA5A0F846}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|Mixed Platforms = Debug|Mixed Platforms 16 | Debug|Win32 = Debug|Win32 17 | Debug|x64 = Debug|x64 18 | Release|Any CPU = Release|Any CPU 19 | Release|Mixed Platforms = Release|Mixed Platforms 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|Any CPU.ActiveCfg = Debug|Win32 25 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 26 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|Mixed Platforms.Build.0 = Debug|x64 27 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|Win32.Build.0 = Debug|Win32 29 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|x64.ActiveCfg = Debug|x64 30 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Debug|x64.Build.0 = Debug|x64 31 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|Any CPU.ActiveCfg = Release|Win32 32 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|Mixed Platforms.ActiveCfg = Release|Win32 33 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|Mixed Platforms.Build.0 = Release|Win32 34 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|Win32.ActiveCfg = Release|Win32 35 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|Win32.Build.0 = Release|Win32 36 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|x64.ActiveCfg = Release|x64 37 | {CA51586D-0565-4B43-AE76-8D8BD1D36438}.Release|x64.Build.0 = Release|x64 38 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 41 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 42 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|Win32.ActiveCfg = Debug|Any CPU 43 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|Win32.Build.0 = Debug|Any CPU 44 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|x64.ActiveCfg = Debug|x64 45 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Debug|x64.Build.0 = Debug|x64 46 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 49 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|Mixed Platforms.Build.0 = Release|Any CPU 50 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|Win32.ActiveCfg = Release|Any CPU 51 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|Win32.Build.0 = Release|Any CPU 52 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|x64.ActiveCfg = Release|x64 53 | {4DEF8280-F526-4FCA-9492-419EA5A0F846}.Release|x64.Build.0 = Release|x64 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | EndGlobal 59 | -------------------------------------------------------------------------------- /Phraser/AppWizReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : Phraser Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this Phraser application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your Phraser application. 9 | 10 | 11 | Phraser.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | Phraser.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | Phraser.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named Phraser.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /Phraser/Phraser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sparell/Phraser/b8346b3182a782ec7f4edc680d073e3ae89dc31c/Phraser/Phraser.cpp -------------------------------------------------------------------------------- /Phraser/Phraser.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {CA51586D-0565-4B43-AE76-8D8BD1D36438} 23 | Win32Proj 24 | Phraser 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Application 37 | true 38 | v140 39 | Unicode 40 | Dynamic 41 | 42 | 43 | Application 44 | true 45 | v140 46 | Unicode 47 | Dynamic 48 | 49 | 50 | Application 51 | false 52 | v140 53 | true 54 | Unicode 55 | 56 | 57 | Application 58 | false 59 | v140 60 | true 61 | Unicode 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | true 81 | 82 | 83 | true 84 | 85 | 86 | false 87 | 88 | 89 | false 90 | 91 | 92 | 93 | Use 94 | Level3 95 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_LIB;%(PreprocessorDefinitions) 96 | true 97 | 98 | 99 | Console 100 | true 101 | true 102 | 103 | 104 | 105 | 106 | Use 107 | Level3 108 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS 109 | true 110 | 111 | 112 | Console 113 | true 114 | true 115 | 116 | 117 | 118 | 119 | Level3 120 | Use 121 | MaxSpeed 122 | true 123 | true 124 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 125 | true 126 | 127 | 128 | Console 129 | true 130 | true 131 | true 132 | 133 | 134 | 135 | 136 | Level3 137 | Use 138 | MaxSpeed 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS 142 | true 143 | 144 | 145 | Console 146 | true 147 | true 148 | true 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | Create 162 | Create 163 | Create 164 | Create 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /Phraser/Phraser.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /Phraser/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Phraser.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Phraser/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | //#include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define BREAK "." 25 | #define SPACE "_" 26 | 27 | // TODO: reference additional headers your program requires here -------------------------------------------------------------------------------- /Phraser/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /PhraserGram/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PhraserGram/PhraserGram.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4DEF8280-F526-4FCA-9492-419EA5A0F846} 8 | Exe 9 | Properties 10 | PhraserGram 11 | PhraserGram 12 | v4.5 13 | 512 14 | false 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | publish\ 24 | true 25 | Disk 26 | false 27 | Foreground 28 | 7 29 | Days 30 | false 31 | false 32 | true 33 | 0 34 | 1.0.0.%2a 35 | false 36 | true 37 | 38 | 39 | AnyCPU 40 | true 41 | full 42 | false 43 | bin\Debug\ 44 | DEBUG;TRACE 45 | prompt 46 | 4 47 | false 48 | false 49 | ExtendedDesignGuidelineRules.ruleset 50 | 51 | 52 | AnyCPU 53 | pdbonly 54 | true 55 | bin\Release\ 56 | TRACE 57 | prompt 58 | 4 59 | false 60 | 61 | 62 | 63 | 64 | 65 | 66 | true 67 | bin\x64\Debug\ 68 | DEBUG;TRACE 69 | full 70 | x64 71 | prompt 72 | ExtendedDesignGuidelineRules.ruleset 73 | false 74 | 75 | 76 | bin\x64\Release\ 77 | TRACE 78 | true 79 | pdbonly 80 | x64 81 | prompt 82 | MinimumRecommendedRules.ruleset 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | False 103 | Microsoft .NET Framework 4.5 %28x86 and x64%29 104 | true 105 | 106 | 107 | False 108 | .NET Framework 3.5 SP1 Client Profile 109 | false 110 | 111 | 112 | False 113 | .NET Framework 3.5 SP1 114 | false 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /PhraserGram/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | using System.IO.MemoryMappedFiles; 8 | using System.Text.RegularExpressions; 9 | 10 | namespace PhraserGram 11 | { 12 | class Program 13 | { 14 | static void Main(string[] args) 15 | { 16 | bool wordmode = false; 17 | int n = 1; 18 | string sourcetextfile = null; 19 | 20 | // Read arguments 21 | if(args.Length == 0) { ShowUsage(); return; } 22 | for (int i = 0; i < args.Length; i++) 23 | { 24 | if (args[i] == "-i") 25 | { 26 | if (args.Length < i + 2) { Console.Error.WriteLine("\nThe -i option requires a input file path."); ShowUsage(); return; }; 27 | sourcetextfile = args[++i]; 28 | if (!File.Exists(sourcetextfile)) { Console.Error.WriteLine("\nThe file {0} could not be found. Please check path.", sourcetextfile); ShowUsage(); return; } 29 | } 30 | 31 | if (args[i] == "-n" ) if (args.Length < i + 2 || !int.TryParse(args[++i], out n)) { Console.Error.WriteLine("\nThe -n option requires an integer."); ShowUsage(); return; }; 32 | if (args[i] == "-w") wordmode = true; 33 | if (args[i] == "-h" || args[i] == "--help" || args[i] == "/?") { ShowUsage(); return; } 34 | 35 | } 36 | 37 | // Execute ngram generation if required arguments are valid 38 | if (string.IsNullOrWhiteSpace(sourcetextfile)) { ShowUsage(); return; } 39 | else 40 | { 41 | ngramextraction ngrams = new ngramextraction(sourcetextfile, n, wordmode); 42 | } 43 | } 44 | 45 | private static void ShowUsage() 46 | { 47 | Uri appuri = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); 48 | 49 | Console.WriteLine("\nUSAGE:"); 50 | Console.WriteLine("{0} -i PATH | -h [options]", appuri.Segments.Last()); 51 | Console.WriteLine("\nOPTIONS:"); 52 | Console.WriteLine("-i PATH\tPath to input source text file\n"); 53 | Console.WriteLine("-n INT\tSize of n-grams (-n 3 means trigrams eg. Default = 1)\n"); 54 | Console.WriteLine("-w \tGenerate n-grams on word level (if omitted, default is character level)\n"); 55 | Console.WriteLine("-h \tShow this usage message. --help or /? or no args also works"); 56 | } 57 | } 58 | class ngramextraction 59 | { 60 | DateTime starttime = DateTime.Now; 61 | 62 | const string BREAK = "."; 63 | const string SPACE = "_"; 64 | 65 | //char[] punctuation = { '.', '!', '?', ':' }; 66 | //char[] removechars = { '\'', '\"', '-', ';', '(', ')', ',' }; 67 | 68 | SortedDictionary ngramlist = new SortedDictionary(); 69 | string inputfile; 70 | bool wordmode = true; 71 | 72 | public ngramextraction(string inputfile, int n, bool wordmode) 73 | { 74 | this.inputfile = inputfile; 75 | this.wordmode = wordmode; 76 | ngrams(n); 77 | } 78 | 79 | void ngrams(int n) 80 | { 81 | Console.Error.WriteLine("Started reading the source textfile at {0}", DateTime.Now.ToLongTimeString()); 82 | 83 | Queue buffer = new Queue(n); // To hold a buffer of words/characters before adding to the dictionary 84 | if(n > 1) buffer.Enqueue(BREAK); // Marks the first word as sentence start, or first char as wordstart 85 | string ngram = ""; 86 | 87 | using (var mappedFile1 = MemoryMappedFile.CreateFromFile(inputfile)) 88 | { 89 | using (Stream mmStream = mappedFile1.CreateViewStream()) 90 | { 91 | using (StreamReader sr = new StreamReader(mmStream, Encoding.UTF8, true)) 92 | { 93 | double filesize = sr.BaseStream.Length; 94 | double nextprogress = filesize / 20; // Print out progress at a 5% interval 95 | 96 | if (wordmode) // Wordmode (in order to gain as much performance as possible, wordmode and charmode are split here to avoid some comparisons in the while loop, though they are allmost the same) 97 | { 98 | while (!sr.EndOfStream) // && sr.BaseStream.Position < 100000 För debug (avbryter stora texter efter ett tag) 99 | { 100 | var line = sr.ReadLine() + " "; 101 | 102 | var lineItems = GetWords(line); 103 | 104 | // Add the ngram to the table (dictionary) 105 | foreach (var item in lineItems) 106 | { 107 | if ((item == BREAK && buffer.Count > 0 && buffer.Last() == BREAK) || string.IsNullOrWhiteSpace(item)) continue; // Skip if double BREAK or empty string (can happen if ' stands alone or with strange chars)(did not find a bullet proof regex to handle all of this) 108 | 109 | buffer.Enqueue(item); 110 | 111 | if (buffer.Count >= n) // Now we have a full ngram to add to list 112 | { 113 | ngram = buffer.Dequeue(); 114 | for (int i = 0; i < n - 1; i++) ngram += " " + buffer.ElementAt(i); 115 | 116 | ngramlist[ngram] = ngramlist.ContainsKey(ngram) ? ngramlist[ngram] + 1 : 1; 117 | } 118 | } 119 | if (sr.BaseStream.Position > nextprogress) // Print out progress 120 | { 121 | Console.Error.WriteLine("{0}% read at {1}", ((double)sr.BaseStream.Position / (double)filesize) * 100, DateTime.Now.ToLongTimeString()); 122 | nextprogress = sr.BaseStream.Position + filesize / 100; 123 | } 124 | } 125 | // Add BREAK after last row if not already there 126 | if (buffer.Count > 0) // buffer count should be n-1 here 127 | { 128 | if (!(buffer.Last() == BREAK)) // No need to add double BREAKS in wordmode 129 | { 130 | buffer.Enqueue(BREAK); 131 | ngram = buffer.Dequeue(); 132 | while (buffer.Count > 0) ngram += " " + buffer.Dequeue(); 133 | 134 | ngramlist[ngram] = ngramlist.ContainsKey(ngram) ? ngramlist[ngram] + 1 : 1; 135 | } 136 | } 137 | } 138 | else // Charmode (almost the same as above wordmode) 139 | { 140 | while (!sr.EndOfStream) // && sr.BaseStream.Position < 100000 För debug (avbryter stora texter efter ett tag) 141 | { 142 | var line = sr.ReadLine() + "\n"; 143 | 144 | var lineItems = GetChars(line); 145 | 146 | // Add the ngrams to the table (dictionary) 147 | foreach (var item in lineItems) 148 | { 149 | if ((item == SPACE || item == BREAK) && buffer.Count > 0 && (buffer.Last() == BREAK || buffer.Last() == SPACE)) continue; // Skip if space after punctuation or double space (did not find a bullet proof regex to handle all of this) 150 | buffer.Enqueue(item); 151 | 152 | if (buffer.Count >= n) // Now we have a full ngram to add to list 153 | { 154 | ngram = buffer.Dequeue(); 155 | for (int i = 0; i < n - 1; i++) ngram += buffer.ElementAt(i); 156 | 157 | ngramlist[ngram] = ngramlist.ContainsKey(ngram) ? ngramlist[ngram] + 1 : 1; 158 | } 159 | } 160 | if (sr.BaseStream.Position > nextprogress) // Print out progress 161 | { 162 | Console.Error.WriteLine("{0}% read at {1}", ((double)sr.BaseStream.Position / (double)filesize) * 100, DateTime.Now.ToLongTimeString()); 163 | nextprogress = sr.BaseStream.Position + filesize / 100; 164 | } 165 | } 166 | } 167 | } 168 | } 169 | } 170 | 171 | // If unigram (1-gram), no need for breaks or spaces... Remove 172 | if (n == 1) 173 | { 174 | ngramlist.Remove(BREAK); 175 | ngramlist.Remove(SPACE); 176 | } 177 | 178 | Console.Error.WriteLine("File read and {0} {1}-grams generated in {2} seconds.\nOutputing...", ngramlist.Count, n, (DateTime.Now - starttime).TotalSeconds.ToString("N01")); 179 | 180 | // Print to stdout 181 | Console.OutputEncoding = UTF8Encoding.UTF8; 182 | 183 | foreach (KeyValuePair pair in ngramlist) 184 | { 185 | Console.WriteLine("{0} {1}", pair.Key, pair.Value); 186 | } 187 | 188 | TimeSpan totalruntime = DateTime.Now - starttime; 189 | Console.Error.WriteLine("Done. Total run time: {0}", totalruntime); //TotalSeconds.ToString("N01")); 190 | } 191 | 192 | static private string[] GetChars(string line) 193 | { 194 | // Replace spaces with SPACE, and punctuation (sentence starts and stops) with BREAK, and then extract all alphanumeric chars (and BREAK:s) 195 | //MatchCollection matches = Regex.Matches(Regex.Replace(line, @"\s* |[\b.\b!\b?\b:]+|\t", BREAK), @"[\w" + BREAK + "]"); // \s* |[.!?:] 196 | line = Regex.Replace(line, @"\b[.!?:]+\W*", BREAK); // Mark punctuation with a BREAK and remove spaces after 197 | line = Regex.Replace(line, @"\s+(?!$)", SPACE); // Mark whitespaces with SPACE (exclude eof nulls in last line) 198 | MatchCollection matches = Regex.Matches(line, @"[A-Za-z" + BREAK + SPACE + "]"); // Replace with A-Za-zÅÄÖåäö to include swedish 199 | var chars = from m in matches.Cast() 200 | select m.Value.ToLower(System.Globalization.CultureInfo.InvariantCulture); 201 | 202 | return chars.ToArray(); 203 | } 204 | 205 | static private string[] GetWords(string line) 206 | { 207 | // Replace punctuation with BREAK to mark sentence starts and stops, and then find all words 208 | line = Regex.Replace(line, @"[\b.\b!\b?\b:]+\W|\t", BREAK); //@"[\b.\b!\b?\b:]+|\t", " " + BREAK + " " 209 | MatchCollection matches = Regex.Matches(line, @"\b[A-Za-z']+\b|[" + BREAK + "]"); // Replace with A-Za-zÅÄÖåäö to include swedish 210 | 211 | var words = from m in matches.Cast() 212 | select m.Value.ToLower(System.Globalization.CultureInfo.InvariantCulture).Replace("\'", ""); // Remove all ':s in words eg. in we're -> were 213 | 214 | return words.ToArray(); 215 | } 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /PhraserGram/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PhraserGram")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Phraser")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("61d74635-75be-4907-9881-53e770fc025f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Phraser 2 | 3 | "Phraser" is a phrase generator using n-grams and Markov chains to generate phrases for passphrase cracking. 4 | The generated phraselists can be used as wordlists in your favourite password cracking application. 5 | 6 | An academic style writeup of the project is available [here](http://www.simovits.com/sites/default/files/files/PederSparell_Linguistic_Cracking_of_Passphrases_using_Markov_Chains.pdf). 7 | 8 | A Swedish version, which is a bit more detailed and has some additional general info about password cracking, is also available [here](http://www.simovits.com/sites/default/files/files/PederSparell-Lingvistisk_knackning_av_losenordsfraser.pdf). 9 | 10 | The phrase generator solution is based on a markov process with two steps involved: 11 | - First you create n-gram statistics (stats about how often certain character sequences occurs in a large text) with the program PhraserGram. Redirect the output to file. 12 | - Then use those statistics as input to the actual phrase generator which outputs phrases, one per line. The output can be redirected to file or read directly into your favourite password cracker via stdin. 13 | 14 | The quality of the final result is strongly dependant on the source text file (the file wich you build up the n-gram statistics from), and depending on size and quality of that file you have to experiment a bit with threshold and other params in order for Phraser to generate phrases with good quality and in a resonable time frame. 15 | Generally, word level n-grams generate better phrases, but the source text file has to be larger. 16 | 17 | ###PhraserGram Usage 18 | ``` 19 | USAGE: 20 | PhraserGram.exe -i PATH | -h [options] 21 | OPTIONS: 22 | -i PATH Path to input source text file 23 | -n INT Size of n-grams (-n 3 means trigrams eg. Default = 1) 24 | -w Generate n-grams on word level (if omitted, default is character level) 25 | -h Show this usage message. --help or /? or no args also works 26 | ``` 27 | 28 | ###Phraser Usage 29 | ``` 30 | USAGE: 31 | Phraser.exe -i PATH |-h [OPTIONS] 32 | OPTIONS: 33 | -h | --help Show this help message 34 | -i | --input PATH Path to n-gram stats file 35 | -min INT Min number of chars in phrases 36 | -max INT Max number of chars in phrases 37 | -wmin | --wordsmin INT Minimal number of words in phrases 38 | -wmax | --wordsmax INT Maximal number of words in phrases 39 | -t | --threshold INT Ignore n-grams seen <= -t times in source text 40 | -f | --feed STRING Only create phrases starting with this 41 | ``` 42 | 43 | ##Complete example execution: 44 | 45 | 1. `PhraserGram -i texts\SherlockBook.txt -n 3 -w > ngrams\3WSherlock.txt` (Reads a book saved in the specified path and create 3-gram stats on word level, and save the results to the file 3WSherlock.txt) 46 | 2. `Phraser -i ngrams\3WSherlock.txt -min 14 -max 16 -t 0 > phrases\L14-16T0N3WSherlock.txt` (reads that 3-gram stat file, and outputs phrases of lengths 14-16 chars, without threshold filtering, and saves the phrases to the specified file) 47 | 48 | ##Some links to source text file resources: 49 | * [Lots of different files with sentences gathered from different places on internet.](http://corpora2.informatik.uni-leipzig.de/download.html) 50 | * [Free ebooks in text format.](https://www.gutenberg.org/) (These are pretty small, but can suffice for testing etc.) 51 | --------------------------------------------------------------------------------