diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fd91c --- /dev/null +++ b/.gitignore @@ -0,0 +1,184 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets +!packages/*/build/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Enable nuget.exe in the .nuget folder (though normally executables are not tracked) +!.nuget/NuGet.exe + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# =================================================== +# Exclude F# project specific directories and files +# =================================================== + +# NuGet Packages Directory +packages/ + +# Generated documentation folder +docs/output/ + +# Temp folder used for publishing docs +temp/ + +# Test results produced by build +TestResults.xml + +# Nuget outputs +nuget/*.nupkg + +# =================================================== +# Project specific directories and files +# =================================================== + +# Download folder used for origin Stanford archives +src/Download + +# Secret key +src/Stanford.NLP.snk \ No newline at end of file diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe new file mode 100644 index 0000000..2c93698 Binary files /dev/null and b/.nuget/NuGet.exe differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000..83fe906 --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,136 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.nuget/packages.config b/.nuget/packages.config new file mode 100644 index 0000000..51bbcbe --- /dev/null +++ b/.nuget/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..c7cde3a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) 2007-2014 Johan Hall, Jens Nilsson and Joakim Nivre + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of MaltParser nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MaltParser.sln b/MaltParser.sln new file mode 100644 index 0000000..0752a50 --- /dev/null +++ b/MaltParser.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1F1B4F0F-2998-4D74-865B-9122611C2B14}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{BF60BC93-E09B-4E5F-9D85-95A519479D54}" + ProjectSection(SolutionItems) = preProject + build.fsx = build.fsx + README.md = README.md + RELEASE_NOTES.md = RELEASE_NOTES.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{83F16175-43B1-4C90-A1EE-8E351C33435D}" + ProjectSection(SolutionItems) = preProject + docs\tools\generate.fsx = docs\tools\generate.fsx + docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D5255-776D-4B61-85F9-73C37AA1FB9A}" + ProjectSection(SolutionItems) = preProject + docs\content\index.fsx = docs\content\index.fsx + docs\content\MaltParser.fsx = docs\content\MaltParser.fsx + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FC1213CC-EF87-45CA-95C0-56D378BE2B84}" + ProjectSection(SolutionItems) = preProject + src\Build.bat = src\Build.bat + src\BuildAll.bat = src\BuildAll.bat + src\Core.fsx = src\Core.fsx + src\MaltParser.fsx = src\MaltParser.fsx + src\MaltParser.NET.snk = src\MaltParser.NET.snk + src\MaltParser.nuspec = src\MaltParser.nuspec + EndProjectSection +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {83F16175-43B1-4C90-A1EE-8E351C33435D} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1} + {8E6D5255-776D-4B61-85F9-73C37AA1FB9A} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fcfb5f --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +MaltParser for .NET +=================== \ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md new file mode 100644 index 0000000..03c8a92 --- /dev/null +++ b/RELEASE_NOTES.md @@ -0,0 +1,2 @@ +#### 1.8.0 - May 31 2014 +* Initial release \ No newline at end of file diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..9528201 --- /dev/null +++ b/build.cmd @@ -0,0 +1,7 @@ +@echo off +cls +if not exist packages\FAKE\tools\Fake.exe ( + .nuget\nuget.exe install FAKE -OutputDirectory packages -ExcludeVersion +) +packages\FAKE\tools\FAKE.exe build.fsx %* +pause diff --git a/build.fsx b/build.fsx new file mode 100644 index 0000000..2bd2102 --- /dev/null +++ b/build.fsx @@ -0,0 +1,103 @@ +// -------------------------------------------------------------------------------------- +// FAKE build script +// -------------------------------------------------------------------------------------- + +#r @"packages/FAKE/tools/FakeLib.dll" +open Fake +open Fake.Git +open Fake.AssemblyInfoFile +open Fake.ReleaseNotesHelper +open System + +// -------------------------------------------------------------------------------------- +// Provide project-specific details + +// File system information +// (.sln is built during the building process) +let solutionFile = "MartParser" + +// Git configuration (used for publishing documentation in gh-pages branch) +// The profile where the project is posted +let gitHome = "https://github.com/sergey-tihon" +// The name of the project on GitHub +let gitName = "MaltParser.NET" + +// -------------------------------------------------------------------------------------- + +// Read additional information from the release notes document +Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ +let release = parseReleaseNotes (IO.File.ReadAllLines "RELEASE_NOTES.md") + +// -------------------------------------------------------------------------------------- +// Clean build results & restore NuGet packages + +Target "RestorePackages" RestorePackages + +Target "RestoreBinaries" (fun _ -> + !! "src/temp/ikvm/*.dll" + |> CopyFiles "bin" +) + +Target "Clean" (fun _ -> + CleanDirs ["bin"; "temp"] +) + +Target "CleanDocs" (fun _ -> + CleanDirs ["docs/output"] +) + +// -------------------------------------------------------------------------------------- +// Build library & test project + +Target "Build" (fun _ -> + { BaseDirectory = __SOURCE_DIRECTORY__ + Includes = [ solutionFile + ".sln"] + Excludes = [] } + |> MSBuildRelease "" "Rebuild" + |> ignore +) + +// -------------------------------------------------------------------------------------- +// Generate the documentation + +Target "GenerateDocs" (fun _ -> + executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore +) + +// -------------------------------------------------------------------------------------- +// Release Scripts + +Target "ReleaseDocs" (fun _ -> + let ghPages = "gh-pages" + let ghPagesLocal = "temp/gh-pages" + Repository.clone "temp" (gitHome + "/" + gitName + ".git") ghPages + Branches.checkoutBranch ghPagesLocal ghPages + fullclean ghPagesLocal + CopyRecursive "docs/output" ghPagesLocal true |> printfn "%A" + CommandHelper.runSimpleGitCommand ghPagesLocal "add ." |> printfn "%s" + let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" release.NugetVersion + CommandHelper.runSimpleGitCommand ghPagesLocal cmd |> printfn "%s" + Branches.push ghPagesLocal +) + +Target "Release" DoNothing + +// -------------------------------------------------------------------------------------- +// Run all targets by default. Invoke 'build ' to override + +Target "All" DoNothing + +"Clean" + ==> "RestorePackages" + ==> "RestoreBinaries" + //==> "Build" + //==> "RunTests" + ==> "All" + +"All" + ==> "CleanDocs" + ==> "GenerateDocs" + ==> "ReleaseDocs" + ==> "Release" + +RunTargetOrDefault "All" diff --git a/docs/content/MaltParser.fsx b/docs/content/MaltParser.fsx new file mode 100644 index 0000000..2b7ed06 --- /dev/null +++ b/docs/content/MaltParser.fsx @@ -0,0 +1,58 @@ +(*** hide ***) +// This block of code is omitted in the generated HTML documentation. Use +// it to define helpers that you do not want to show in the documentation. +#I "../../bin" +#I "../../src/temp/ikvm-7.4.5196.0/bin/" + +(** +Parse sentences with MaltParser +=============================================== + +This example shows how to parse a sentence with MaltParser by first initialize a parser model. + +To run this example requires that you have created `swemalt-1.7.2i.mco`. + +You can download model from [pre-trainted models page](http://www.maltparser.org/mco/mco.html). + +*) +#r "maltparser-1.8.dll" +#r "IKVM.OpenJDK.Core.dll" + +open java.io +open java.net + +open org.maltparser.concurrent +open org.maltparser.concurrent.graph + +// Loading the Swedish model swemalt-1.7.2 +let swemaltMiniModelURL = File(__SOURCE_DIRECTORY__ + "/../../bin/swemalt-1.7.2.mco").toURI().toURL() +let model = ConcurrentMaltParserService.initializeParserModel(swemaltMiniModelURL) + +// Creates an array of tokens, which contains the Swedish sentence +// 'Samtidigt får du högsta sparränta plus en skattefri sparpremie.' +// in the CoNLL data format. +let tokens = + [|"1\tSamtidigt\t_\tAB\tAB\t_" + "2\tfår\t_\tVB\tVB\tPRS|AKT" + "3\tdu\t_\tPN\tPN\tUTR|SIN|DEF|SUB" + "4\thögsta\t_\tJJ\tJJ\tSUV|UTR/NEU|SIN/PLU|DEF|NOM" + "5\tsparränta\t_\tNN\tNN\tUTR|SIN|IND|NOM" + "6\tplus\t_\tAB\tAB\t_" + "7\ten\t_\tDT\tDT\tUTR|SIN|IND" + "8\tskattefri\t_\tJJ\tJJ\tPOS|UTR|SIN|IND|NOM" + "9\tsparpremie\t_\tNN\tNN\tUTR|SIN|IND|NOM" + "10\t.\t_\tMAD\tMAD\t_"|] + +let outputGraph = model.parse(tokens) +printfn "%A" outputGraph + +// [fsi:1 Samtidigt _ AB AB _ 2 TA _ _] +// [fsi:2 får _ VB VB PRS|AKT 0 ROOT _ _] +// [fsi:3 du _ PN PN UTR|SIN|DEF|SUB 2 SS _ _] +// [fsi:4 högsta _ JJ JJ SUV|UTR/NEU|SIN/PLU|DEF|NOM 5 AT _ _] +// [fsi:5 sparränta _ NN NN UTR|SIN|IND|NOM 2 OO _ _] +// [fsi:6 plus _ AB AB _ 5 ET _ _] +// [fsi:7 en _ DT DT UTR|SIN|IND 9 DT _ _] +// [fsi:8 skattefri _ JJ JJ POS|UTR|SIN|IND|NOM 9 AT _ _] +// [fsi:9 sparpremie _ NN NN UTR|SIN|IND|NOM 6 PA _ _] +// [fsi:10 . _ MAD MAD _ 2 IP _ _] \ No newline at end of file diff --git a/docs/content/index.fsx b/docs/content/index.fsx new file mode 100644 index 0000000..25fa0e2 --- /dev/null +++ b/docs/content/index.fsx @@ -0,0 +1,48 @@ +(*** hide ***) +// This block of code is omitted in the generated HTML documentation. Use +// it to define helpers that you do not want to show in the documentation. +#I "../../bin" + +(** +MaltParser for .NET +=================== + +`MaltParser` is a system for data-driven dependency parsing, which can be used to induce a parsing model from treebank +data and to parse new data using an induced model. `MaltParser` is developed by `Johan Hall`, `Jens Nilsson` and `Joakim Nivre` +at Växjö University and Uppsala University, Sweden. + + +`MaltParser` implements nine deterministic parsing algorithms: + +* Nivre arc-eager +* Nivre arc-standard +* Covington non-projective +* Covington projective +* Stack projective +* Stack swap-eager +* Stack swap-lazy +* Planar (implemented by `Carlos Gómez-Rodríguez`) +* 2-planar (implemented by `Carlos Gómez-Rodríguez`) + +`MaltParser` allows users to define feature models of arbitrary complexity. + +`MaltParser` currently includes two machine learning packages (thanks to `Sofia Cassel` for her work on LIBLINEAR): + +* `LIBSVM` - A Library for Support Vector Machines (Chang, 2001). +* `LIBLINEAR` -- A Library for Large Linear Classification (Fan et al., 2008). + +`MaltParser` can also be turned into a phrase structure parser that recovers both continuous and discontinuous phrases +with both phrase labels and grammatical functions (Hall and Nivre, 2008a; Hall and Nivre, 2008b). + +
+
+
+
+ The MaltParser for .NET library can be installed from NuGet: +
PM> Install-Package MaltParser
+
+
+
+
+ +*) diff --git a/docs/files/img/logo.jpg b/docs/files/img/logo.jpg new file mode 100644 index 0000000..3db6195 Binary files /dev/null and b/docs/files/img/logo.jpg differ diff --git a/docs/files/img/logo.pdn b/docs/files/img/logo.pdn new file mode 100644 index 0000000..5bd9be2 Binary files /dev/null and b/docs/files/img/logo.pdn differ diff --git a/docs/tools/generate.fsx b/docs/tools/generate.fsx new file mode 100644 index 0000000..620e120 --- /dev/null +++ b/docs/tools/generate.fsx @@ -0,0 +1,85 @@ +// -------------------------------------------------------------------------------------- +// Builds the documentation from `.fsx` and `.md` files in the 'docs/content' directory +// (the generated documentation is stored in the 'docs/output' directory) +// -------------------------------------------------------------------------------------- + +// Binaries that have XML documentation (in a corresponding generated XML file) +let referenceBinaries = [ ] +// Web site location for the generated documentation +let website = "/MaltParser.NET" + +// Specify more information about your project +let info = + [ "project-name", "MaltParser.NET" + "project-author", "Sergey Tihon" + "project-summary", "MaltParser is a system for data-driven dependency parsing, which can be used to induce a parsing model from treebank data and to parse new data using an induced model." + "project-github", "https://github.com/sergey-tihon/MaltParser.NET" ] + +// -------------------------------------------------------------------------------------- +// For typical project, no changes are needed below +// -------------------------------------------------------------------------------------- + +#I "../../packages/FSharp.Formatting.2.2.12-beta/lib/net40" +#I "../../packages/RazorEngine.3.4.0/lib/net45/" +#r "../../packages/Microsoft.AspNet.Razor.3.0.0/lib/net45/System.Web.Razor.dll" +#r "../../packages/FAKE/tools/FakeLib.dll" +#r "RazorEngine.dll" +#r "FSharp.Literate.dll" +#r "FSharp.CodeFormat.dll" +#r "FSharp.MetadataFormat.dll" +open Fake +open System.IO +open Fake.FileHelper +open FSharp.Literate +open FSharp.MetadataFormat + +// When called from 'build.fsx', use the public project URL as +// otherwise, use the current 'output' directory. +#if RELEASE +let root = website +#else +let root = "file://" + (__SOURCE_DIRECTORY__ @@ "../output") +#endif + +// Paths with template/source/output locations +let bin = __SOURCE_DIRECTORY__ @@ "../../bin" +let content = __SOURCE_DIRECTORY__ @@ "../content" +let output = __SOURCE_DIRECTORY__ @@ "../output" +let files = __SOURCE_DIRECTORY__ @@ "../files" +let templates = __SOURCE_DIRECTORY__ @@ "templates" +let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting.2.2.12-beta/" +let docTemplate = formatting @@ "templates/docpage.cshtml" + +// Where to look for *.csproj templates (in this order) +let layoutRoots = + [ templates; formatting @@ "templates" + formatting @@ "templates/reference" ] + +// Copy static files and CSS + JS from F# Formatting +let copyFiles () = + CopyRecursive files output true |> Log "Copying file: " + ensureDirectory (output @@ "content") + CopyRecursive (formatting @@ "styles") (output @@ "content") true + |> Log "Copying styles and scripts: " + +// Build API reference from XML comments +let buildReference () = + CleanDir (output @@ "reference") + for lib in referenceBinaries do + MetadataFormat.Generate + ( bin @@ lib, output @@ "reference", layoutRoots, + parameters = ("root", root)::info ) + +// Build documentation from `fsx` and `md` files in `docs/content` +let buildDocumentation () = + let subdirs = Directory.EnumerateDirectories(content, "*", SearchOption.AllDirectories) + for dir in Seq.append [content] subdirs do + let sub = if dir.Length > content.Length then dir.Substring(content.Length + 1) else "." + Literate.ProcessDirectory + ( dir, docTemplate, output @@ sub, replacements = ("root", root)::info, + layoutRoots = layoutRoots ) + +// Generate +copyFiles() +buildDocumentation() +//buildReference() diff --git a/docs/tools/packages.config b/docs/tools/packages.config new file mode 100644 index 0000000..ace65df --- /dev/null +++ b/docs/tools/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/docs/tools/templates/template.cshtml b/docs/tools/templates/template.cshtml new file mode 100644 index 0000000..0ce2c5d --- /dev/null +++ b/docs/tools/templates/template.cshtml @@ -0,0 +1,67 @@ + + + + + @Title + + + + + + + + + + + + + + + + +
+ +
+
+
+ @RenderBody() +
+
+ Stanford.NLP.NET + +
+
+
+ Fork me on GitHub + + diff --git a/src/Build.bat b/src/Build.bat new file mode 100644 index 0000000..7de2992 --- /dev/null +++ b/src/Build.bat @@ -0,0 +1,7 @@ +@echo off +cls +if not exist "..\packages\FAKE\tools\Fake.exe" ( + "..\.nuget\nuget.exe" install FAKE -OutputDirectory "..\packages" -ExcludeVersion +) +"..\packages\FAKE\tools\Fake.exe" %1 +pause \ No newline at end of file diff --git a/src/BuildAll.bat b/src/BuildAll.bat new file mode 100644 index 0000000..ae15f82 --- /dev/null +++ b/src/BuildAll.bat @@ -0,0 +1 @@ +for %%f in (Stanford*.fsx) do (Build.bat %%f) \ No newline at end of file diff --git a/src/Core.fsx b/src/Core.fsx new file mode 100644 index 0000000..44b7320 --- /dev/null +++ b/src/Core.fsx @@ -0,0 +1,147 @@ +module Fake.IKVM.Helpers + +#r @"..\packages\FAKE\tools\FakeLib.dll" +#r "System.IO.Compression.FileSystem.dll" + +open Microsoft.FSharp.Core.Printf +open System +open System.IO + +open Fake + +// ================== Download manager ===================================== + +let downloadDir = @".\Download\" + +let restoreFile url = + let downloadFile file url = + printfn "Downloading file '%s' to '%s'..." url file + let BUFFER_SIZE = 16*1024 + use outputFileStream = File.Create(file, BUFFER_SIZE) + let req = System.Net.WebRequest.Create(url) + use response = req.GetResponse() + use responseStream = response.GetResponseStream() + let printStep = 100L*1024L + let buffer = Array.create BUFFER_SIZE 0uy + let rec download downloadedBytes = + let bytesRead = responseStream.Read(buffer, 0, BUFFER_SIZE) + outputFileStream.Write(buffer, 0, bytesRead) + if (downloadedBytes/printStep <> (downloadedBytes-int64(bytesRead))/printStep) + then printfn "\tDownloaded '%d' bytes" downloadedBytes + if (bytesRead > 0) then download (downloadedBytes + int64(bytesRead)) + download 0L + let file = downloadDir @@ System.IO.Path.GetFileName(url) + if (not <| File.Exists(file)) + then url |> downloadFile file + file + +let unZipTo toDir file = + printfn "Unzipping file '%s' to '%s'" file toDir + Compression.ZipFile.ExtractToDirectory(file, toDir) + +let restoreFolderFromUrl folder url = + if not <| Directory.Exists folder then + url |> restoreFile |> unZipTo (folder @@ @"..\") + +let restoreFolderFromFile folder zipFile = + if not <| Directory.Exists folder then + zipFile |> unZipTo (folder @@ @"..\") + +// ================== IKVM Compiler=== ===================================== + +let ikvmc = + restoreFolderFromUrl @".\temp\ikvm-7.4.5196.0" "http://www.frijters.net/ikvmbin-7.4.5196.0.zip" + @".\temp\ikvm-7.4.5196.0\bin\ikvmc.exe" + +let ildasm = @"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64\ildasm.exe" +let ilasm = @"c:\Windows\Microsoft.NET\Framework64\v2.0.50727\ilasm.exe" + +type IKVMcTask(jar:string) = + member val JarFile = jar + member val Version = "" with get, set + member val Dependencies = List.empty with get, set + + +let timeOut = TimeSpan.FromSeconds(120.0) + +let IKVMCompile workingDirectory keyFile tasks = + let getNewFileName newExtension (fileName:string) = + Path.GetFileName(fileName).Replace(Path.GetExtension(fileName), newExtension) + let startProcess fileName args = + let result = + ExecProcess + (fun info -> + info.FileName <- fileName + info.WorkingDirectory <- FullName workingDirectory + info.Arguments <- args) + timeOut + if result<> 0 then + failwithf "Process '%s' failed with exit code '%d'" fileName result + + let newKeyFile = + let file = workingDirectory @@ (Path.GetFileName(keyFile)) + File.Copy(keyFile, file, true) + Path.GetFileName(file) + let rec compile (task:IKVMcTask) = + let getIKVMCommandLineArgs() = + let sb = Text.StringBuilder() + task.Dependencies |> Seq.iter + (fun x -> + compile x + x.JarFile |> getNewFileName ".dll" |> bprintf sb " -r:%s") + if not <| String.IsNullOrEmpty(task.Version) + then task.Version |> bprintf sb " -version:%s" + bprintf sb " %s -out:%s" + (task.JarFile |> getNewFileName ".jar") + (task.JarFile |> getNewFileName ".dll") + sb.ToString() + + File.Copy(task.JarFile, workingDirectory @@ (Path.GetFileName(task.JarFile)) ,true) + startProcess ikvmc (getIKVMCommandLineArgs()) + if (File.Exists(keyFile)) then + let dllFile = task.JarFile |> getNewFileName ".dll" + let ilFile = task.JarFile |> getNewFileName ".il" + startProcess ildasm (sprintf " /all /out=%s %s" ilFile dllFile) + File.Delete(dllFile) + startProcess ilasm (sprintf " /dll /key=%s %s" (newKeyFile) ilFile) + tasks |> Seq.iter compile + +// ================== Fake tasks =========================================== +let copyPackages fromDir toDir = + if (not <| Directory.Exists(toDir)) + then Directory.CreateDirectory(toDir) |> ignore + Directory.GetFiles(fromDir) + |> Seq.filter (fun x -> Path.GetExtension(x) = ".nupkg") + |> Seq.iter (fun x -> File.Copy(x, Path.Combine(toDir, Path.GetFileName(x)), true)) + + +let version = "1.8.0.0" +let authors = ["Johan Hall";"Jens Nilsson";"Joakim Nivre"] + +// Folders +let ikvmDir = @".\temp\ikvm\" +let nugetDir = @".\temp\nuget\" +let targetDir = @".\packages\" + +// Targets +// Clean IKVM working directory +Target "CleanIKVM" (fun _ -> + CleanDir ikvmDir +) + +// Clean NuGet directory +Target "CleanNuGet" (fun _ -> + CleanDir nugetDir +) + +let copyFilesToNugetFolder() = + XCopy ikvmDir (nugetDir @@ "lib") + !! @"temp/nuget/lib/*.*" + -- @"temp/nuget/lib/*.dll" + |> DeleteFiles//Seq.iter (System.IO.File.Delete) + +// Default target +Target "Default" (fun _ -> + copyPackages nugetDir targetDir + trace "Building The Stanford Parser" +) \ No newline at end of file diff --git a/src/MaltParser.NET.snk b/src/MaltParser.NET.snk new file mode 100644 index 0000000..159f37e Binary files /dev/null and b/src/MaltParser.NET.snk differ diff --git a/src/MaltParser.fsx b/src/MaltParser.fsx new file mode 100644 index 0000000..315a2b0 --- /dev/null +++ b/src/MaltParser.fsx @@ -0,0 +1,51 @@ +// include Fake lib +#load @".\Core.fsx" +open Fake +open Fake.AssemblyInfoFile +open Fake.IKVM.Helpers + +// Assembly / NuGet package properties +let projectName = "MaltParser" +let projectDescription = "MaltParser is a system for data-driven dependency parsing, which can be used to induce a parsing model from treebank data and to parse new data using an induced model." + +// Targets + +// Run IKVM compiler +Target "RunIKVMCompiler" (fun _ -> + restoreFolderFromUrl + @".\temp\maltparser-1.8" + "http://maltparser.org/dist/maltparser-1.8.zip" + [IKVMcTask(@"temp\maltparser-1.8\maltparser-1.8.jar", Version=version, + Dependencies = + [IKVMcTask(@"temp\maltparser-1.8\lib\liblinear-1.8.jar", Version=version) + IKVMcTask(@"temp\maltparser-1.8\lib\libsvm.jar", Version=version) + IKVMcTask(@"temp\maltparser-1.8\lib\log4j.jar", Version="1.2.14.0")])] + |> IKVMCompile ikvmDir @".\MaltParser.NET.snk" +) + +// Create NuGet package +Target "CreateNuGet" (fun _ -> + copyFilesToNugetFolder() + + "MaltParser.nuspec" + |> NuGet (fun p -> + {p with + Project = projectName + Authors = authors + Version = version + Description = projectDescription + NoPackageAnalysis = true + ToolPath = ".\..\.nuget\NuGet.exe" + WorkingDir = nugetDir + OutputPath = nugetDir }) +) + +// Dependencies +"CleanIKVM" + ==> "RunIKVMCompiler" + ==> "CleanNuGet" + ==> "CreateNuGet" + ==> "Default" + +// start build +Run "Default" \ No newline at end of file diff --git a/src/MaltParser.nuspec b/src/MaltParser.nuspec new file mode 100644 index 0000000..fbf7b06 --- /dev/null +++ b/src/MaltParser.nuspec @@ -0,0 +1,17 @@ + + + + MaltParser + 0.0.1 + @authors@ + Sergey Tihon + https://github.com/sergey-tihon/MaltParser.NET/blob/master/LICENSE.txt + http://sergey-tihon.github.io/MaltParser.NET/img/logo.jpg + http://sergey-tihon.github.io/MaltParser.NET/ + @description@ + malt nlp parser POS Treebank + + + + + \ No newline at end of file