-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 54c1140
Showing
19 changed files
with
1,106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
logs | ||
project/project | ||
project/target | ||
target | ||
/.target | ||
/.ensime | ||
/.cache | ||
tmp | ||
.history | ||
dist | ||
/.idea | ||
/*.iml | ||
/out | ||
/.idea_modules | ||
/.classpath | ||
/.project | ||
/RUNNING_PID | ||
/.settings | ||
/project/*-shim.sbt | ||
activator.bat | ||
activator | ||
activator-launch-*.jar | ||
activator-*-shim.sbt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
seco-lexicalanalysis-play | ||
========================= | ||
|
||
SeCo lexical analysis services published as a web service using the Scala Play framework. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import controllers.LexicalAnalysisController | ||
|
||
import com.softwaremill.macwire.MacwireMacros._ | ||
import services.lexicalanalysis.LexicalAnalysisModule | ||
|
||
object Application extends LexicalAnalysisModule { | ||
|
||
val lexicalAnalysisController = wire[LexicalAnalysisController] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import com.softwaremill.macwire.{InstanceLookup, Macwire} | ||
import java.util.Locale | ||
import play.api.GlobalSettings | ||
import play.api.mvc.QueryStringBindable.Parsing | ||
|
||
object Global extends GlobalSettings with Macwire { | ||
val instanceLookup = InstanceLookup(valsByClass(Application)) | ||
|
||
override def getControllerInstance[A](controllerClass: Class[A]) = instanceLookup.lookupSingleOrThrow(controllerClass) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use strict' | ||
|
||
angular.module('index',['play.routing']) | ||
.controller('IdentifyCtrl', ($scope, playRoutes) -> | ||
$scope.text = "The quick brown fox jumps over the lazy dog" | ||
$scope.$watch('text', _.throttle((text) -> | ||
playRoutes.controllers.LexicalAnalysisController.identifyGET(text).get().success((data) -> | ||
$scope.errorStatus = '' | ||
$scope.guessedLang=data | ||
).error((data,status) -> | ||
if (status==0) | ||
$scope.errorStatus = 503 | ||
$scope.error = "Service unavailable" | ||
else | ||
$scope.errorStatus = status | ||
$scope.error = data | ||
) | ||
,1000)) | ||
) | ||
.controller('LemmatizeCtrl', ($scope, playRoutes) -> | ||
$scope.text = "Albert osti fagotin ja töräytti puhkuvan melodian." | ||
$scope.$watchCollection('[text,locale]', _.throttle(() -> | ||
locale = $scope.locale | ||
if locale=='' then locale=null | ||
playRoutes.controllers.LexicalAnalysisController.baseformGET($scope.text,locale).get().success((data) -> | ||
$scope.errorStatus = '' | ||
$scope.baseform=data | ||
).error((data,status) -> | ||
if (status==0) | ||
$scope.errorStatus = 503 | ||
$scope.error = "Service unavailable" | ||
else | ||
$scope.errorStatus = status | ||
$scope.error = data | ||
) | ||
,1000)) | ||
) | ||
.controller('AnalyzeCtrl', ($scope, playRoutes) -> | ||
$scope.text = "Albert osti" | ||
$scope.locale = "fi" | ||
$scope.$watchCollection('[text,locale]', _.throttle(() -> | ||
locale = $scope.locale | ||
if locale=='' then locale=null | ||
playRoutes.controllers.LexicalAnalysisController.analyzeGET($scope.text,locale).get().success((data) -> | ||
$scope.analysis=data | ||
).error((data,status) -> | ||
if (status==0) | ||
$scope.errorStatus = 503 | ||
$scope.error = "Service unavailable" | ||
else | ||
$scope.errorStatus = status | ||
$scope.error = data | ||
) | ||
,1000)) | ||
) | ||
.controller('InflectionCtrl', ($scope, playRoutes) -> | ||
$scope.text = "Albert osti fagotin ja töräytti puhkuvan melodian." | ||
$scope.locale = "fi" | ||
$scope.baseform=true; | ||
$scope.forms = "V N Nom Sg, N Nom Pl, A Pos Nom Pl" | ||
$scope.$watchCollection('[text,locale,baseform,forms]', _.throttle(() -> | ||
locale = $scope.locale | ||
if locale=='' then locale=null | ||
playRoutes.controllers.LexicalAnalysisController.inflectGET($scope.text, $scope.forms.split(/, */),$scope.baseform,locale).get().success((data) -> | ||
$scope.inflection=data | ||
).error((data,status) -> | ||
if (status==0) | ||
$scope.errorStatus = 503 | ||
$scope.error = "Service unavailable" | ||
else | ||
$scope.errorStatus = status | ||
$scope.error = data | ||
) | ||
,1000)) | ||
) | ||
.controller('HyphenationCtrl', ($scope, playRoutes) -> | ||
$scope.text = "Albert osti fagotin ja töräytti puhkuvan melodian." | ||
$scope.$watchCollection('[text,locale]', _.throttle(() -> | ||
locale = $scope.locale | ||
if locale=='' then locale=null | ||
playRoutes.controllers.LexicalAnalysisController.hyphenateGET($scope.text,locale).get().success((data) -> | ||
$scope.hyphenation=data | ||
).error((data,status) -> | ||
if (status==0) | ||
$scope.errorStatus = 503 | ||
$scope.error = "Service unavailable" | ||
else | ||
$scope.errorStatus = status | ||
$scope.error = data | ||
) | ||
,1000)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"use strict"; | ||
|
||
// The service - will be used by controllers or other services, filters, etc. | ||
angular.module("play.routing", []).factory("playRoutes", function($http) { | ||
|
||
/* | ||
* Wrap a Play JS function with a new function that adds the appropriate $http method. | ||
* Note that the url has been already applied to the $http method so you only have to pass in | ||
* the data (if any). | ||
* Note: This is not only easier on the eyes, but must be called in a separate function with its own | ||
* set of arguments, because otherwise JavaScript's function scope will bite us. | ||
* @param playFunction The function from Play's jsRouter to be wrapped | ||
*/ | ||
var wrapHttp = function(playFunction) { | ||
return function(/*arguments*/) { | ||
var routeObject = playFunction.apply(this, arguments); | ||
var httpMethod = routeObject.method.toLowerCase(); | ||
var url = routeObject.url; | ||
var res = { | ||
method : httpMethod, url : url, absoluteUrl : routeObject.absoluteURL, webSocketUrl : routeObject.webSocketURL | ||
}; | ||
res[httpMethod] = function(obj) { | ||
return $http[httpMethod](url, obj); | ||
}; | ||
return res; | ||
}; | ||
}; | ||
|
||
// Add package object, in most cases "controllers" | ||
var addPackageObject = function(packageName, service) { | ||
if (!(packageName in playRoutes)) { | ||
playRoutes[packageName] = {}; | ||
} | ||
}; | ||
|
||
// Add controller object, e.g. Application | ||
var addControllerObject = function(packageName, controllerKey, service) { | ||
if (!(controllerKey in playRoutes[packageName])) { | ||
playRoutes[packageName][controllerKey] = {}; | ||
} | ||
}; | ||
|
||
var playRoutes = {}; | ||
// Loop over all items in the jsRoutes generated by Play, wrap and add them to | ||
// playRoutes | ||
for ( var packageKey in jsRoutes) { | ||
var packageObject = jsRoutes[packageKey]; | ||
addPackageObject(packageKey, playRoutes); | ||
for ( var controllerKey in packageObject) { | ||
var controller = packageObject[controllerKey]; | ||
addControllerObject(packageKey, controllerKey, playRoutes); | ||
for ( var controllerMethodKey in controller) { | ||
playRoutes[packageKey][controllerKey][controllerMethodKey] = wrapHttp(controller[controllerMethodKey]); | ||
} | ||
} | ||
} | ||
return playRoutes; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
body { | ||
padding-top: 70px; | ||
padding-bottom: 70px; | ||
} | ||
|
||
.anchor { | ||
position:relative; | ||
top: -40px; | ||
visibility: hidden; | ||
} | ||
|
||
.affix,.navbar-fixed-top { | ||
-webkit-transform: scale3d(1,1,1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package binders | ||
|
||
import play.api.mvc.QueryStringBindable.Parsing | ||
import play.api.i18n.Lang | ||
import play.api.mvc.QueryStringBindable | ||
import java.util.Locale | ||
|
||
/** | ||
* Created by jiemakel on 24.10.2013. | ||
*/ | ||
object Binders { | ||
implicit object bindableLocale extends Parsing[Locale]( | ||
new Locale(_), _.toString, (key: String, e: Exception) => "Cannot parse parameter %s as Locale: %s".format(key, e.getMessage) | ||
) | ||
} |
Oops, something went wrong.