Skip to content

Instantly share code, notes, and snippets.

@saludes
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saludes/9364597 to your computer and use it in GitHub Desktop.
Save saludes/9364597 to your computer and use it in GitHub Desktop.
(ns my-gf-java.core)
(def WS_DOC_ROOT
(let [pwd (System/getenv "PWD")]
(str pwd "/resources/")))
(def WS_PORT 41297)
(def WS_URL_LOCALHOST (str "http://localhost:" WS_PORT))
(let [server (str " -server=" WS_PORT)
doc-root (str " --document-root=" WS_DOC_ROOT)]
(println (str "Please run on shell: gf" server doc-root)))
(import 'ch.uzh.ifi.attempto.gfservice.gfwebservice.GfWebService)
(def WS_URI (java.net.URI. WS_URL_LOCALHOST))
(def gf (GfWebService. WS_URI "/grammars/Go.pgf"))
(defn eng-parse-one [input cat]
(let [lang "GoEng"
trees (.getTrees (.parse gf cat input lang) lang)]
(cond
(empty? trees) (println "No parsings")
(> (count trees) 1) (println "Ambiguous")
:else (first trees))))
(defn est-lin [tree]
(.getTexts (.linearize gf tree "GoEst")))
(defproject my-gf-java "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.5.1"]
[com.googlecode.json-simple/json-simple "1.1"]
[com.google.guava/guava "11.0.2"]
[org.apache.httpcomponents/httpcore "4.1.1"]
[org.apache.httpcomponents/httpclient "4.1.1"]
[local/bar "1.0.0"]]
:repositories {"project" "file:repo"})
@saludes
Copy link
Author

saludes commented Mar 5, 2014

I'm using

Leiningen 2.3.4 on Java 1.7.0-ea OpenJDK 64-Bit Server VM

I followed the instructions of https://gist.github.com/stuartsierra/3062743 with gf-java-0.8.1.jar but changing install:install-file to deploy:deploy-file as directed in the first comment.

@saludes
Copy link
Author

saludes commented Mar 5, 2014

There is a resurces/grammars folder where Go.pgf resides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment