本文整理匯總了Python中extractor.Extractor.getUris方法的典型用法代碼示例。如果您正苦於以下問題:Python Extractor.getUris方法的具體用法?Python Extractor.getUris怎麽用?Python Extractor.getUris使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類extractor.Extractor
的用法示例。
在下文中一共展示了Extractor.getUris方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ext_json
# 需要導入模塊: from extractor import Extractor [as 別名]
# 或者: from extractor.Extractor import getUris [as 別名]
def ext_json():
rdfUrl = ''
tok = Tokenizer()
if request.method == 'POST':
rdf = request.form['data']
status_test = "0"#request.form['status']
filters = ""#request.form['exculdeurls']
#rdf = "http://jpp.no-ip.org/MAD_J.rdf"
try:
#r = requests.get(rdf)
gg = Graph()
#g.load(rdfUrl)
rdf_content = StringIO.StringIO(rdf.encode('utf-8'))
#print rdf_content.readline()
gg.parse(rdf_content, format="xml")
ext = Extractor(gg)
uris = ext.getUris()
mapping = MapFactory()
for uri in uris:
term = tok.tokenized_url(uri)
uri_status = ""
if status_test == "1":
uri_status = ext.testUri(uri)
else:
uri_status = "N/A"
uri_lookup = str(uri)+"\""
lnum = ext.get_lines(rdf_content, uri_lookup)
ent = MapEntry(uri, term, "", lnum, uri_status)
mapping.add(ent)
jsonized_result = json.dumps(mapping.get())
return Response(jsonized_result, mimetype='application/json')
except requests.exceptions.ConnectionError:
X2Rwarning = 'X2R Warning: The requested URL raises ConnectionError~!!!'
return X2Rwarning
示例2: test
# 需要導入模塊: from extractor import Extractor [as 別名]
# 或者: from extractor.Extractor import getUris [as 別名]
def test():
g = Graph()
#g.parse("MAD_D.rdf", format="xml")
f = open("./testsuite/test_fixtures/MAD_D.rdf", 'rb')
st = f.read().decode('utf-8')
print type(st)
g.parse(StringIO.StringIO(st.encode('utf-8')), format="xml")
ext = Extractor(g)
uris = ext.getUris()
print ext.terms()
ext.getBnodes()
示例3: ext_result
# 需要導入模塊: from extractor import Extractor [as 別名]
# 或者: from extractor.Extractor import getUris [as 別名]
def ext_result():
rdfUrl = ''
if request.method == 'POST':
rdfUrl = request.form['url']
try:
r = requests.get(rdfUrl)
#rdfUrl = str(r.status_code)
g = Graph()
#g.parse("MAD.rdf", format="xml")
g.load(rdfUrl)
ext = Extractor(g)
uris = ext.getUris()
terms = ext.terms()
result = {}
result['uris'] = uris
result['terms'] = terms
result['bNodes'] =str(len(ext.getBnodes()))
result['uNodes'] = str(len(uris))
return render_template('index.html', result= result)
except requests.exceptions.ConnectionError:
X2Rwarning = 'X2R Warning: The requested URL raises ConnectionError~!!!'
return X2Rwarning