Closed YuanKQ closed 7 years ago
I have found the cause. The visit has been banned by DBpedia. And the meaning of the error is as follows:
"Connection reset by peer" is the TCP/IP equivalent of slamming the phone back on the hook. It's more polite than merely not replying, leaving one hanging. But it's not the FIN-ACK expected of the truly polite TCP/IP converseur.
Fortunately, I have found that computing semantic similarity of DBpedia entities is based on the semantic similarity of YAGO concepts which is still accessible.
I solved the problem by crawing the list of the url like ".../class/yago/..." directly from the web page "http://dbpedia.org/resource/..." and refer the code of EntitySimilarity.similarity.
Here is my code.
from sematch.semantic.similarity import EntitySimilarity
# concepts_1: the list of the url like ".../class/yago/..." directly from the web page "http://dbpedia.org/resource/concept1_name"
# concepts_2: the list of the url like ".../class/yago/..." directly from the web page "http://dbpedia.org/resource/concept2_name"
def similarity_test(concepts_1, concepts_2):
sim = EntitySimilarity()
synsets_1 = [sim._yago.yago2synset(c) for c in concepts_1 if sim._yago.yago2synset(c)]
synsets_2 = [sim._yago.yago2synset(c) for c in concepts_2 if sim._yago.yago2synset(c)]
if not synsets_1 or not synsets_2:
return 0.0
s1, _ = zip(*Counter({s: sim._yago.synset_ic(s) for s in synsets_1}).most_common(5))
s2, _ = zip(*Counter({s: sim._yago.synset_ic(s) for s in synsets_2}).most_common(5))
N1 = len(s1)
N2 = len(s2)
score1 = sum([max([sim._yago.similarity(syn1, syn2) for syn2 in s2]) for syn1 in s1]) / N1
score2 = sum([max([sim._yago.similarity(syn1, syn2) for syn1 in s1]) for syn2 in s2]) / N2
return (score1 + score2) / 2.0
Yes, you can download the features and implement those features with the faster local computation. The online computation is designed for easy start and testing.
i met the same question.this may attribute to rhe China's Wall.when i connected to the VPN,the process is ok.i will try Yuan's code.
Hello, I am an undergraduate student and following your research.
When I comput semantic similarity of DBpedia entities using the example codes as follows:
I get the following error:
And the complete error infomations are here:
But when I use "http://dbpedia.org/resource/Madrid" in SPARQL Explorer is OK, could you please tell me why this happen?