Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial checkin.

  • Loading branch information...
commit 7cab667f0d224fa48f62cceb14539bec596d208b 0 parents
Siarhei_Tsikhan authored
Showing with 708 additions and 0 deletions.
  1. +22 −0 .gitattributes
  2. +172 −0 .gitignore
  3. +9 −0 README.md
  4. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/arabicFactored.ser.gz
  5. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/chineseFactored.ser.gz
  6. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/chinesePCFG.ser.gz
  7. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/englishFactored.ser.gz
  8. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/englishPCFG.caseless.ser.gz
  9. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/englishPCFG.ser.gz
  10. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/frenchFactored.ser.gz
  11. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/germanFactored.ser.gz
  12. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/germanPCFG.ser.gz
  13. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/wsjFactored.ser.gz
  14. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/wsjPCFG.ser.gz
  15. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/xinhuaFactored.ser.gz
  16. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/xinhuaFactoredSegmenting.ser.gz
  17. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/xinhuaPCFG.ser.gz
  18. BIN  StanfordNLPLibraries/stanford-parser/stanford-parser.dll
  19. +6 −0 fsharp-stanford-nlp-samples/.nuget/NuGet.Config
  20. BIN  fsharp-stanford-nlp-samples/.nuget/NuGet.exe
  21. +153 −0 fsharp-stanford-nlp-samples/.nuget/NuGet.targets
  22. +16 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/App.config
  23. +17 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/JavaCollections.fs
  24. +57 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/ParserDemo.fs
  25. +50 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/ParserDemo2.fs
  26. +21 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/Program.fs
  27. +150 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/StanfordParser.Samples.fsproj
  28. +4 −0 fsharp-stanford-nlp-samples/StanfordParser.Samples/packages.config
  29. +27 −0 fsharp-stanford-nlp-samples/fsharp-stanford-nlp-samples.sln
  30. +4 −0 fsharp-stanford-nlp-samples/packages/repositories.config
