forked from advancedlogic/GoOse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.go
69 lines (65 loc) · 3.01 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package goose
import (
"github.com/advancedlogic/gojs-config"
)
type configuration struct {
localStoragePath string //not used in this version
imagesMinBytes int //not used in this version
enableImageFetching bool
useMetaLanguage bool
targetLanguage string
imageMagickConvertPath string //not used in this version
imageMagickIdentifyPath string //not used in this version
browserUserAgent string
debug bool
extractPublishDate bool
additionalDataExtractor bool
//path to the stopwords folder
stopWordsPath string
stopWords StopWords
parser *parser
}
func GetDefualtConfiguration(args ...string) configuration {
if len(args) == 0 {
return configuration{
localStoragePath: "", //not used in this version
imagesMinBytes: 4500, //not used in this version
enableImageFetching: true,
useMetaLanguage: true,
targetLanguage: "en",
imageMagickConvertPath: "/usr/bin/convert", //not used in this version
imageMagickIdentifyPath: "/usr/bin/identify", //not used in this version
browserUserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7",
debug: false,
extractPublishDate: false,
additionalDataExtractor: false,
stopWordsPath: "resources/stopwords",
stopWords: NewStopwords(), //TODO with path
parser: NewParser(),
}
} else {
path := args[0]
jsconfiguration, err := jsconfig.LoadConfig(path)
if err != nil {
panic(err.Error())
}
stopWordsPath := jsconfiguration.String("stopWordsPath", "resources/stopwords")
stopWords := NewStopwords() //TODO with path
return configuration{
localStoragePath: jsconfiguration.String("localStoragePath", ""), //not used in this version
imagesMinBytes: jsconfiguration.Int("imageMinBytes", 4500), //not used in this version
enableImageFetching: jsconfiguration.Bool("enableImageFetching", true),
useMetaLanguage: jsconfiguration.Bool("useMetaLanguage", true),
targetLanguage: jsconfiguration.String("targetLanguage", "en"),
imageMagickConvertPath: jsconfiguration.String("imageMagickConvertPath", "/usr/bin/convert"), //not used in this version
imageMagickIdentifyPath: jsconfiguration.String("imageMagickIdentityPath", "/usr/bin/identify"), //not used in this version
browserUserAgent: jsconfiguration.String("browserUserAgent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7"),
debug: jsconfiguration.Bool("debug", false),
extractPublishDate: jsconfiguration.Bool("extractPublishDate", false), //TODO
additionalDataExtractor: jsconfiguration.Bool("additionalDataExtractor", false), //TODO
stopWordsPath: stopWordsPath,
stopWords: stopWords,
parser: NewParser(),
}
}
}