Skip to content

Commit f0d9776

Browse files
committed
code cleanup, Prudence 1.1 compatibility, added required jars to repo
1 parent 27a62d1 commit f0d9776

File tree

7 files changed

+20
-16
lines changed

7 files changed

+20
-16
lines changed

libraries/com.mongodb.jar

242 KB
Binary file not shown.

libraries/com.mongodb.rhino.jar

14.7 KB
Binary file not shown.
320 KB
Binary file not shown.

libraries/goose-1.4.1.jar

330 KB
Binary file not shown.

libraries/jsoup-1.6.1.jar

275 KB
Binary file not shown.

src/proose/libraries/goose.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ try {
44
importClass(com.google.api.translate.Language)
55
importClass(com.google.api.translate.Translate)
66
} catch(error) {
7-
application.logger.warn("Google Translate Java API not found: Translation feature unavailable.")
7+
application.logger.warning("Google Translate Java API not found: Translation feature unavailable.")
88
}
99
document.execute('register/')
1010

1111
var Goose = Goose || function() {
12-
var Public = {
13-
config: null,
14-
extractor: null,
15-
Extractor: function() {
16-
this.extract = function(uri, srclang, tlang) {
12+
var Public = {
13+
config: null,
14+
extractor: null,
15+
Extractor: function() {
16+
this.extract = function(uri, srclang, tlang) {
1717
try {
1818
// use Goose to extract article title and main text
1919
var article = Public.extractor.extractContent(String(uri))
@@ -35,9 +35,9 @@ var Goose = Goose || function() {
3535
}
3636
}
3737
return retval
38-
}
39-
}
40-
}
38+
}
39+
}
40+
}
4141
// Initialize
4242
Public.config = register(Configuration, null, {'setEnableImageFetching': false})
4343
Public.extractor = register(ContentExtractor, Public.config)
@@ -46,6 +46,6 @@ var Goose = Goose || function() {
4646
} catch(error) {
4747
// Google Translate library is optional
4848
}
49-
return Public
49+
return Public
5050
}()
5151

src/proose/resources/page.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ importClass(com.mongodb.rhino.JSON)
22
document.execute('goose/')
33

44
function handleInit(conversation) {
5-
conversation.addMediaTypeByName('text/html')
6-
conversation.addMediaTypeByName('application/json')
5+
conversation.addMediaTypeByName('text/html')
6+
conversation.addMediaTypeByName('application/json')
77
}
88

99
function handleGet(conversation) {
10-
return 501 // not implemented
10+
// return 501 // not implemented
11+
uri = "http://threecrickets.com/prudence/legal/"
12+
var goose = new Goose.Extractor()
13+
var result = goose.extract(uri, 'en', 'fr')
14+
return JSON.to(result, true)
1115
}
1216

1317
function handlePost(conversation) {
@@ -21,9 +25,9 @@ function handlePost(conversation) {
2125
// http://localhost:8080/proose/page/
2226
var text = conversation.entity.text
2327
var json = JSON.from(String(text))
24-
var uri = json.uri
25-
var srclang = json.source_language || null
26-
var tlang = json.target_language || null
28+
var uri = json.uri
29+
var srclang = json.source_language || null
30+
var tlang = json.target_language || null
2731
var goose = new Goose.Extractor()
2832
var result = goose.extract(uri, srclang, tlang)
2933
if (!result) {

0 commit comments

Comments
 (0)