FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge branch 'release/v1.0.3' · bocode/python-goose@05e66b4 · GitHub

Commit 05e66b4

Browse files
committed
Merge branch 'release/v1.0.3'
2 parents 050b11f + 31e51e8 commit 05e66b4

5 files changed

Lines changed: 337 additions & 3 deletions

File tree

‎goose/images/extractors.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,19 @@ def _check_elements(elements):
386386
image = _check_elements(elements)
387387
if image is not None:
388388
src = self.parser.getAttribute(image, attr='src')
389-
return self.get_image(image, src, score=90, extraction_type='known')
389+
if src:
390+
return self.get_image(image, src, score=90, extraction_type='known')
390391

391392
# check for elements with known classes
392393
for css in KNOWN_IMG_DOM_NAMES:
393394
elements = self.parser.getElementsByTag(doc, attr='class', value=css)
394395
image = _check_elements(elements)
395396
if image is not None:
396397
src = self.parser.getAttribute(image, attr='src')
397-
return self.get_image(image, src, score=90, extraction_type='known')
398+
if src:
399+
return self.get_image(image, src, score=90, extraction_type='known')
398400

399-
return image
401+
return None
400402

401403
def build_image_path(self, src):
402404
"""\
Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
ad
2+
al
3+
allo
4+
ai
5+
agli
6+
all
7+
agl
8+
alla
9+
alle
10+
con
11+
col
12+
coi
13+
da
14+
dal
15+
dallo
16+
dai
17+
dagli
18+
dall
19+
dagl
20+
dalla
21+
dalle
22+
di
23+
del
24+
dello
25+
dei
26+
degli
27+
dell
28+
degl
29+
della
30+
delle
31+
in
32+
nel
33+
nello
34+
nei
35+
negli
36+
nell
37+
negl
38+
nella
39+
nelle
40+
su
41+
sul
42+
sullo
43+
sui
44+
sugli
45+
sull
46+
sugl
47+
sulla
48+
sulle
49+
per
50+
tra
51+
contro
52+
io
53+
tu
54+
lui
55+
lei
56+
noi
57+
voi
58+
loro
59+
mio
60+
mia
61+
miei
62+
mie
63+
tuo
64+
tua
65+
tuoi
66+
tue
67+
suo
68+
sua
69+
suoi
70+
sue
71+
nostro
72+
nostra
73+
nostri
74+
nostre
75+
vostro
76+
vostra
77+
vostri
78+
vostre
79+
mi
80+
ti
81+
ci
82+
vi
83+
lo
84+
la
85+
li
86+
le
87+
gli
88+
ne
89+
il
90+
un
91+
uno
92+
una
93+
ma
94+
ed
95+
se
96+
perchè
97+
perché
98+
perche
99+
anche
100+
come
101+
dov
102+
dove
103+
che
104+
chi
105+
cui
106+
non
107+
più
108+
piu
109+
quale
110+
quanto
111+
quanti
112+
quanta
113+
quante
114+
quello
115+
quelli
116+
quella
117+
quelle
118+
questo
119+
questi
120+
questa
121+
queste
122+
si
123+
tutto
124+
tutti
125+
a
126+
c
127+
e
128+
i
129+
l
130+
o
131+
ho
132+
hai
133+
ha
134+
abbiamo
135+
avete
136+
hanno
137+
abbia
138+
abbiate
139+
abbiano
140+
avrò
141+
avro
142+
avrai
143+
avrà
144+
avra
145+
avremo
146+
avrete
147+
avranno
148+
avrei
149+
avresti
150+
avrebbe
151+
avremmo
152+
avreste
153+
avrebbero
154+
avevo
155+
avevi
156+
aveva
157+
avevamo
158+
avevate
159+
avevano
160+
ebbi
161+
avesti
162+
ebbe
163+
avemmo
164+
aveste
165+
ebbero
166+
avessi
167+
avesse
168+
avessimo
169+
avessero
170+
avendo
171+
avuto
172+
avuta
173+
avuti
174+
avute
175+
sono
176+
sei
177+
è
178+
é
179+
e
180+
siamo
181+
siete
182+
sia
183+
siate
184+
siano
185+
sarà
186+
sarai
187+
sarò
188+
saro
189+
saremo
190+
sarete
191+
saranno
192+
sarei
193+
saresti
194+
sarebbe
195+
saremmo
196+
sareste
197+
sarebbero
198+
ero
199+
eri
200+
era
201+
eravamo
202+
eravate
203+
erano
204+
fui
205+
fosti
206+
fu
207+
fummo
208+
foste
209+
furono
210+
fossi
211+
fosse
212+
fossimo
213+
fossero
214+
essendo
215+
faccio
216+
fai
217+
facciamo
218+
fanno
219+
faccia
220+
facciate
221+
facciano
222+
farà
223+
farai
224+
farò
225+
faremo
226+
farete
227+
faranno
228+
farei
229+
faresti
230+
farebbe
231+
faremmo
232+
fareste
233+
farebbero
234+
facevo
235+
facevi
236+
faceva
237+
facevamo
238+
facevate
239+
facevano
240+
feci
241+
facesti
242+
fece
243+
facemmo
244+
faceste
245+
fecero
246+
facessi
247+
facesse
248+
facessimo
249+
facessero
250+
facendo
251+
sto
252+
stai
253+
sta
254+
stiamo
255+
stanno
256+
stia
257+
stiate
258+
stiano
259+
starà
260+
starai
261+
starò
262+
staremo
263+
starete
264+
staranno
265+
starei
266+
staresti
267+
starebbe
268+
staremmo
269+
stareste
270+
starebbero
271+
stavo
272+
stavi
273+
stava
274+
stavamo
275+
stavate
276+
stavano
277+
stetti
278+
stesti
279+
stette
280+
stemmo
281+
steste
282+
stettero
283+
stessi
284+
stesse
285+
stessimo
286+
stessero
287+
stando
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
2+
<html>
3+
<head>
4+
<title>test</title>
5+
</head>
6+
7+
<body>
8+
<div>
9+
<img class="storytext" src="http://bla.com/images/465395/"/>
10+
</div>
11+
<div>
12+
<img class="mediaimage" src=""/>
13+
</div>
14+
<div>
15+
<h1>title</h1>
16+
<p>
17+
TextNode 1 - The Scala supported IDE is one of the few pain points of developers who want to start using Scala in their Java project. On existing long term project developed by a team its hard to step in and introduce a new language that is not supported by the existing IDE. On way to go about it is to hid the fact that you use Scala from the Java world by using one way dependency injection. Still, if you wish to truly absorb Scala into your existing java environment then you'll soon introduced cross language dependencies.
18+
</p>
19+
<p>
20+
Most of our team is using Eclipse as the main IDE, its incrimental compilation in Java with its tight JUnit integration are great for fast TDD programming. Unfortunately the Eclipse Scala plugin is not there yet, it may hangs the IDE and messes up Java compilation - especially in large (more then 1000 source files) Java/Scala projects. Though the plugin is getting better over time some developers would find the plugin as a majore drag on their productivity.
21+
For developers who do not write Scala at all or rather edit Scala with other editors, you can use this alternate path which lets them work on their Java or Scala code without messing with the plugin.
22+
</p>
23+
</div>
24+
</body>
25+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"url": "http://go.com/bla/bla",
3+
"expected": {
4+
"cleaned_text" : "TextNode 1 - The Scala supported IDE is one of the few pain points of developers who want to start u",
5+
"top_image": {
6+
"extraction_type": "NA",
7+
"src": "",
8+
"confidence_score": 0.0,
9+
"bytes": 0,
10+
"height": 0,
11+
"width": 0,
12+
"top_image_node": null
13+
}
14+
}
15+
}

‎tests/images.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ def test_known_image_css_id(self):
144144
article = self.getArticle()
145145
self._test_known_image_css(article)
146146

147+
def test_known_image_empty_src(self):
148+
'Tests that img tags for known image sources with empty src attributes are skipped.'
149+
article = self.getArticle()
150+
self._test_known_image_css(article)
151+
147152
def test_opengraph_tag(self):
148153
article = self.getArticle()
149154
self._test_known_image_css(article)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL