-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
executable file
·145 lines (125 loc) · 3.87 KB
/
Copy pathconfig.py
File metadata and controls
executable file
·145 lines (125 loc) · 3.87 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/python
# coding: utf-8
"""..module:: archiveprocessor.config.
..moduleauthor:: Jan Lehecka <jlehecka@ntis.zcu.cz>
"""
from metadata import (
CONTENT,
TOKENS,
SENTENCES,
URLKEY,
REFERSTO,
HARVESTID,
TITLE,
PLAINTEXT,
LANGUAGE,
SENTIMENT,
HEADLINES,
TOPICS,
LINKS,
WEBPAGETYPE,
RESPONSECODE
)
# Logger setting, possible levels are: debug, info, warning, error, critical.
# Set LOG_FILE to empty string for logging into STDOUT (works only in
# standalone local mode).
LOG_LVL = 'info'
LOG_FILE = '/opt/archiveprocessor/ArchiveProcessor.log'
# HBase settings
HBASE_HOST = ""
HBASE_PORT = 9099
HBASE_MAIN_TABLE = "main"
HBASE_HARV_TABLE = "harvest"
HBASE_CONF_TABLE = "config"
HBASE_PROC_TABLE = "processes"
PROC_STATUS_RUNNING = "running"
PROC_STATUS_FINISHED = "finished"
PROC_STATUS_FAILED = "failed"
# record types to be processed (this is 'WARC-Type' field in the WARC headers)
RECORD_TYPES = ["response", "revisit"]
# groups of supported MIME types (regular expressions to be matched)
RECORD_MIME_TYPES = {
'HTML': r'(text/html|application/xhtml\+xml)',
'PDF': r'application/pdf',
'IMG': r'image/*',
# TODO:audio/video
}
# process only records satisfying these metadata regexp filters
RECORD_FILTERS = {
RESPONSECODE: r'^2\d\d$',
}
# HTML records larger than this size (in bytes) will be skipped.
# This is to prevent Justext from getting stucked for a long time on
# one extremely large HTML.
# Example of such record URL:
# https://www.sportis.cz/search.php?rok=
# (warning: your browser could be stucked for a while as well)
MAX_ALLOWED_HTML_CONTENT_SIZE = 20000000
# Skip WARC records with content length longer than this size (in bytes).
# This prevents memory problems with processing too long records with wrong
# MIME types (e.g. video saved as a text).
# In current project phase, we are interested only in records reasonable small
# (HTML, PDF, text, images, ...)
MAX_ALLOWED_WARC_CONTENT_SIZE = 100000000 # ~100 MB
JUSTEXT_BASE_SETTING = dict(
length_low=70,
length_high=140,
stopwords_low=0.2,
stopwords_high=0.3,
max_link_density=0.4,
max_good_distance=5,
max_heading_distance=150,
no_headings=True
)
# if JusText does not find any text, keep trying again with following setting
# fall-backs
JUSTEXT_FALLBACK_SETTING = [
# allow whole text paragraph to be one link
dict(max_link_density=1),
# text paragraphs can be far away from each other
dict(max_good_distance=20),
]
# stoplists are lists of the most frequent words in languages;
# they are used to guess what is the main language of a web page
STOPLISTS = {
'cs': 'stoplists/cs.txt',
'sk': 'stoplists/sk.txt',
'en': 'stoplists/en.txt',
'de': 'stoplists/de.txt',
'pl': 'stoplists/pl.txt',
'ru': 'stoplists/ru.txt',
'fr': 'stoplists/fr.txt',
}
# metadata which will be dropped from the intermediary JSON before saving
UNNECESSARY_FIELDS = [
CONTENT,
TOKENS,
SENTENCES
]
# metadata which will have separate column in output database.
# The output row for each record will have following columns:
# key: globally unique ID of the record
# 1,2,...,N-1: fields specified in OUTPUT_SEPARATE_COLS
# N: "IF": the rest of intermediary format (i.e. IF minus
# UNNECESSARY_FIELDS, minus OUTPUT_SEPARATE_COLS)
OUTPUT_SEPARATE_COLS = [
URLKEY,
REFERSTO,
HARVESTID,
TITLE,
PLAINTEXT,
LANGUAGE,
SENTIMENT,
HEADLINES,
TOPICS,
LINKS,
WEBPAGETYPE
]
# path to JSON schema of intermediary format
JSON_SCHEMA = 'schema.json'
# Directory where NLTK Punkt corpus is saved
NLTK_DATA_DIR = "NLTK_data"
# trained sklearn model for topic identification
TOPICS_CLF_MODEL = '/opt/archiveprocessor/TopicIdentification.pkl'
# trained sklearn model for sentiment analysis
SENTIMENT_CLF_MODEL = '/opt/archiveprocessor/SentimentAnalysis.pkl'