22 .gitattributes
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.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
172 .gitignore
@@ -0,0 +1,172 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## 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/
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.vspscc
+.builds
+*.dotCover
+*.DotSettings
+
+## TODO: If you have NuGet Package Restore enabled, uncomment this
+#packages/
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+
+# Visual Studio profiler
+*.psess
+*.vsp
+
+# ReSharper is a .NET coding add-in
+_ReSharper*
+
+# 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
+
+# Others
+[Bb]in
+[Oo]bj
+sql
+TestResults
+*.Cache
+ClientBin
+stylecop.*
+~$*
+*.dbmdl
+*.ncrunchsolution
+*.ncrunchproject
+Generated_Code #added for RIA/Silverlight projects
+
+# 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
+
+
+
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+
+#############
+## Python
+#############
+
+*.py[co]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+
+# Mac crap
+.DS_Store
+
+############
+## Nuget
+############
+fsharp-stanford-nlp-samples/packages/*
+!fsharp-stanford-nlp-samples/packages/repositories.config
9 README.md
@@ -0,0 +1,9 @@
+The Stanford Natural Language Processing, in F#
+===================================================
+
+This project contains [Stanford NLP](http://www-nlp.stanford.edu/) assemblies (compiled from *.jar files using [IKVM.NET Bytecode Compiler](http://www.ikvm.net/userguide/ikvmc.html)) with samples translated to [F#](http://fsharp.org/).
+
+
+### [Stanford Parser](http://www-nlp.stanford.edu/software/lex-parser.shtml)
+
+Implementations of probabilistic natural language parsers, both highly optimized PCFG and dependency parsers, and a lexicalized PCFG parser in Java. Includes: [Online parser demo](http://nlp.stanford.edu:8080/parser/), [Stanford Dependencies](http://nlp.stanford.edu/software/stanford-dependencies.shtml) page, and [Parser FAQ](http://www-nlp.stanford.edu/software/parser-faq.shtml).
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/arabicFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/chineseFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/chinesePCFG.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/englishFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/englishPCFG.caseless.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/englishPCFG.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/frenchFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/germanFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/germanPCFG.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/wsjFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/wsjPCFG.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/xinhuaFactored.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/xinhuaFactoredSegmenting.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser-2.0.4-models/xinhuaPCFG.ser.gz
Binary file not shown
BIN  StanfordNLPLibraries/stanford-parser/stanford-parser.dll
Binary file not shown
6 fsharp-stanford-nlp-samples/.nuget/NuGet.Config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <solution>
+ <add key="disableSourceControlIntegration" value="true" />
+ </solution>
+</configuration>
BIN  fsharp-stanford-nlp-samples/.nuget/NuGet.exe
Binary file not shown
153 fsharp-stanford-nlp-samples/.nuget/NuGet.targets
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+
+ <!-- Enable the restore command to run before builds -->
+ <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
+
+ <!-- Property that enables building a package from a project -->
+ <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
+
+ <!-- Determines if package restore consent is required to restore packages -->
+ <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
+
+ <!-- Download NuGet.exe if it does not already exist -->
+ <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
+ </PropertyGroup>
+
+ <ItemGroup Condition=" '$(PackageSources)' == '' ">
+ <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
+ <!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
+ <!--
+ <PackageSource Include="https://nuget.org/api/v2/" />
+ <PackageSource Include="https://my-nuget-source/nuget/" />
+ -->
+ </ItemGroup>
+
+ <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
+ <!-- Windows specific commands -->
+ <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+ <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
+ <PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
+ <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
+ <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
+ <PackagesConfig>packages.config</PackagesConfig>
+ <PackagesDir>$(SolutionDir)packages</PackagesDir>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <!-- NuGet command -->
+ <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
+ <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
+
+ <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
+ <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
+
+ <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
+
+ <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
+ <!-- Commands -->
+ <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -o "$(PackagesDir)"</RestoreCommand>
+ <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
+
+ <!-- We need to ensure packages are restored prior to assembly resolve -->
+ <BuildDependsOn Condition="$(RestorePackages) == 'true'">
+ RestorePackages;
+ $(BuildDependsOn);
+ </BuildDependsOn>
+
+ <!-- Make the build depend on restore packages -->
+ <BuildDependsOn Condition="$(BuildPackage) == 'true'">
+ $(BuildDependsOn);
+ BuildPackage;
+ </BuildDependsOn>
+ </PropertyGroup>
+
+ <Target Name="CheckPrerequisites">
+ <!-- Raise an error if we're unable to locate nuget.exe -->
+ <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
+ <SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
+ <!--
+ Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
+ This effectively acts as a lock that makes sure that the download operation will only happen once and all
+ parallel builds will have to wait for it to complete.
+ -->
+ <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
+ </Target>
+
+ <Target Name="_DownloadNuGet">
+ <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
+ </Target>
+
+ <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(RestoreCommand)"
+ Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
+
+ <Exec Command="$(RestoreCommand)"
+ LogStandardErrorAsError="true"
+ Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
+ </Target>
+
+ <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(BuildCommand)"
+ Condition=" '$(OS)' != 'Windows_NT' " />
+
+ <Exec Command="$(BuildCommand)"
+ LogStandardErrorAsError="true"
+ Condition=" '$(OS)' == 'Windows_NT' " />
+ </Target>
+
+ <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+ <ParameterGroup>
+ <OutputFilename ParameterType="System.String" Required="true" />
+ </ParameterGroup>
+ <Task>
+ <Reference Include="System.Core" />
+ <Using Namespace="System" />
+ <Using Namespace="System.IO" />
+ <Using Namespace="System.Net" />
+ <Using Namespace="Microsoft.Build.Framework" />
+ <Using Namespace="Microsoft.Build.Utilities" />
+ <Code Type="Fragment" Language="cs">
+ <![CDATA[
+ try {
+ OutputFilename = Path.GetFullPath(OutputFilename);
+
+ Log.LogMessage("Downloading latest version of NuGet.exe...");
+ WebClient webClient = new WebClient();
+ webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
+
+ return true;
+ }
+ catch (Exception ex) {
+ Log.LogErrorFromException(ex);
+ return false;
+ }
+ ]]>
+ </Code>
+ </Task>
+ </UsingTask>
+
+ <UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+ <ParameterGroup>
+ <EnvKey ParameterType="System.String" Required="true" />
+ <EnvValue ParameterType="System.String" Required="true" />
+ </ParameterGroup>
+ <Task>
+ <Using Namespace="System" />
+ <Code Type="Fragment" Language="cs">
+ <![CDATA[
+ try {
+ Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
+ }
+ catch {
+ }
+ ]]>
+ </Code>
+ </Task>
+ </UsingTask>
+</Project>
16 fsharp-stanford-nlp-samples/StanfordParser.Samples/App.config
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+ </startup>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="4.0.0.0" newVersion="4.3.0.0"/>
+ <bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0"/>
+ <bindingRedirect oldVersion="2.0.0.0" newVersion="4.3.0.0"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
17 fsharp-stanford-nlp-samples/StanfordParser.Samples/JavaCollections.fs
@@ -0,0 +1,17 @@
+module JavaCollections
+
+open java.util
+
+let toSeq (iter:Iterator) =
+ let rec loop (x:Iterator) =
+ seq {
+ yield x.next()
+ if x.hasNext() then
+ yield! (loop x)
+ }
+ loop iter
+
+let toArrayList seq =
+ let list = ArrayList()
+ seq |> Seq.iter (fun x -> list.Add(x))
+ list
57 fsharp-stanford-nlp-samples/StanfordParser.Samples/ParserDemo.fs
@@ -0,0 +1,57 @@
+module ParserDemo
+
+open java.util
+open java.io
+
+open edu.stanford.nlp.objectbank
+open edu.stanford.nlp.``process``
+open edu.stanford.nlp.ling
+open edu.stanford.nlp.trees
+open edu.stanford.nlp.parser.lexparser
+
+let demoDP (lp:LexicalizedParser) (fileName:string) =
+ // This option shows loading and sentence-segment and tokenizing
+ // a file using DocumentPreprocessor
+ let tlp = PennTreebankLanguagePack();
+ let gsf = tlp.grammaticalStructureFactory();
+ // You could also create a tokenizer here (as below) and pass it
+ // to DocumentPreprocessor
+ DocumentPreprocessor(fileName).iterator()
+ |> JavaCollections.toSeq
+ |> Seq.iter (fun sentence ->
+ let parse = lp.apply(sentence);
+ parse.pennPrint();
+
+ let gs = gsf.newGrammaticalStructure(parse);
+ let tdl = gs.typedDependenciesCCprocessed(true);
+ printfn "\n%O\n" tdl
+ )
+
+let demoAPI (lp:LexicalizedParser) =
+ // This option shows parsing a list of correctly tokenized words
+ let sent = [|"This"; "is"; "an"; "easy"; "sentence"; "." |]
+ let rawWords = Sentence.toCoreLabelList(sent)
+ let parse = lp.apply(rawWords)
+ parse.pennPrint()
+
+ // This option shows loading and using an explicit tokenizer
+ let sent2 = "This is another sentence."
+ let tokenizerFactory = PTBTokenizer.factory(CoreLabelTokenFactory(), "")
+ use sent2Reader = new StringReader(sent2)
+ let rawWords2 = tokenizerFactory.getTokenizer(sent2Reader).tokenize()
+ let parse = lp.apply(rawWords2)
+
+ let tlp = PennTreebankLanguagePack()
+ let gsf = tlp.grammaticalStructureFactory()
+ let gs = gsf.newGrammaticalStructure(parse)
+ let tdl = gs.typedDependenciesCCprocessed()
+ printfn "\n%O\n" tdl
+
+ let tp = new TreePrint("penn,typedDependenciesCollapsed")
+ tp.printTree(parse)
+
+let main fileName =
+ let lp = LexicalizedParser.loadModel(@"..\..\..\..\StanfordNLPLibraries\stanford-parser\stanford-parser-2.0.4-models\englishPCFG.ser.gz")
+ match fileName with
+ | Some(file) -> demoDP lp file
+ | None -> demoAPI lp
50 fsharp-stanford-nlp-samples/StanfordParser.Samples/ParserDemo2.fs
@@ -0,0 +1,50 @@
+module ParserDemo2
+
+open java.io
+open java.util
+
+open edu.stanford.nlp.ling
+open edu.stanford.nlp.``process``
+open edu.stanford.nlp.trees
+open edu.stanford.nlp.parser.lexparser
+
+// Usage: ParserDemo2 [[grammar] textFile]
+let main (model:string option) (fileName:string option) =
+ let grammar =
+ match model with
+ | Some(model) -> model
+ | None -> "..\..\..\..\StanfordNLPLibraries\stanford-parser\stanford-parser-2.0.4-models\englishPCFG.ser.gz"
+ let options =[|"-maxLength"; "80"; "-retainTmpSubcategories"|]
+ let lp = LexicalizedParser.loadModel(grammar, options);
+ let tlp = PennTreebankLanguagePack();
+ let gsf = tlp.grammaticalStructureFactory();
+
+ let sentences =
+ match fileName with
+ | Some(file) ->
+ let dp = DocumentPreprocessor(file);
+ dp.iterator()
+ |> JavaCollections.toSeq
+ |> Seq.cast<ArrayList>
+ | None ->
+ // Showing tokenization and parsing in code a couple of different ways.
+ seq {
+ let sent = [| "This"; "is"; "an"; "easy"; "sentence"; "." |]
+ yield sent |> Seq.map (fun w-> Word(w)) |> JavaCollections.toArrayList
+
+ let sent2 ="This is a slightly longer and more complex sentence requiring tokenization."
+ let toke = tlp.getTokenizerFactory().getTokenizer(new StringReader(sent2));
+ yield toke.tokenize() :?> ArrayList
+ }
+
+ for sentence in sentences do
+ let parse = lp.apply(sentence)
+ parse.pennPrint()
+ printfn "\n%O\n" (parse.taggedYield())
+
+ let gs = gsf.newGrammaticalStructure(parse)
+ let tdl = gs.typedDependenciesCCprocessed(true)
+ printfn "%O\n" tdl
+
+ let sent3 = "This is one last test!"
+ lp.apply(sent3).pennPrint()
21 fsharp-stanford-nlp-samples/StanfordParser.Samples/Program.fs
@@ -0,0 +1,21 @@
+type DemoModes =
+ | ParserDemo1
+ | ParserDemo2
+
+[<EntryPoint>]
+let main argv =
+ printfn "%A" argv
+ let (demo, fileName, model) =
+ match argv with
+ | [|"1"|] -> (ParserDemo1, None, None)
+ | [|"1"; fileName|] -> (ParserDemo1, Some(fileName), None)
+ | [|"2"|] -> (ParserDemo2, None, None)
+ | [|"2"; fileName|] -> (ParserDemo2, Some(fileName), None)
+ | [|"2"; fileName; model|] -> (ParserDemo2, Some(fileName), Some(model))
+ | _ -> failwith "Incorrect input parameters"
+
+ match demo with
+ | ParserDemo1 -> ParserDemo.main fileName
+ | ParserDemo2 -> ParserDemo2.main model fileName
+
+ 0 // return an integer exit code
150 fsharp-stanford-nlp-samples/StanfordParser.Samples/StanfordParser.Samples.fsproj
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>5e7b34dd-4def-45b7-8967-6ff8ecc7a9bf</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>StanfordParser.Samples</RootNamespace>
+ <AssemblyName>StanfordParser.Samples</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <Name>StanfordParser.Samples</Name>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <Tailcalls>false</Tailcalls>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DocumentationFile>bin\Debug\StanfordParser.Samples.XML</DocumentationFile>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <Tailcalls>true</Tailcalls>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <WarningLevel>3</WarningLevel>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DocumentationFile>bin\Release\StanfordParser.Samples.XML</DocumentationFile>
+ <Prefer32Bit>true</Prefer32Bit>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="IKVM.AWT.WinForms, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Beans, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Charsets, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Corba, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Core, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Jdbc, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Management, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Media, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Misc, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Naming, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Remoting, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Security, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.SwingAWT, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Text, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Tools, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Util, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.API, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.Bind, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.Crypto, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.Parse, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.Transform, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.WebServices, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML.XPath, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.Runtime, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="IKVM.Runtime.JNI, Version=7.1.4532.2, Culture=neutral, PublicKeyToken=13235d27fcbfff58">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="mscorlib" />
+ <Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="stanford-parser">
+ <HintPath>..\..\StanfordNLPLibraries\stanford-parser\stanford-parser.dll</HintPath>
+ </Reference>
+ <Reference Include="stanford-parser-2.0.4-models">
+ <HintPath>..\..\StanfordNLPLibraries\stanford-parser\stanford-parser-2.0.4-models.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Numerics" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="JavaCollections.fs" />
+ <Compile Include="ParserDemo.fs" />
+ <Compile Include="ParserDemo2.fs" />
+ <Compile Include="Program.fs" />
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ </ItemGroup>
+ <PropertyGroup>
+ <MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
+ </PropertyGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
4 fsharp-stanford-nlp-samples/StanfordParser.Samples/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="IKVM" version="7.2.4630.5" targetFramework="net45" />
+</packages>
27 fsharp-stanford-nlp-samples/fsharp-stanford-nlp-samples.sln
@@ -0,0 +1,27 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "StanfordParser.Samples", "StanfordParser.Samples\StanfordParser.Samples.fsproj", "{5E7B34DD-4DEF-45B7-8967-6FF8ECC7A9BF}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F78F2B97-E867-4D02-92EF-37AB69B190F4}"
+ ProjectSection(SolutionItems) = preProject
+ .nuget\NuGet.Config = .nuget\NuGet.Config
+ .nuget\NuGet.exe = .nuget\NuGet.exe
+ .nuget\NuGet.targets = .nuget\NuGet.targets
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {5E7B34DD-4DEF-45B7-8967-6FF8ECC7A9BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5E7B34DD-4DEF-45B7-8967-6FF8ECC7A9BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5E7B34DD-4DEF-45B7-8967-6FF8ECC7A9BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5E7B34DD-4DEF-45B7-8967-6FF8ECC7A9BF}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
4 fsharp-stanford-nlp-samples/packages/repositories.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<repositories>
+ <repository path="..\StanfordParser.Samples\packages.config" />
+</repositories>
Please sign in to comment.
Something went wrong with that request. Please try again.