Hello All,
I am new here and about Python, I am now in learning progress. When i
am doing examples i have errors that i couldn't solve.
Error1: from "downloads an image" example
from pattern.web import URL
>>> url = URL('
http://www.clips.ua.ac.be/media/pattern_schema.gif')
>>> f = open('test'+extension(
url.page), 'w') # save as test.gif
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
f = open('test'+extension(
url.page), 'w') # save as test.gif
NameError: name 'extension' is not defined
Error2 : from "pattern.graph" example
>>> from pattern.web import Yahoo, plaintext
>>> from pattern.en import Sentence, Chunk, parse
>>> from pattern.search import Pattern
>>> from pattern.graph import Graph, Node, Edge, export
>>>
>>> g = Graph()
>>> for i in range(5):
for r in Yahoo().search('"more important than"', start=i+1,
count=100):
s = plaintext(r.description.lower())
s = Sentence(parse(s))
p = Pattern.fromstring('NP (VP) more important than NP')
for m in p.search(s):
a = m.constituents(p[+0])[-1] # Left NP.
b = m.constituents(p[-1])[+0] # Right NP.
a = (isinstance(a, Chunk) and a.head or a).string
b = (isinstance(b, Chunk) and b.head or b).string
if a and b:
if a not in g:
g.add_node(a, radius=4, stroke=(0,0,0,0.8))
if b not in g:
g.add_node(b, radius=4, stroke=(0,0,0,0.8))
g.add_edge(g[a], g[b], stroke=(0,0,0,0.6))
Traceback (most recent call last):
File "<pyshell#22>", line 2, in <module>
for r in Yahoo().search('"more important than"', start=i+1,
count=100):
File "C:\Python27\lib\site-packages\pattern-2.1-py2.7.egg\pattern\web
\__init__.py", line 970, in search
raise HTTP401Authentication
HTTP401Authentication
Any though is really helps.