parent
296c2ce840
commit
7c5922e5af
@ -1 +0,0 @@
|
|||||||
{u'expr': u'Id = 1912875929', u'entities': [{u'logprob': -11.773, u'Id': 1912875929}]}
|
|
@ -1,41 +0,0 @@
|
|||||||
Total Size: 39
|
|
||||||
[2094437628, 2273736245]
|
|
||||||
[2094437628, 3880285, 2094437628, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2094437628, 2273736245]
|
|
||||||
[2094437628, 2311122994, 2094437628, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2088397685, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2054283902, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2021067283, 2273736245]
|
|
||||||
[2094437628, 2311122994, 2021067283, 2273736245]
|
|
||||||
[2094437628, 2311122994, 2136111777, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2136111777, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2067111928, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2086923594, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2033935581, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2053077389, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2003918905, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2048481564, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2017318430, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2067477861, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2046860686, 2273736245]
|
|
||||||
[2094437628, 2311122994, 2046860686, 2273736245]
|
|
||||||
[2094437628, 2273736245, 1996704434, 2273736245]
|
|
||||||
[2094437628, 2311122994, 1996704434, 2273736245]
|
|
||||||
[2094437628, 2273736245, 1991518848, 2273736245]
|
|
||||||
[2094437628, 2311122994, 1991518848, 2273736245]
|
|
||||||
[2094437628, 2311122994, 2272756406, 2273736245]
|
|
||||||
[2094437628, 2273736245, 2272756406, 2273736245]
|
|
||||||
[2094437628, 2311122994, 1928727717, 2273736245]
|
|
||||||
[2094437628, 2273736245, 1928727717, 2273736245]
|
|
||||||
[2094437628, 2273736245, 165450437, 2273736245]
|
|
||||||
[2094437628, 2311122994, 165450437, 2273736245]
|
|
||||||
[2094437628, 124657808, 2094437628, 2273736245]
|
|
||||||
[2094437628, 121332964, 2094437628, 2273736245]
|
|
||||||
[2094437628, 124657808, 2088397685, 2273736245]
|
|
||||||
[2094437628, 121332964, 2088397685, 2273736245]
|
|
||||||
[2094437628, 124657808, 2054283902, 2273736245]
|
|
||||||
[2094437628, 121332964, 2067111928, 2273736245]
|
|
||||||
[2094437628, 121332964, 2033935581, 2273736245]
|
|
||||||
[2094437628, 121332964, 2067477861, 2273736245]
|
|
||||||
[2094437628, 121332964, 2046860686, 2273736245]
|
|
||||||
total time: 6143
|
|
@ -1,104 +0,0 @@
|
|||||||
{
|
|
||||||
"expr" : "Composite(AA.AuId = 2014261844)",
|
|
||||||
"entities" :
|
|
||||||
[{ "logprob":-19.889, "Id":2114096741, "Ti":"a survey of geodesic paths on 3d surfaces", "Y":2011, "CC":11, "RId":[2149906774, 2256863592, 1999244633, 1238092070, 1999690352, 2166164984, 2054113582, 2084224084, 2161253909, 2159361280, 2130726152, 1999545213, 2108567935, 2280326949, 2141409037, 2005276292, 2028769163, 1990466879, 2331180561, 2081777693, 2170220350, 1989723858, 2129612824, 2074537686, 2169528473, 2120424341, 2072019354, 2042746037, 2029649144, 2074682596, 613480278, 2159549579, 2112346596, 1984697939, 1980197133, 1014505, 240977677, 1999558884, 2132432991, 2167732668, 2094360223, 2018164813, 2012669981, 2049480565, 2024733248, 98519300, 2123631536, 2089694170, 2114121462, 1579058916, 2017117017, 2047629658, 2079841800, 1972774658, 1974931598, 2162703138, 1526047146, 2037134555, 2109278560, 2134422883, 2053723042, 1993264991, 2122845873, 2019758632, 2162114735, 1810598584, 2147690196, 49068151, 1497277914, 2042706118, 1998692689, 1977998901], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2154897350,"AfId":67031392}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2014261844,"AfId":197604219}], "F":[{"FId":22590252}, {"FId":157498722}, {"FId":29123130}, {"FId":2524010}, {"FId":33923547}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-19.916, "Id":2156148354, "Ti":"algorithms for optimal outlier removal", "Y":2009, "CC":7, "RId":[2005314985, 2026771935, 2029948740, 145790213, 2339150939, 2059985428, 1972858511, 2110507702, 2046227217, 2010790640, 2048493433, 2042473201, 2102902634, 1516306206, 2302532677, 1968215127, 1977838112, 2044445959, 2005311123, 2167927607, 2123817071, 148814178], "AA":[{"AuId":2057698039,"AfId":67031392}, {"AuId":2120994602,"AfId":67031392}, {"AuId":2138755643,"AfId":67031392}, {"AuId":2154897350,"AfId":67031392}, {"AuId":2160857524,"AfId":67031392}, {"AuId":2169685232,"AfId":67031392}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":206194317}, {"FId":176222170}, {"FId":29123130}, {"FId":33923547}], "J":{"JId":163424111} },
|
|
||||||
{ "logprob":-19.974, "Id":2131970932, "Ti":"shrec 10 track non rigid 3d shape retrieval", "Y":2010, "CC":16, "RId":[2151103935, 2131846894, 1625255723, 2099789128, 2056132907, 2131791003, 1999690352, 2159361280, 2106629076, 2071866949, 1982465050, 2172246656, 2151245724, 2063513338, 2084286148, 2084548435, 1885760432, 2238971733, 2123631536], "AA":[{"AuId":2097668895,"AfId":1321296531}, {"AuId":2134662681,"AfId":1321296531}, {"AuId":2171331403,"AfId":99464096}, {"AuId":2133292699,"AfId":66906201}, {"AuId":2190956648,"AfId":99464096}, {"AuId":2166627689,"AfId":66906201}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2146978970,"AfId":99464096}, {"AuId":2096876795,"AfId":99464096}, {"AuId":2030948482,"AfId":99464096}, {"AuId":2014261844,"AfId":197604219}] },
|
|
||||||
{ "logprob":-20.036, "Id":2099361645, "Ti":"linear reconfiguration of cube style modular robots", "Y":2009, "CC":7, "RId":[1526777436, 2164380970, 2126295536, 2117416080, 2056453745, 2059661411, 1012009150, 2169676578, 2231045347, 1508698264], "AA":[{"AuId":76407621,"AfId":132053463}, {"AuId":2047536997,"AfId":132053463}, {"AuId":2139371818,"AfId":7863295}, {"AuId":380982395,"AfId":63966007}, {"AuId":2300589195,"AfId":920285187}, {"AuId":695374658,"AfId":132053463}, {"AuId":1995729299,"AfId":202524275}, {"AuId":2102544858,"AfId":178766854}, {"AuId":1985301561,"AfId":9617848}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":193435613}, {"FId":114614502}, {"FId":33923547}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-20.070, "Id":2052243599, "Ti":"statistical analysis of 3d faces in motion", "Y":2013, "CC":4, "RId":[], "AA":[{"AuId":57898110,"AfId":91712215}, {"AuId":2014261844,"AfId":91712215}] },
|
|
||||||
{ "logprob":-20.162, "Id":1012009150, "Ti":"reconfiguration of cube style modular robots using o log n parallel moves", "Y":2008, "CC":7, "RId":[2117416080, 2056453745], "AA":[{"AuId":76407621}, {"AuId":2047536997}, {"AuId":380982395}, {"AuId":695374658}, {"AuId":1985301561}, {"AuId":2014261844}], "J":{"JId":106296714} },
|
|
||||||
{ "logprob":-20.223, "Id":2109991685, "Ti":"efficient constant velocity reconfiguration of crystalline robots", "Y":2011, "CC":4, "RId":[2101392651, 2149841830, 1909393615, 2167382904, 1526777436, 1999730797, 2149602461, 1972350, 1976620677, 2121795633, 2164380970, 1566041730, 2126295536, 2032219063, 2117416080, 2140517064, 2132817270, 2035233472, 1982236134, 1972590691, 2056453745, 2033719238, 2163689710, 2164438790, 2104005082, 2188492432, 2099361645, 2116110704, 2056053005, 119161764, 2044917890, 1487445608, 2145386076, 2333066315, 2294545116], "AA":[{"AuId":76407621}, {"AuId":2307369388,"AfId":132053463}, {"AuId":2139371818,"AfId":7863295}, {"AuId":380982395,"AfId":63966007}, {"AuId":2300589195,"AfId":920285187}, {"AuId":695374658,"AfId":132053463}, {"AuId":1995729299,"AfId":202524275}, {"AuId":135182615,"AfId":35462925}, {"AuId":2102544858,"AfId":178766854}, {"AuId":2303622677,"AfId":906480834}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":81074085}, {"FId":154945302}, {"FId":41008148}], "J":{"JId":92163612} },
|
|
||||||
{ "logprob":-20.313, "Id":2107465918, "Ti":"filling holes in triangular meshes by curve unfolding", "Y":2009, "CC":5, "RId":[1977758817, 2129412583, 2061010610, 2237825899, 2129098897, 1543226262, 1998255762, 2171542563, 2081507207, 2045471990, 2121669559, 2008151176, 1909076809, 2018110063, 1991845454, 2056725994, 1583585595, 2008888582, 2034609976, 1708197474, 2017477785, 2105522022, 1521071054], "AA":[{"AuId":1984903675,"AfId":197604219}, {"AuId":2014261844,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2120994602,"AfId":67031392}, {"AuId":380982395,"AfId":63966007}] },
|
|
||||||
{ "logprob":-20.314, "Id":2159031003, "Ti":"landmark free posture invariant human shape correspondence", "Y":2011, "CC":9, "RId":[2237250383, 2049981393, 2119851068, 334078648, 1989191365, 2104480174, 2025062188, 2159361280, 2098578926, 2098466221, 2123487031, 2042246564, 2064499898, 1969076082, 2026935851, 1944448249, 2115298906, 2037149239, 2141387879, 2003014378, 1542263132, 2113000721], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2099631723,"AfId":197604219}], "F":[{"FId":41008148}], "J":{"JId":73060445} },
|
|
||||||
{ "logprob":-20.384, "Id":2002018157, "Ti":"π 2 angle yao graphs are spanners", "Y":2012, "CC":5, "RId":[2095977717], "AA":[{"AuId":2120994602}, {"AuId":2139371818}, {"AuId":286320687}, {"AuId":1995729299}, {"AuId":812850721}, {"AuId":2007139549}, {"AuId":2014261844}], "F":[{"FId":29302406}, {"FId":33923547}], "J":{"JId":25827807} },
|
|
||||||
{ "logprob":-20.388, "Id":1936186068, "Ti":"building statistical shape spaces for 3d human modeling", "Y":2015, "CC":1, "RId":[], "AA":[{"AuId":308162991,"AfId":149899117}, {"AuId":2014261844}, {"AuId":209677723}, {"AuId":214804705,"AfId":149899117}, {"AuId":1620943014,"AfId":149899117}] },
|
|
||||||
{ "logprob":-20.429, "Id":2010532093, "Ti":"a low dimensional representation for robust partial isometric correspondences computation", "Y":2014, "CC":2, "RId":[2237250383, 1989191365, 2137306662, 1992187125, 2100657858, 2211546658, 1513908640, 2117888987, 2159361280, 2098578926, 2004402003, 2122578066, 2105106232, 1985290145, 2098466221, 2104198297, 2127025496, 2123487031, 2073431710, 1982465050, 2180873826, 1985222241, 1993846356, 1983445044, 2040436296, 1969076082, 2047161559, 1965805571, 2053126129, 2130595631, 2294879381, 2065270678, 1709959390, 2016663152, 2166606682, 2037149239, 2100187127, 2012385660, 2093544140, 2151917516, 2105591368, 2123631536, 2045323633, 1989995855, 2112192224, 2013273872], "AA":[{"AuId":1984903675,"AfId":149899117}, {"AuId":2101927313,"AfId":149899117}, {"AuId":2014261844}, {"AuId":2135052836,"AfId":149899117}, {"AuId":73181535,"AfId":149899117}], "J":{"JId":137436721} },
|
|
||||||
{ "logprob":-20.483, "Id":2123631536, "Ti":"posture invariant correspondence of incomplete triangular manifolds", "Y":2011, "CC":10, "RId":[1989191365, 2051434435, 2159361280, 2143030836, 2091626191, 2140500712, 1999597013, 2041771459, 1997744504], "AA":[{"AuId":2014261844}, {"AuId":2132968838}, {"AuId":2120994602}, {"AuId":2127044776}], "J":{"JId":68340538} },
|
|
||||||
{ "logprob":-20.486, "Id":1981018417, "Ti":"segmenting animated objects into near rigid components", "Y":2009, "CC":13, "RId":[2099789128, 2122007052, 2104480174, 2023808821, 1993962870, 2160994953, 1572663059, 2052728883, 2121717885, 2123487031, 2168907905, 2108891011, 1969076082, 2091715846, 2071894871, 2110340327, 2155953655, 2104680386, 2208573830], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":1984903675,"AfId":197604219}], "F":[{"FId":45633534}, {"FId":29123130}, {"FId":2524010}], "J":{"JId":73060445} },
|
|
||||||
{ "logprob":-20.549, "Id":1987121049, "Ti":"human shape correspondence with automatically predicted landmarks", "Y":2012, "CC":4, "RId":[2119851068, 1540992968, 2099606917, 1989191365, 2104480174, 2098466221, 2115298906], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2099631723,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}], "C":{"CId":1155500043} },
|
|
||||||
{ "logprob":-20.668, "Id":1487445608, "Ti":"realistic reconfiguration of crystalline and telecube robots", "Y":2009, "CC":2, "RId":[1526777436, 2117416080, 2056453745, 2188492432], "AA":[{"AuId":76407621,"AfId":132053463}, {"AuId":2047536997,"AfId":132053463}, {"AuId":2139371818,"AfId":7863295}, {"AuId":380982395,"AfId":63966007}, {"AuId":1723144653,"AfId":60158472}, {"AuId":2300589195,"AfId":920285187}, {"AuId":695374658,"AfId":132053463}, {"AuId":1995729299,"AfId":202524275}, {"AuId":135182615,"AfId":35462925}, {"AuId":2102544858,"AfId":102322142}, {"AuId":1985301561,"AfId":9617848}, {"AuId":2014261844,"AfId":67031392}] },
|
|
||||||
{ "logprob":-20.673, "Id":268639037, "Ti":"automatic location of landmarks used in manual anthropometry", "Y":2014, "CC":0, "RId":[2153635508, 2295332248, 2171490473, 1510526001, 1569530544, 2154980168, 1735588541, 1994359450, 2003014378, 2059393299, 1985851765, 2079294336], "AA":[{"AuId":2157123513,"AfId":119439378}, {"AuId":2131007269,"AfId":119439378}, {"AuId":1996155268,"AfId":119439378}, {"AuId":2103542331,"AfId":136259955}, {"AuId":2174370829,"AfId":60158472}, {"AuId":1965603897,"AfId":142476485}, {"AuId":2225981013,"AfId":99464096}, {"AuId":2134662681,"AfId":1321296531}, {"AuId":2139958683,"AfId":1321296531}, {"AuId":168721329,"AfId":142476485}, {"AuId":2232402393,"AfId":142476485}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2135990543,"AfId":99464096}, {"AuId":2096876795,"AfId":99464096}, {"AuId":728773384,"AfId":136259955}, {"AuId":2030948482,"AfId":99464096}, {"AuId":2014261844,"AfId":91712215}, {"AuId":2099631723,"AfId":197604219}] },
|
|
||||||
{ "logprob":-20.718, "Id":2084142581, "Ti":"establishing strong connectivity using optimal radius half disk antennas", "Y":2013, "CC":3, "RId":[2093381928, 2104142168, 2120296177, 2009782889, 2112970581, 2102709759, 2154743412, 2147322856, 42897049], "AA":[{"AuId":76407621}, {"AuId":2139371818}, {"AuId":2300589195}, {"AuId":2140429713}, {"AuId":2280126321}, {"AuId":2133297015}, {"AuId":2014261844}], "F":[{"FId":64671776}, {"FId":13743678}, {"FId":94523657}, {"FId":114614502}, {"FId":33923547}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-20.718, "Id":2143039717, "Ti":"estimating 3d human shapes from measurements", "Y":2011, "CC":5, "RId":[2153504150, 2158179171, 2020466163, 2005645152, 2280326949, 2077557812, 2030575031, 1987121049], "AA":[{"AuId":2014261844,"AfId":91712215}, {"AuId":2132968838,"AfId":197604219}], "F":[{"FId":153180895}, {"FId":60627051}, {"FId":41008148}], "C":{"CId":1155500043} },
|
|
||||||
{ "logprob":-20.781, "Id":2093088, "Ti":"correspondences of persistent feature points on near isometric surfaces", "Y":2012, "CC":1, "RId":[2222512263, 2137306662, 2166820607, 2100657858, 1590776313, 2064020260, 2130646036, 2161253909, 2105106232, 2127025496, 2123487031, 2073431710, 2146019744, 1969076082, 1970279742, 2102838323, 2147373864, 1993167366, 2095705972], "AA":[{"AuId":2276897403,"AfId":149899117}, {"AuId":2130756756,"AfId":149899117}, {"AuId":2014261844,"AfId":149899117}, {"AuId":1984903675}, {"AuId":1995219829}, {"AuId":2135052836,"AfId":149899117}, {"AuId":73181535,"AfId":149899117}], "C":{"CId":1124077590} },
|
|
||||||
{ "logprob":-20.810, "Id":2149284486, "Ti":"automatically creating design models from 3d anthropometry data", "Y":2012, "CC":4, "RId":[1975442866, 2337065094, 334078648, 2211546658, 2104198297, 2100961486, 1944448249, 2157100308, 2067482733, 2028666973, 2003014378, 2036834050, 2055824434, 2159031003, 1995061439, 1503456783, 2170244379], "AA":[{"AuId":2014261844}, {"AuId":2132968838}, {"AuId":2120994602}], "F":[{"FId":73586568}, {"FId":46886674}, {"FId":39840566}, {"FId":29123130}, {"FId":2524010}, {"FId":33923547}], "J":{"JId":173178594} },
|
|
||||||
{ "logprob":-20.817, "Id":184244079, "Ti":"pi 2 angle yao graphs are spanners", "Y":2010, "CC":3, "RId":[2031671531, 2095977717], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2139371818,"AfId":7863295}, {"AuId":286320687,"AfId":67031392}, {"AuId":1995729299,"AfId":202524275}, {"AuId":812850721,"AfId":67031392}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":197604219}], "C":{"CId":1175727152} },
|
|
||||||
{ "logprob":-20.828, "Id":2057922595, "Ti":"posture invariant surface description and feature extraction", "Y":2010, "CC":4, "RId":[2124386111, 2153504150, 2295382923, 1999690352, 1590776313, 2025062188, 2130646036, 2159361280, 2121717885, 2098578926, 2134448913, 1969076082, 2103525210, 2151694303, 2161813446], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2127044776,"AfId":29607241}, {"AuId":2132968838,"AfId":197604219}], "F":[{"FId":178207025}, {"FId":194401833}, {"FId":52102323}, {"FId":181145010}, {"FId":9083635}, {"FId":77304879}, {"FId":124504099}, {"FId":64876066}, {"FId":97970142}, {"FId":52622490}, {"FId":198107850}, {"FId":1674844}, {"FId":205372480}, {"FId":9417928}, {"FId":31972630}, {"FId":41008148}], "C":{"CId":1158167855} },
|
|
||||||
{ "logprob":-20.843, "Id":1988539193, "Ti":"three dimensional human shape inference from silhouettes reconstruction and validation", "Y":2011, "CC":4, "RId":[2104974755, 1989191365, 2117007522, 1999690352, 2164942161, 1494238748, 1967490225], "AA":[{"AuId":1970210942}, {"AuId":2132968838}, {"AuId":2014261844}, {"AuId":2099631723}], "C":{"CId":1155500043} },
|
|
||||||
{ "logprob":-20.856, "Id":2048359624, "Ti":"fully automatic expression invariant face correspondence", "Y":2014, "CC":3, "RId":[2140190241, 2152826865, 2237250383, 2019599312, 334078648, 2051434435, 2137306662, 1992187125, 2161116336, 2153759571, 2159361280, 2098578926, 2137821246, 1985290145, 2130093472, 2135042441, 2135666716, 2158054470, 1976295221, 2097365005, 2104539097, 2047836041, 2116258886, 2128258626, 2151231840, 2003014378, 1967879679, 2159031003, 1966800193, 1601628837, 2093120612, 2136500581, 2102717885, 2086359182, 2148535600, 2306421343], "AA":[{"AuId":2331953835,"AfId":84593992}, {"AuId":2014261844,"AfId":91712215}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2099866554,"AfId":36243813}], "F":[{"FId":14961307}], "C":{"CId":1155500043} },
|
|
||||||
{ "logprob":-20.887, "Id":2034643056, "Ti":"estimation of human body shape and posture under clothing", "Y":2014, "CC":1, "RId":[2159080219, 2099940712, 1540992968, 1989191365, 2051434435, 2104480174, 1999690352, 2211546658, 2159361280, 2158179171, 2122578066, 2071866949, 2165258384, 2098466221, 2088230067, 2109752307, 1993846356, 1965805571, 2075834168, 1944448249, 2074407824, 2154750607, 2026861142, 2159031003, 2080666679, 2114621449], "AA":[{"AuId":2014261844}, {"AuId":308162991,"AfId":149899117}, {"AuId":1984903675}, {"AuId":2305398014}, {"AuId":2308397549}], "J":{"JId":185008460} },
|
|
||||||
{ "logprob":-20.910, "Id":1576311670, "Ti":"reconfiguration of 3d crystalline robots using o log n parallel moves", "Y":2009, "CC":0, "RId":[], "AA":[{"AuId":2311459076}, {"AuId":2305207799,"AfId":63966007}, {"AuId":380982395}, {"AuId":695374658}, {"AuId":1985301561}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-21.002, "Id":2114621449, "Ti":"posture invariant statistical shape analysis using laplace operator", "Y":2012, "CC":4, "RId":[2119350939, 334078648, 1989191365, 1999690352, 2211546658, 2125949583, 2169776045, 2104198297, 2158778494, 1909894032, 1993846356, 2052069724, 1944448249, 2106466172, 2074407824, 2103296388, 1520035080, 2073655956, 2120383035, 2036834050, 2086435606], "AA":[{"AuId":2014261844}, {"AuId":2132968838}, {"AuId":2099631723}], "F":[{"FId":165700671}], "J":{"JId":94821547} },
|
|
||||||
{ "logprob":-21.034, "Id":1600526016, "Ti":"reconfiguration of cube style modular robots using o logn parallel moves", "Y":2008, "CC":0, "RId":[1526777436, 2164380970, 2126295536, 2117416080, 2056453745], "AA":[{"AuId":76407621,"AfId":132053463}, {"AuId":2047536997,"AfId":132053463}, {"AuId":380982395,"AfId":63966007}, {"AuId":695374658,"AfId":132053463}, {"AuId":1985301561,"AfId":9617848}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":120373497}, {"FId":41008148}, {"FId":33923547}], "C":{"CId":1175727152} },
|
|
||||||
{ "logprob":-21.053, "Id":2089277703, "Ti":"posture invariant correspondence of triangular meshes in shape space", "Y":2009, "CC":4, "RId":[2049981393, 2099789128, 1989191365, 1999690352, 2159361280, 2123487031, 2153487529, 2143030836, 2068333134, 1486218565, 2061845601], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2120994602,"AfId":67031392}], "F":[{"FId":178207025}, {"FId":194401833}, {"FId":181145010}, {"FId":53533937}, {"FId":77660652}, {"FId":66024118}, {"FId":1674844}, {"FId":2524010}, {"FId":33923547}], "C":{"CId":1164975091} },
|
|
||||||
{ "logprob":-21.055, "Id":2150635919, "Ti":"review of statistical shape spaces for 3d data with comparative analysis for human faces", "Y":2012, "CC":2, "RId":[2115755118, 2038952578, 2117188745, 334078648, 2085261163, 1989191365, 2051434435, 1992187125, 2211546658, 2125949583, 2166743687, 1544875853, 2142152601, 2104198297, 2135666716, 1976295221, 1993846356, 2104539097, 1965805571, 2075834168, 2069997605, 2074407824, 1575243757, 2067032877, 2012048984, 2063601108, 2163183381, 2066090933, 1995712965, 2134389879, 2154320156, 2163399942, 1553670630, 2030116982, 2143039717, 1988539193, 2114621449], "AA":[{"AuId":1984903675,"AfId":149899117}, {"AuId":2193757115}, {"AuId":57898110}, {"AuId":2014261844}], "J":{"JId":185008460} },
|
|
||||||
{ "logprob":-21.072, "Id":2113000721, "Ti":"semi automatic prediction of landmarks on human models in varying poses", "Y":2010, "CC":2, "RId":[1999690352, 2113656553, 2159361280, 2123487031, 2153487529, 2074407824, 2037149239, 2003014378, 2036834050], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2127044776,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}], "F":[{"FId":52102323}, {"FId":27511587}, {"FId":204707403}, {"FId":193293595}, {"FId":127011070}, {"FId":159886148}, {"FId":66024118}, {"FId":1674844}, {"FId":105795698}], "C":{"CId":1160896163} },
|
|
||||||
{ "logprob":-21.079, "Id":2127958493, "Ti":"posture invariant gender classification for 3d human models", "Y":2009, "CC":2, "RId":[2135541996, 1999690352, 2161253909, 1971957654, 2014877967, 2002286769, 2003014378, 2103525210, 2146308415, 2112646535, 2162114735, 2230315448, 2141267000], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2001181309,"AfId":197604219}], "F":[{"FId":12267149}, {"FId":110083411}, {"FId":119857082}, {"FId":41008148}], "C":{"CId":1158167855} },
|
|
||||||
{ "logprob":-21.095, "Id":2187479452, "Ti":"shrec 14 track automatic location of landmarks used in manual anthropometry", "Y":2014, "CC":1, "RId":[2295332248, 2019599312, 2171490473, 1510526001, 1569530544, 168966905, 2154980168, 1735588541, 1994359450, 2034105264, 2003014378, 2059393299, 1985851765, 2079294336, 2113000721], "AA":[{"AuId":2157123513}, {"AuId":2131007269}, {"AuId":1996155268}, {"AuId":2103542331}, {"AuId":2174370829}, {"AuId":1965603897}, {"AuId":2225981013}, {"AuId":2134662681}, {"AuId":2110580142}, {"AuId":168721329}, {"AuId":2116133272}, {"AuId":2135990543}, {"AuId":2096876795}, {"AuId":728773384}, {"AuId":2030948482}, {"AuId":2014261844}, {"AuId":2099631723}] },
|
|
||||||
{ "logprob":-21.172, "Id":2010839818, "Ti":"tracking complete deformable objects with finite elements", "Y":2012, "CC":4, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":2164413517}, {"AuId":2132968838}] },
|
|
||||||
{ "logprob":-21.190, "Id":1520300017, "Ti":"linear reconfiguration of cube style modular robots", "Y":2007, "CC":0, "RId":[1526777436, 2117416080], "AA":[{"AuId":76407621,"AfId":132053463}, {"AuId":2047536997,"AfId":132053463}, {"AuId":2139371818,"AfId":7863295}, {"AuId":380982395,"AfId":63966007}, {"AuId":298322331,"AfId":920285187}, {"AuId":695374658,"AfId":132053463}, {"AuId":2108112919,"AfId":202524275}, {"AuId":2102544858,"AfId":178766854}, {"AuId":1985301561,"AfId":9617848}, {"AuId":2014261844,"AfId":67031392}], "C":{"CId":1175727152} },
|
|
||||||
{ "logprob":-21.204, "Id":2030723399, "Ti":"a linear space algorithm for distance preserving graph embedding", "Y":2009, "CC":3, "RId":[2053186076, 2001141328, 2067752346, 2340006107, 2051434435, 1999690352, 2166164984, 2159361280, 2105082158, 1973264045, 2096141080, 2134201719, 1566976463, 2044028871, 1999823999, 1972859956, 2162114735, 2018998921], "AA":[{"AuId":2111668054,"AfId":177738480}, {"AuId":2120994602,"AfId":67031392}, {"AuId":2042195894,"AfId":67031392}, {"AuId":2154897350,"AfId":67031392}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":75564084}, {"FId":176370821}, {"FId":186450821}, {"FId":49847556}, {"FId":91682802}, {"FId":73555534}, {"FId":176012381}, {"FId":2524010}, {"FId":33923547}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-21.218, "Id":2080526711, "Ti":"3d faces in motion fully automatic registration and statistical analysis", "Y":2015, "CC":1, "RId":[1560013842, 2085261163, 1992187125, 2102924784, 2104425538, 2104198297, 2135666716, 1909894032, 1976295221, 32702425, 2143829622, 2104539097, 2038891881, 1965805571, 2166672191, 2069997605, 1575243757, 1990940174, 2067032877, 2012048984, 2163183381, 1995712965, 2003706019, 2087642411, 2134389879, 2011556862, 2012075579, 2096020629, 2052243599, 2162280462, 2089623493, 2136500581, 2030116982, 2149284486, 2048359624, 2076756054, 2087960557, 1590053313, 2021679049], "AA":[{"AuId":57898110}, {"AuId":2014261844}], "F":[{"FId":105795698}], "J":{"JId":185008460} },
|
|
||||||
{ "logprob":-21.220, "Id":2119872517, "Ti":"a characterization of the degree sequences of 2 trees", "Y":2008, "CC":1, "RId":[301824129, 2087083200, 2336652925, 2064721098, 2005706719, 1592352976, 1598444089, 195844759, 2000204877, 2136019314, 1996874849, 2161839451, 2287138200, 2079721544], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2284031192,"AfId":67031392}, {"AuId":270679271,"AfId":100538780}, {"AuId":695374658,"AfId":132053463}, {"AuId":2160857524,"AfId":67031392}, {"AuId":2158694965}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":48785453}, {"FId":132569581}, {"FId":114614502}, {"FId":33923547}], "J":{"JId":193368155} },
|
|
||||||
{ "logprob":-21.229, "Id":2036688247, "Ti":"finite element based tracking of deforming surfaces", "Y":2015, "CC":0, "RId":[334078648, 2211546658, 2122578066, 2129494071, 2143703219, 1985290145, 2098466221, 2082254676, 2109752307, 2127374940, 1965805571, 2168685057, 2081927584, 2016663152, 1988179100, 2023560768, 2146700972, 2041855012, 2002980568, 2091593985, 2117541425, 2006303959, 2091843001, 2038837307], "AA":[{"AuId":2014261844,"AfId":91712215}, {"AuId":2164413517,"AfId":153718931}, {"AuId":2088902210,"AfId":153718931}, {"AuId":2132968838,"AfId":197604219}], "J":{"JId":137436721} },
|
|
||||||
{ "logprob":-21.257, "Id":2114241394, "Ti":"pi 2 angle yao graphs are spanners", "Y":2010, "CC":0, "RId":[], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2139371818,"AfId":7863295}, {"AuId":286320687,"AfId":67031392}, {"AuId":1995729299,"AfId":202524275}, {"AuId":812850721,"AfId":67031392}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":197604219}] },
|
|
||||||
{ "logprob":-21.270, "Id":2251676003, "Ti":"3d faces in motion", "Y":2015, "CC":0, "RId":[2237250383, 2085261163, 2051434435, 2137306662, 1992187125, 2102924784, 2104425538, 2104198297, 1909894032, 1976295221, 32702425, 2104539097, 2146161009, 1575243757, 1990940174, 2067032877, 2003706019, 2129360799, 2087642411, 2011556862, 2096020629, 2162653225, 2089623493, 2075759375, 2093120612, 2136500581, 2030116982, 2149284486, 2164118058, 2087960557], "AA":[{"AuId":57898110,"AfId":91712215}, {"AuId":2014261844,"AfId":91712215}], "F":[{"FId":105795698}], "J":{"JId":185008460} },
|
|
||||||
{ "logprob":-21.322, "Id":2124999587, "Ti":"image based model completion", "Y":2007, "CC":2, "RId":[2033819227, 2160014001, 2129098897, 2005126631, 1543226262, 2120977599, 1981940178, 1969549682, 2081507207, 1541700072, 2008151176, 2165455240, 1991845454, 2157688203, 2085858393, 2017477785, 1997641715, 140307293, 2279061013], "AA":[{"AuId":1984903675,"AfId":197604219}, {"AuId":2014261844,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}], "F":[{"FId":182310444}, {"FId":2524010}, {"FId":41008148}], "C":{"CId":1149416356} },
|
|
||||||
{ "logprob":-21.331, "Id":2104765276, "Ti":"morphing of triangular meshes in shape space", "Y":2011, "CC":2, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":2120994602}, {"AuId":2103437391}, {"AuId":1995729299}, {"AuId":1984903675}], "F":[{"FId":50637493}, {"FId":29123130}, {"FId":2524010}, {"FId":33923547}], "J":{"JId":68340538} },
|
|
||||||
{ "logprob":-21.378, "Id":2063175732, "Ti":"rotationally monotone polygons", "Y":2009, "CC":1, "RId":[2149906774, 2129879687, 2139230981, 2126876121, 1825136300, 1481903970, 2063346183, 2045783875, 2080276023, 2306830116, 2022832678, 1553375877, 1997316506, 2034428396, 2028695830], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2160857524,"AfId":67031392}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":197949415}, {"FId":72169020}, {"FId":2524010}, {"FId":33923547}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-21.386, "Id":2115896006, "Ti":"shape from suggestive contours using 3d priors", "Y":2012, "CC":1, "RId":[], "AA":[{"AuId":2014261844,"AfId":91712215}, {"AuId":2132968838}], "F":[{"FId":27438332}, {"FId":155650255}, {"FId":31510193}, {"FId":31972630}, {"FId":119857082}, {"FId":41008148}], "C":{"CId":1160896163} },
|
|
||||||
{ "logprob":-21.387, "Id":2296729236, "Ti":"a low dimensional representation for robust partial isometric correspondences computation", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":1984903675}, {"AuId":2101927313}, {"AuId":2014261844}, {"AuId":73181535}, {"AuId":2135052836}] },
|
|
||||||
{ "logprob":-21.432, "Id":2064761790, "Ti":"efficient reconfiguration of lattice based modular robots", "Y":2013, "CC":2, "RId":[1526777436, 2096537964, 1524850010, 2139714790, 2117416080, 2032768325, 2188492432, 2099361645, 1012009150, 2056053005], "AA":[{"AuId":76407621}, {"AuId":2059928011}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":2300589195}, {"AuId":2112876687}, {"AuId":2014261844}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-21.460, "Id":2027612430, "Ti":"bending invariant meshes and application to groupwise correspondences", "Y":2009, "CC":0, "RId":[2053186076, 2001141328, 2099789128, 1999690352, 1590776313, 2025062188, 2159361280, 2144083240, 2140500712, 1982366717, 2147647517, 2090320629, 2018110063, 1999597013, 1566976463, 2108258308, 92634156, 158821397], "AA":[{"AuId":2014261844,"AfId":197604219}, {"AuId":2132968838,"AfId":197604219}, {"AuId":1970210942,"AfId":197604219}, {"AuId":2159171761,"AfId":197604219}, {"AuId":2099631723,"AfId":197604219}], "F":[{"FId":194401833}, {"FId":165818556}, {"FId":181145010}, {"FId":120174047}, {"FId":77660652}, {"FId":66024118}, {"FId":106516650}, {"FId":1674844}, {"FId":192939610}, {"FId":2524010}, {"FId":33923547}], "C":{"CId":1164975091} },
|
|
||||||
{ "logprob":-21.503, "Id":2231045347, "Ti":"realistic reconfiguration of crystalline and telecube robots", "Y":2008, "CC":1, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2047536997}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":1723144653}, {"AuId":298322331}, {"AuId":695374658}, {"AuId":1995729299}, {"AuId":135182615}, {"AuId":2102544858}, {"AuId":1586814107}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-21.511, "Id":2267768293, "Ti":"smi 2012 full posture invariant statistical shape analysis using laplace operator", "Y":2012, "CC":0, "RId":[334078648, 1989191365, 2051434435, 1631674738, 1999690352, 2125949583, 2144570481, 1944448249, 2036834050, 2096071249], "AA":[{"AuId":2014261844,"AfId":91712215}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2099631723,"AfId":197604219}], "F":[{"FId":165700671}], "J":{"JId":94821547} },
|
|
||||||
{ "logprob":-21.512, "Id":62232106, "Ti":"characterization of partial intrinsic symmetries", "Y":2014, "CC":0, "RId":[1626653188, 1590776313, 1544875853, 2127025496, 2155957710, 2091791686, 2130518695, 2145093702, 2077031952, 2130595631, 2161271908, 2145524482, 2146527621, 2093544140, 1540641376, 2116077655, 2161420750, 2025044072, 2045323633, 2000403788, 2295140937, 1534713745, 2171851104, 2260540739], "AA":[{"AuId":2109044626,"AfId":91712215}, {"AuId":2060265658,"AfId":4923324}, {"AuId":2014261844,"AfId":91712215}, {"AuId":2101927313,"AfId":193662353}], "F":[{"FId":41008148}], "C":{"CId":1124077590} },
|
|
||||||
{ "logprob":-21.527, "Id":2106341096, "Ti":"isometric morphing of triangular meshes", "Y":2008, "CC":1, "RId":[2140798815, 2147774191, 2048158019, 2154084374, 1542792704, 2014770458, 2144707889, 2168771843], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":1995729299,"AfId":202524275}, {"AuId":2132968838}, {"AuId":2014261844}], "F":[{"FId":194401833}, {"FId":171836373}, {"FId":33923547}], "C":{"CId":1201479284} },
|
|
||||||
{ "logprob":-21.556, "Id":1668992945, "Ti":"morphing of triangular meshes in shape space", "Y":2008, "CC":0, "RId":[2122007052, 1572663059, 2151636374, 2142326458, 2147774191, 2095986812, 2091804476, 2048158019, 2154084374, 1944448249, 2098727428, 2092053444, 2036834050, 2144707889, 2030458754, 2106341096], "AA":[{"AuId":2014261844,"AfId":67031392}, {"AuId":2120994602,"AfId":67031392}, {"AuId":2132968838,"AfId":197604219}, {"AuId":1995729299}, {"AuId":1984903675,"AfId":153718931}] },
|
|
||||||
{ "logprob":-21.561, "Id":1807911131, "Ti":"multilinear wavelets a statistical shape space for human faces", "Y":2014, "CC":0, "RId":[2117188745, 2071866949, 2142152601, 2135666716, 32702425, 1965805571, 2087642411, 2052243599, 2131202735, 1511946343], "AA":[{"AuId":2060265658,"AfId":4923324}, {"AuId":57898110,"AfId":91712215}, {"AuId":2014261844,"AfId":91712215}], "C":{"CId":1124077590} },
|
|
||||||
{ "logprob":-21.722, "Id":1561451935, "Ti":"geodesic paths on 3d surfaces survey and open problems", "Y":2009, "CC":2, "RId":[], "AA":[{"AuId":2154897350}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-21.752, "Id":1973850282, "Ti":"algorithms for designing clamshell molds", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":2120994602}, {"AuId":2160857524}, {"AuId":2007139549}], "F":[{"FId":16635281}, {"FId":175700187}, {"FId":29123130}, {"FId":2524010}], "J":{"JId":143715161} },
|
|
||||||
{ "logprob":-21.794, "Id":2162114735, "Ti":"approximations of geodesic distances for incomplete triangular manifolds", "Y":2007, "CC":3, "RId":[1999690352, 2161253909, 2159361280, 2108567935, 2104700297, 1999597013, 92634156, 158821397, 2018998921], "AA":[{"AuId":2127044776}, {"AuId":2120994602}, {"AuId":2132968838}, {"AuId":2014261844}], "F":[{"FId":165818556}, {"FId":2524010}, {"FId":33923547}], "C":{"CId":1201479284} },
|
|
||||||
{ "logprob":-21.801, "Id":1553375877, "Ti":"rotational clamshell casting in three dimensions", "Y":2006, "CC":1, "RId":[], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2160857524,"AfId":67031392}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}] },
|
|
||||||
{ "logprob":-21.873, "Id":2310280492, "Ti":"a robust multilinear model learning framework for 3d faces", "Y":2016, "CC":0, "RId":[], "AA":[{"AuId":57898110}, {"AuId":2014261844}], "C":{"CId":1158167855} },
|
|
||||||
{ "logprob":-21.889, "Id":2123817071, "Ti":"removing outliers to minimize area and perimeter", "Y":2006, "CC":1, "RId":[2048493433, 2042473201, 2167927607], "AA":[{"AuId":2057698039,"AfId":67031392}, {"AuId":2160857524,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":206194317}, {"FId":2524010}, {"FId":33923547}], "C":{"CId":1201479284} },
|
|
||||||
{ "logprob":-21.949, "Id":2055752405, "Ti":"3d anthropometric data processing", "Y":2012, "CC":1, "RId":[], "AA":[{"AuId":2132968838}, {"AuId":2014261844}, {"AuId":2099631723}], "J":{"JId":183335753} },
|
|
||||||
{ "logprob":-21.979, "Id":2336233787, "Ti":"clamshell casting", "Y":2009, "CC":0, "RId":[301824129, 2126876121, 2059155916, 2067631433, 2292025986, 1538991644, 2085041675, 2113830395, 153494752, 180909918, 2125685982, 2002507856, 23500900], "AA":[{"AuId":2120994602,"AfId":67031392}, {"AuId":2160857524,"AfId":67031392}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}], "J":{"JId":89324355} },
|
|
||||||
{ "logprob":-22.013, "Id":2141646866, "Ti":"linear space algorithms for distance preserving embedding", "Y":2007, "CC":0, "RId":[2166164984, 2134921160, 1973264045, 1999823999], "AA":[{"AuId":2111668054}, {"AuId":2120994602,"AfId":67031392}, {"AuId":2042195894,"AfId":67031392}, {"AuId":2154897350,"AfId":67031392}, {"AuId":2132968838,"AfId":197604219}, {"AuId":2007139549,"AfId":67031392}, {"AuId":2014261844,"AfId":67031392}], "F":[{"FId":75564084}, {"FId":176370821}, {"FId":186450821}, {"FId":87195055}, {"FId":2524010}, {"FId":33923547}], "C":{"CId":1201479284} },
|
|
||||||
{ "logprob":-22.073, "Id":2261888986, "Ti":"fitting a 3d morphable model to edges a comparison between hard and soft correspondences", "Y":2016, "CC":0, "RId":[], "AA":[{"AuId":2269457212}, {"AuId":2253705556}, {"AuId":57898110}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.104, "Id":1808135090, "Ti":"a statistical shape space model of the palate surface trained on 3d mri scans of the vocal tract", "Y":2015, "CC":0, "RId":[], "AA":[{"AuId":2079520017}, {"AuId":2168222028}, {"AuId":57898110}, {"AuId":2014261844}, {"AuId":2158195643}] },
|
|
||||||
{ "logprob":-22.120, "Id":1599889834, "Ti":"linear reconfiguration of cube style modular robots", "Y":2007, "CC":0, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2047536997}, {"AuId":1947593104}, {"AuId":380982395}, {"AuId":2300589195}, {"AuId":695374658}, {"AuId":1995729299}, {"AuId":2102544858}, {"AuId":1985301561}, {"AuId":2014261844}], "J":{"JId":106296714} },
|
|
||||||
{ "logprob":-22.140, "Id":2180648442, "Ti":"a groupwise multilinear correspondence optimization for 3d faces", "Y":2015, "CC":0, "RId":[], "AA":[{"AuId":57898110}, {"AuId":2014261844}], "C":{"CId":1164975091} },
|
|
||||||
{ "logprob":-22.143, "Id":1633576308, "Ti":"algorithms for optimal outlier removal 1 rossen atanassov prosenjit bose mathieu couture", "Y":2012, "CC":0, "RId":[], "AA":[{"AuId":2154897350}, {"AuId":2160857524}, {"AuId":2169685232}, {"AuId":2007139549}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.259, "Id":771468320, "Ti":"realistic reconfiguration of crystalline and teletube robots", "Y":2008, "CC":0, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2047536997}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":1723144653}, {"AuId":2300589195}, {"AuId":695374658}, {"AuId":1995729299}, {"AuId":135182615}, {"AuId":2102544858}, {"AuId":1985301561}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.266, "Id":2269332872, "Ti":"matching and morphing of isometric models", "Y":2009, "CC":1, "RId":[], "AA":[{"AuId":2014261844,"AfId":67031392}] },
|
|
||||||
{ "logprob":-22.289, "Id":1658042064, "Ti":"analysis of farthest point sampling for approximating geodesics in a graph", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":195882947}, {"AuId":2241594721}, {"AuId":2154897350}, {"AuId":2014261844}], "F":[{"FId":101837359}, {"FId":148764684}, {"FId":114614502}, {"FId":33923547}], "J":{"JId":165542689} },
|
|
||||||
{ "logprob":-22.389, "Id":2295413353, "Ti":"establishing strong connectivity using optimal radius half disk antennas", "Y":2011, "CC":1, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2139371818}, {"AuId":298322331}, {"AuId":2140429713}, {"AuId":2280126321}, {"AuId":2133297015}, {"AuId":2014261844}], "C":{"CId":1201479284} },
|
|
||||||
{ "logprob":-22.393, "Id":2051898570, "Ti":"filling holes in triangular meshes using digital images by curve unfolding", "Y":2011, "CC":1, "RId":[2033819227, 2160014001, 2099789128, 1977758817, 2129412583, 2051434435, 2061010610, 2237825899, 2129098897, 2005126631, 1543226262, 2120977599, 1998255762, 2111240761, 2171542563, 1981940178, 2081507207, 2151214419, 2071111253, 2045471990, 2145093702, 1541700072, 2121669559, 2008151176, 2165455240, 1909076809, 2018110063, 2038126344, 1991845454, 2056725994, 1583585595, 2008888582, 2034609976, 1708197474, 2007847953, 2042254269, 1966871317, 2084188728, 2017477785, 1997641715, 2105522022, 140307293, 2279061013], "AA":[{"AuId":1984903675}, {"AuId":2014261844}, {"AuId":2103437391}, {"AuId":2120994602}, {"AuId":380982395}], "J":{"JId":68340538} },
|
|
||||||
{ "logprob":-22.425, "Id":2294545116, "Ti":"efficient reconfiguration of lattice based modular robots", "Y":2009, "CC":1, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2059928011}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":298322331}, {"AuId":2112876687}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.435, "Id":2296577209, "Ti":"how to cite this article", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2047536997}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":1827704974}, {"AuId":695374658}, {"AuId":135182615}, {"AuId":2102544858}, {"AuId":1985301561}, {"AuId":2014261844}, {"AuId":2295413464}] },
|
|
||||||
{ "logprob":-22.713, "Id":2180134226, "Ti":"a characterization of the degree sequences of 2 trees", "Y":2007, "CC":0, "RId":[], "AA":[{"AuId":2120994602}, {"AuId":1973971504}, {"AuId":270679271}, {"AuId":695374658}, {"AuId":2160857524}, {"AuId":2158694965}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.736, "Id":2199709889, "Ti":"a characterization of the degree sequences of 2 trees", "Y":2006, "CC":0, "RId":[], "AA":[{"AuId":2120994602}, {"AuId":1973971504}, {"AuId":270679271}, {"AuId":695374658}, {"AuId":2160857524}, {"AuId":2158694965}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.768, "Id":2294962059, "Ti":"rotationally monotone polygons", "Y":2006, "CC":0, "RId":[], "AA":[{"AuId":2120994602}, {"AuId":2160857524}, {"AuId":2007139549}, {"AuId":2014261844}], "C":{"CId":1201479284} },
|
|
||||||
{ "logprob":-22.863, "Id":2052207545, "Ti":"a general framework to generate sizing systems from 3d motion data applied to face mask design", "Y":2014, "CC":0, "RId":[2237250383, 334078648, 2137306662, 2211546658, 1566413196, 2157100308, 2028666973, 2163131540, 2052243599, 1963954287, 2162048995, 2138930031, 2030740176, 2149284486], "AA":[{"AuId":57898110}, {"AuId":2120994602}, {"AuId":2132968838}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.885, "Id":2225840200, "Ti":"filling holes in triangular meshes by curve unfolding", "Y":2009, "CC":0, "RId":[], "AA":[{"AuId":380982395}, {"AuId":2120994602}, {"AuId":2132968838}, {"AuId":2014261844}, {"AuId":1984903675}] },
|
|
||||||
{ "logprob":-22.891, "Id":761823114, "Ti":"communaute francaise de belgique arc", "Y":2009, "CC":0, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2047536997}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":1723144653}, {"AuId":1827704974}, {"AuId":695374658}, {"AuId":135182615}, {"AuId":2102544858}, {"AuId":1985301561}, {"AuId":2014261844}, {"AuId":2137867949}, {"AuId":2140062869}, {"AuId":2045170451}] },
|
|
||||||
{ "logprob":-22.891, "Id":2241341858, "Ti":"linear reconfiguration of cube style modular robots", "Y":2009, "CC":0, "RId":[], "AA":[{"AuId":380982395}, {"AuId":76407621}, {"AuId":2047536997}, {"AuId":2139371818}, {"AuId":695374658}, {"AuId":2108112919}, {"AuId":2102544858}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.891, "Id":829689105, "Ti":"efficient reconfiguration for lattice based modular robots", "Y":2009, "CC":0, "RId":[], "AA":[{"AuId":76407621}, {"AuId":2059928011}, {"AuId":2139371818}, {"AuId":380982395}, {"AuId":2300589195}, {"AuId":2112876687}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-22.929, "Id":2293810765, "Ti":"a hybrid approach to 3d tongue modeling from vocal tract mri using unsupervised image segmentation and mesh deformation", "Y":2014, "CC":0, "RId":[], "AA":[{"AuId":2079520017}, {"AuId":2168222028}, {"AuId":2014261844}], "C":{"CId":1177287137} },
|
|
||||||
{ "logprob":-23.063, "Id":2294471017, "Ti":"a statistical shape space model of the palate surface trained on 3d mri scans of the vocal tract", "Y":2016, "CC":0, "RId":[], "AA":[{"AuId":2079520017}, {"AuId":2168222028}, {"AuId":57898110}, {"AuId":2014261844}, {"AuId":2158195643}] },
|
|
||||||
{ "logprob":-23.205, "Id":2296119166, "Ti":"automatically creating design models from 3d anthropometry data", "Y":2011, "CC":0, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":2132968838}, {"AuId":2120994602}] },
|
|
||||||
{ "logprob":-23.359, "Id":2179812682, "Ti":"statistical shape spaces for 3d data a review", "Y":2016, "CC":0, "RId":[], "AA":[{"AuId":1984903675}, {"AuId":2331953835}, {"AuId":57898110}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.364, "Id":2337456168, "Ti":"analysis of farthest point sampling for approximating geodesics in a graph", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":195882947}, {"AuId":2241594721}, {"AuId":2154897350}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.394, "Id":2293869343, "Ti":"fully automatic expression invariant face correspondence", "Y":2012, "CC":0, "RId":[], "AA":[{"AuId":2309876607}, {"AuId":2014261844}, {"AuId":2132968838}, {"AuId":2099866554}] },
|
|
||||||
{ "logprob":-23.397, "Id":2184304798, "Ti":"order type invariant labeling and comparison of point sets", "Y":2012, "CC":0, "RId":[2157266306, 16939786, 1967443570, 1966030595, 2129175815, 1968264007, 2034752889, 2052653263, 2020541197], "AA":[{"AuId":2188808206}, {"AuId":2112876687}, {"AuId":695374658}, {"AuId":2102544858}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.519, "Id":2294893056, "Ti":"finite element based tracking of deforming surfaces", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":2164413517}, {"AuId":2088902210}, {"AuId":2132968838}] },
|
|
||||||
{ "logprob":-23.519, "Id":2295845112, "Ti":"estimation of human body shape and posture under clothing", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":308162991}, {"AuId":1984903675}, {"AuId":2132968838}, {"AuId":2164413517}] },
|
|
||||||
{ "logprob":-23.519, "Id":2064118604, "Ti":"from 3 d scans to design tools", "Y":2013, "CC":0, "RId":[], "AA":[{"AuId":2132968838}, {"AuId":2031320464}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.587, "Id":2296127659, "Ti":"multilinear wavelets a statistical shape space for human faces", "Y":2014, "CC":0, "RId":[], "AA":[{"AuId":1984903675}, {"AuId":57898110}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.733, "Id":2188958145, "Ti":"establishing strong connectivity using optimal", "Y":2012, "CC":0, "RId":[2102709759, 42897049], "AA":[{"AuId":2181913596}, {"AuId":2300589195}, {"AuId":2140429713}, {"AuId":2133297015}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.747, "Id":2295499190, "Ti":"estimating 3d human shapes from measurements", "Y":2011, "CC":0, "RId":[], "AA":[{"AuId":2014261844}, {"AuId":2132968838}] },
|
|
||||||
{ "logprob":-23.815, "Id":2296099950, "Ti":"comparative analysis of statistical shape spaces", "Y":2012, "CC":0, "RId":[], "AA":[{"AuId":1984903675}, {"AuId":2331953835}, {"AuId":57898110}, {"AuId":2014261844}] },
|
|
||||||
{ "logprob":-23.815, "Id":2249684012, "Ti":"review and comparative analysis of statistical shape spaces of 3d data", "Y":2012, "CC":0, "RId":[2115755118, 2038952578, 2237250383, 2137306662, 1992187125, 2125949583, 1566413196, 2152826766, 2158179171, 2142152601, 2088230067, 1976295221, 2100484145, 1520005879, 2075834168, 2074407824, 1992475172, 2156736396, 2166468061, 1575243757, 2163183381, 2066090933, 2131202735, 2110733656, 1553670630, 2149466360, 1511946343, 2030575031, 2030116982, 108644101, 2131039592, 2147886171, 1912889008, 1533103600], "AA":[{"AuId":1984903675}, {"AuId":2331953835}, {"AuId":57898110}, {"AuId":2014261844}] }]
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
[1995672522, 2091164805]
|
|
||||||
[[2034917438, 205783295, 2014602748], [2034917438, 1995672522, 2014602748], [2034917438, 1995672522, 2017562024, 2014602748], [2034917438, 1995672522, 2034190349, 2014602748], [2034917438, 1995672522, 2093894241, 2014602748]]
|
|
||||||
225
|
|
@ -1,119 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
input = [2132060629,307743305]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
#''''''''''''''''''''''''''''''''''[AA.AuId, AA.AuId]'''''''''''''''''''''''''''''''''
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr': exp1,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id,AA.AfId,AA.AuId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#'''''''''''''''''''''''''2nd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'count': '1000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
if id2["Id"] not in Id2:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for aaid1 in Id1:
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print len(deresult)
|
|
@ -1,167 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
input = [2251253715, 2180737804]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''2nd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp2 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data2
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id',
|
|
||||||
'model': 'latest',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for Aid in Id1:
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print len(result)
|
|
@ -1,15 +0,0 @@
|
|||||||
[[2251253715, 2180737804], [2251253715, 2180737804, 2048498903, 2180737804], [2251253715, 2180737804, 2223920688, 2180737804], [2251253715, 2180737804, 949266530, 2180737804], [2251253715, 2180737804, 1783833040, 2180737804], [2251253715, 2180737804, 2251253715, 2180737804], [2251253715, 2180737804, 2108096461, 2180737804], [2251253715, 2180737804, 35927321, 2180737804], [2251253715, 2299839756, 2048498903, 2180737804], [2251253715, 2299839756, 949266530, 2180737804], [2251253715, 2299839756, 2223920688, 2180737804], [2251253715, 2299839756, 1783833040, 2180737804], [2251253715, 2299839756, 2251253715, 2180737804], [2251253715, 2299839756, 2108096461, 2180737804]]
|
|
||||||
Total Size: 14
|
|
||||||
|
|
||||||
2251253715
|
|
||||||
2273736245
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2180737804
|
|
||||||
2094437628
|
|
@ -1,226 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input = [1970381522,2162351023]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
#''''''''''''''''''''''''''''''''''[id0, id1]'''''''''''''''''''''''''''''''''
|
|
||||||
#'''''''''''''''1st API''''''''''''''''''''''''
|
|
||||||
exp1 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''2nd API''''''''''''''''''''''''
|
|
||||||
exp2 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''3rd API''''''''''''''''''''''''
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([[deinput[0],CJId3,i["Id"],deinput[1]]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([[deinput[0],CJId3,i["Id"],deinput[1]]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> id -> id
|
|
||||||
'''for Id in Id3:
|
|
||||||
for Reid in ReId1:
|
|
||||||
if Reid == Id:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])'''
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
for Reid in ReId1:
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print len(result)
|
|
@ -1,22 +0,0 @@
|
|||||||
import httplib, urllib, base64
|
|
||||||
|
|
||||||
params = urllib.urlencode({
|
|
||||||
# Request parameters
|
|
||||||
'expr': "Composite(AA.AuId = 621499171)",
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'offset': '0',
|
|
||||||
'attributes': 'Ti,Id,Y,CC,RId,F.FId,AA.AfId,AA.AuId,J.JId,C.CId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
|
|
||||||
try:
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/calchistogram?%s" % params)
|
|
||||||
#conn.request("GET", "/academic/v1.0/evaluate?%s" % params, "{body}")
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
print(data)
|
|
||||||
conn.close()
|
|
||||||
except Exception as e:
|
|
||||||
print("[Errno {0}] {1}".format(e.errno, e.strerror))
|
|
File diff suppressed because one or more lines are too long
@ -1,23 +0,0 @@
|
|||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
params = urllib.urlencode({
|
|
||||||
# Request parameters
|
|
||||||
#'expr': "Composite(AA.AuN='kai chen')",
|
|
||||||
'expr': "Composite(AA.AfId = 63021997)",
|
|
||||||
#'expr': 'Id = 1970381522',
|
|
||||||
#'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
#'orderby': 'AA.AfId',
|
|
||||||
'count': '10',
|
|
||||||
'attributes': 'Id,Ti,RId,F.FId,AA.AfId,AA.AfN,AA.AuN',
|
|
||||||
#'attributes': 'Id,AA.AfId,AA.AuId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
print(data)
|
|
||||||
conn.close()
|
|
@ -1,750 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web,time
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
#'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 180:
|
|
||||||
print "4th api > 180 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId2:
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "3th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
if rid4 in Id1:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auidid5api(auid2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 135:
|
|
||||||
print "5th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % auid2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data6 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId2=[]
|
|
||||||
for i3 in data6["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == auid2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId2:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],auid2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
global start_time
|
|
||||||
start_time = time.clock()
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
#print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
print "data2"
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "data3"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "data3 > 150 s"
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
print "operation"
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1:
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "data4"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data1 > 150 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
threads=[]
|
|
||||||
for auid2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(auidid5api,auid2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data2 > 100 s"
|
|
||||||
break
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 130:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
if x in AfId2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,750 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web,time
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
#'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId2:
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "3th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
if rid4 in Id1:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auidid5api(auid2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 135:
|
|
||||||
print "5th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % auid2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data6 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId2=[]
|
|
||||||
for i3 in data6["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == auid2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId2:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],auid2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
global start_time
|
|
||||||
start_time = time.clock()
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
#print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
print "data2"
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "data3"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data3 > 120 s"
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
print "operation"
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1:
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "data4"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data1 > 120 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
threads=[]
|
|
||||||
for auid2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(auidid5api,auid2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data2 > 100 s"
|
|
||||||
break
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 130:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
if x in AfId2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
Binary file not shown.
@ -1,750 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web,time
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
#'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId2:
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "3th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
if rid4 in Id1:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auidid5api(auid2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 135:
|
|
||||||
print "5th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % auid2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data6 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId2=[]
|
|
||||||
for i3 in data6["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == auid2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
for x in AfId2:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],auid2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
global start_time
|
|
||||||
start_time = time.clock()
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
#print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
print "data2"
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "data3"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data3 > 120 s"
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
print "operation"
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1:
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "data4"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data1 > 120 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
threads=[]
|
|
||||||
for auid2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(auidid5api,auid2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data2 > 100 s"
|
|
||||||
break
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 130:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
if x in AfId2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
Binary file not shown.
@ -1,151 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
input = [2094437628, 2273736245]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
#''''''''''''''''''''''''''''''''''[Id, AA.AuId]'''''''''''''''''''''''''''''''''
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id,AA.AuId,AA.AfId,F.FId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''2nd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp2 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'RId,AA.AuId,AA.AfId,F.FId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
for tmp in AfId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp == x["AfId"]:
|
|
||||||
# Id -> AA.AuId -> AA.AfId -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["AuId"],tmp,deinput[1]])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for rid in ReId2:
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
print ("Data4")
|
|
||||||
print data4
|
|
||||||
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print ("Result")
|
|
||||||
print deresult
|
|
||||||
#print len(deresult)
|
|
@ -1,690 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#for Id in Id3:
|
|
||||||
#if rid == Id:
|
|
||||||
#result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
#for y in AfId1:
|
|
||||||
#if x == y :
|
|
||||||
#result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
if rid4 in Id1:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
#for tmp in Id1:
|
|
||||||
#if rid4 == tmp:
|
|
||||||
#result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
#for tmp in Id3:
|
|
||||||
#if rid == tmp:
|
|
||||||
#result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
#for y in Id2:
|
|
||||||
#if x==y:
|
|
||||||
#result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
#print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
print "data2"
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "data3"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
print "operation"
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "data4"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
if x in AfId2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
#for y in AfId2:
|
|
||||||
#if x==y:
|
|
||||||
#result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
#for y in Id2:
|
|
||||||
#if x==y:
|
|
||||||
#result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,750 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web,time
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
#'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId2:
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "3th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
if rid4 in Id1:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auidid5api(auid2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 135:
|
|
||||||
print "5th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % auid2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data6 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId2=[]
|
|
||||||
for i3 in data6["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == auid2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
for x in AfId2:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],auid2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
global start_time
|
|
||||||
start_time = time.clock()
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
#print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
print "data2"
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "data3"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data3 > 120 s"
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
print "operation"
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1:
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "data4"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data1 > 120 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
threads=[]
|
|
||||||
for auid2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(auidid5api,auid2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data2 > 100 s"
|
|
||||||
break
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 130:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError,IndexError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
if x in AfId2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
Binary file not shown.
@ -1,22 +0,0 @@
|
|||||||
import httplib, urllib, base64
|
|
||||||
|
|
||||||
params = urllib.urlencode({
|
|
||||||
# Request parameters
|
|
||||||
'query': 'papers by jaime teevan after 2012',
|
|
||||||
'complete': '0',
|
|
||||||
'count': '10',
|
|
||||||
'offset': '0',
|
|
||||||
'timeout': '1000',
|
|
||||||
'model': 'latest',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
|
|
||||||
try:
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/interpret?%s" % params)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
print(data)
|
|
||||||
conn.close()
|
|
||||||
except Exception as e:
|
|
||||||
print("[Errno {0}] {1}".format(e.errno, e.strerror))
|
|
@ -1,12 +0,0 @@
|
|||||||
from multiprocessing import Pool
|
|
||||||
def f(x):
|
|
||||||
print x["Id"]
|
|
||||||
print x["RId"]
|
|
||||||
def hehe():
|
|
||||||
data = {"expr" : "Id = 2153635508","entities" : [{ "logprob":-13.530, "Id":2153635508, "Ti":"libsvm a library for support vector machines", "Y":2011, "CC":7688, "RId":[2060367530, 2109943925, 1576520375, 1512098439, 2172000360, 2087347434, 2124351082, 2104978738, 1618905105, 2132870739, 2157239837, 2161920802, 1510526001, 2056983531, 1480229055, 2151040995, 1621799579, 2153104898, 1543810117, 2137346077, 2141057577, 2047542122, 2097850441, 2140586694, 2164938337, 2137285073, 2103568877, 2138907228, 2145276325, 2096613134, 1556115774, 2110899801, 1564719599, 1775273161, 2039402388, 2100967622, 34176136, 2139526185, 2011741120, 122929263, 2137518678, 2218312210], "AA":[{"AuId":2138800916,"AfId":16733864}, {"AuId":2168176072,"AfId":16733864}] }]}
|
|
||||||
pool = Pool(processes=4) # start 4 worker processes
|
|
||||||
pool.map(f, data["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
if __name__ == '__main__':
|
|
||||||
hehe()
|
|
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import web
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/users?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
data = web.input()
|
|
||||||
return data.id2
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,750 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web,time
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
#'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
#'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId2:
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "3th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
if rid4 in Id1:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "4th api > 150 s"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
if rid in Id3:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auidid5api(auid2,deinput,AfId1):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 135:
|
|
||||||
print "5th api > 150 s"
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % auid2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data6 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId2=[]
|
|
||||||
for i3 in data6["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == auid2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId2:
|
|
||||||
if x in AfId1:
|
|
||||||
result.append([deinput[0],auid2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 150:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
global start_time
|
|
||||||
start_time = time.clock()
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
#print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
print "data2"
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "data3"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data3 > 120 s"
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
print "operation"
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1:
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "data4"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 120:
|
|
||||||
print "data1 > 120 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
threads=[]
|
|
||||||
for auid2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(auidid5api,auid2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 100:
|
|
||||||
print "data2 > 100 s"
|
|
||||||
break
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
now = time.clock()
|
|
||||||
exe_time = (float)(now - start_time)
|
|
||||||
if exe_time > 130:
|
|
||||||
print "data1 > 100 s"
|
|
||||||
break
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
if x in AfId2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
if x in Id2:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,708 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
import time
|
|
||||||
from multiprocessing.dummy import Pool as ThreadPool
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
def ididfor(i):
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([xxinput[0],tmp["FId"],i["Id"],xxinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([xxinput[0],tmp["AuId"],i["Id"],xxinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def idauidfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([xxinput[0],i1["Id"],xxinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([xxinput[0],x["AuId"],i1["Id"],xxinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([xxinput[0],x["FId"],i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == xxinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result,start_time,xxinput,FId1,AuId1,CJId1,Id3
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
Id3=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(ididfor,data3["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result,start_time,ReId2,xxinput,AuId2,FId2,CJId2,Id1,AfId1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(idauidfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result,start_time
|
|
||||||
result=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result,start_time
|
|
||||||
result=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,713 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
import time
|
|
||||||
from multiprocessing.dummy import Pool as ThreadPool
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
def ididfor(i):
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([xxinput[0],tmp["FId"],i["Id"],xxinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([xxinput[0],tmp["AuId"],i["Id"],xxinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def idauidfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([xxinput[0],i1["Id"],xxinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([xxinput[0],x["AuId"],i1["Id"],xxinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([xxinput[0],x["FId"],i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == xxinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
def auididfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==xxinput[1]:
|
|
||||||
result.append([xxinput[0],xxinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([xxinput[0],i1["Id"],tmp["FId"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([xxinput[0],i1["Id"],tmp["AuId"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==xxinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],i1["Id"],CJId1,xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],i1["Id"],CJId1,xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result,start_time,xxinput,FId1,AuId1,CJId1,Id3
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
Id3=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(ididfor,data3["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result,start_time,ReId2,xxinput,AuId2,FId2,CJId2,Id1,AfId1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(idauidfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result,start_time,Id1,AfId1,xxinput,FId2,AuId2,CJId2
|
|
||||||
result=[]
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
xxinput = deinput
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auididfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result,start_time
|
|
||||||
result=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,732 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
import time
|
|
||||||
from multiprocessing.dummy import Pool as ThreadPool
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
print ">200"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4 = data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
print "Reid"
|
|
||||||
print Reid
|
|
||||||
print ReId4
|
|
||||||
print "deinput"
|
|
||||||
print deinput
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
def ididfor(i):
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([xxinput[0],tmp["FId"],i["Id"],xxinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([xxinput[0],tmp["AuId"],i["Id"],xxinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def idauidfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([xxinput[0],i1["Id"],xxinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([xxinput[0],x["AuId"],i1["Id"],xxinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([xxinput[0],x["FId"],i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == xxinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
def auididfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==xxinput[1]:
|
|
||||||
result.append([xxinput[0],xxinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([xxinput[0],i1["Id"],tmp["FId"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([xxinput[0],i1["Id"],tmp["AuId"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==xxinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],i1["Id"],CJId1,xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],i1["Id"],CJId1,xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
def auau2for(id2):
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==xxinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def auau3for(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==xxinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result,start_time,xxinput,FId1,AuId1,CJId1,Id3
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
Id3=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(ididfor,data3["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result,start_time,ReId2,xxinput,AuId2,FId2,CJId2,Id1,AfId1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(idauidfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result,start_time,Id1,AfId1,xxinput,FId2,AuId2,CJId2
|
|
||||||
result=[]
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
xxinput = deinput
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auididfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result,start_time,AfId2,xxinput,Id2,Id1,AfId1
|
|
||||||
result=[]
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
xxinput = deinput
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auau2for,data2["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auau3for,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,707 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
import time
|
|
||||||
from multiprocessing.dummy import Pool as ThreadPool
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
def ididfor(i):
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([xxinput[0],tmp["FId"],i["Id"],xxinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([xxinput[0],tmp["AuId"],i["Id"],xxinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result,start_time,xxinput,FId1,AuId1,CJId1,Id3
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
Id3=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(ididfor,data3["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result,start_time
|
|
||||||
start_time = time.clock()
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result,start_time
|
|
||||||
result=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result,start_time
|
|
||||||
result=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
Binary file not shown.
@ -1,756 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent,os,sys
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
import time
|
|
||||||
#from multiprocessing.dummy import Pool as ThreadPool
|
|
||||||
#from multiprocessing import Pool
|
|
||||||
#import multiprocessing, logging
|
|
||||||
#logger = multiprocessing.log_to_stderr()
|
|
||||||
#logger.setLevel(multiprocessing.SUBDEBUG)
|
|
||||||
#from gevent.pool import Pool
|
|
||||||
from multiprocessing import Process, Lock
|
|
||||||
lock = Lock()
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
print ">200"
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4 = data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
now_time = time.clock()
|
|
||||||
exe_time = (float)(now_time - start_time)
|
|
||||||
if exe_time > 200:
|
|
||||||
return
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '1000000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
def ididfor(lock,i):
|
|
||||||
#lock.acquire()
|
|
||||||
with lock:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
#lock.release()
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
with lock:
|
|
||||||
result.append([xxinput[0],tmp["FId"],i["Id"],xxinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
with lock:
|
|
||||||
result.append([xxinput[0],tmp["AuId"],i["Id"],xxinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
with lock:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
with lock:
|
|
||||||
result.append([xxinput[0],CJId3,i["Id"],xxinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def idauidfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([xxinput[0],i1["Id"],xxinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([xxinput[0],x["AuId"],i1["Id"],xxinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([xxinput[0],x["FId"],i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == xxinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],CJId2,i1["Id"],xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
def auididfor(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==xxinput[1]:
|
|
||||||
result.append([xxinput[0],xxinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([xxinput[0],i1["Id"],tmp["FId"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([xxinput[0],i1["Id"],tmp["AuId"],xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==xxinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],i1["Id"],CJId1,xxinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([xxinput[0],i1["Id"],CJId1,xxinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
def auau2for(id2):
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==xxinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def auau3for(i1):
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==xxinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result,start_time,xxinput,FId1,AuId1,CJId1,Id3
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
Id3=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
print "before data1"
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
print "before data2"
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
print "threads"
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
#p = Pool()
|
|
||||||
#for i in data3["entities"]:
|
|
||||||
# p.map(ididfor,i)
|
|
||||||
#p.map(ididfor,data3["entities"])
|
|
||||||
#p.close()
|
|
||||||
#p.join()
|
|
||||||
threads = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
p=Process(target=ididfor,args=(lock,i))
|
|
||||||
p.daemon = True
|
|
||||||
threads.append(p)
|
|
||||||
for i in range(len(threads)):
|
|
||||||
threads[i].start()
|
|
||||||
for j in range(len(threads)):
|
|
||||||
threads[j].join()
|
|
||||||
|
|
||||||
'''for data in data3["entities"]:
|
|
||||||
Process(target=ididfor,args=(data,)).start()
|
|
||||||
print "threads done"'''
|
|
||||||
print Id3
|
|
||||||
'''for i in data3["entities"]:
|
|
||||||
p=Process(target=ididfor,args=(i,))
|
|
||||||
p.start()'''
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
print "before gevent"
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result,start_time,ReId2,xxinput,AuId2,FId2,CJId2,Id1,AfId1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
start_time = time.clock()
|
|
||||||
xxinput=deinput
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(idauidfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result,start_time,Id1,AfId1,xxinput,FId2,AuId2,CJId2
|
|
||||||
result=[]
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
xxinput = deinput
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auididfor,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result,start_time,AfId2,xxinput,Id2,Id1,AfId1
|
|
||||||
result=[]
|
|
||||||
AfId2=[]
|
|
||||||
Id2=[]
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
xxinput = deinput
|
|
||||||
start_time = time.clock()
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auau2for,data2["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
pool = ThreadPool(4)
|
|
||||||
pool.map(auau3for,data1["entities"])
|
|
||||||
pool.close()
|
|
||||||
pool.join()
|
|
||||||
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,713 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
'''for Reid in ReId1:
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])'''
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for author2 in AuId2:
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for rid in ReId2:
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for Aid in Id1:
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for aaid1 in Id1:
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,663 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for Aid in Id1:
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for aaid1 in Id1:
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,669 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for aaid1 in Id1:
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
@ -1,675 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#import gevent.monkey
|
|
||||||
#gevent.monkey.patch_socket()
|
|
||||||
from gevent import monkey, sleep
|
|
||||||
monkey.patch_all()
|
|
||||||
import gevent
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
def api1(deinput):
|
|
||||||
global data1
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data1=json.loads(data)
|
|
||||||
|
|
||||||
def api2(deinput):
|
|
||||||
global data2
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
conn.close()
|
|
||||||
data2=json.loads(data)
|
|
||||||
|
|
||||||
def api4(deinput):
|
|
||||||
global data4
|
|
||||||
exp4 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api5(deinput):
|
|
||||||
global data5
|
|
||||||
exp5 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp5,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data5 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def api3(deinput):
|
|
||||||
global data3
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
|
|
||||||
def idid4api(Reid,deinput,FId2,AuId2,CJId2,Id3):
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
|
|
||||||
def idauid3api(author2,deinput,AfId1):
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
def idauid4api(rid,deinput,Id1):
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
|
|
||||||
def auidid4api(Aid,deinput,Id3):
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
|
|
||||||
def auau3api(aaid1,deinput,Id2):
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
threads=[]
|
|
||||||
threads.append(gevent.spawn(api1,deinput))
|
|
||||||
threads.append(gevent.spawn(api2,deinput))
|
|
||||||
threads.append(gevent.spawn(api3,deinput))
|
|
||||||
threads.append(gevent.spawn(api4,deinput))
|
|
||||||
threads.append(gevent.spawn(api5,deinput))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1,data3,data5)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data4,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput,data4,data5,data3)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput,data4,data5,data3):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
data1 = data4
|
|
||||||
data2 = data5
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
try:
|
|
||||||
if i["Id"] not in Id3:
|
|
||||||
Id3.append(i["Id"])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
threads=[]
|
|
||||||
for Reid in ReId1:
|
|
||||||
threads.append(gevent.spawn(idid4api,Reid,deinput,FId2,AuId2,CJId2,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data4,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
|
|
||||||
data1 = data2
|
|
||||||
data2 = data4
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for author2 in AuId2:
|
|
||||||
threads.append(gevent.spawn(idauid3api,author2,deinput,AfId1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for rid in ReId2:
|
|
||||||
threads.append(gevent.spawn(idauid4api,rid,deinput,Id1))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1,data3,data5):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
data2 = data5
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for Aid in Id1:
|
|
||||||
threads.append(gevent.spawn(auidid4api,Aid,deinput,Id3))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
global result
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
threads=[]
|
|
||||||
for aaid1 in Id1:
|
|
||||||
threads.append(gevent.spawn(auau3api,aaid1,deinput,Id2))
|
|
||||||
gevent.joinall(threads)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
Binary file not shown.
@ -1,727 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import web
|
|
||||||
import httplib, urllib, base64
|
|
||||||
import json
|
|
||||||
|
|
||||||
urls=(
|
|
||||||
'/bof333?(.+)','get_user'
|
|
||||||
)
|
|
||||||
app = web.application(urls,globals())
|
|
||||||
result=[]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class get_user:
|
|
||||||
def GET(self,user):
|
|
||||||
input_data = web.input()
|
|
||||||
#input = [2157025439,2139398774]
|
|
||||||
input=[int(input_data.id1),int(input_data.id2)]
|
|
||||||
encodeinput = json.dumps(input)
|
|
||||||
deinput = json.loads(encodeinput)
|
|
||||||
print deinput
|
|
||||||
exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
flag=0
|
|
||||||
try:
|
|
||||||
print data1["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag=10;#id1 is Id
|
|
||||||
try:
|
|
||||||
print data2["entities"][0]["Id"]
|
|
||||||
except(KeyError,IndexError):
|
|
||||||
flag+=1;#id2 is Id
|
|
||||||
if flag == 0:
|
|
||||||
result=auau(deinput,data1,data2)
|
|
||||||
elif flag == 1:
|
|
||||||
result=auidid(deinput,data1)
|
|
||||||
elif flag == 10:
|
|
||||||
result=idauid(deinput,data2)
|
|
||||||
elif flag == 11:
|
|
||||||
result=idid(deinput)
|
|
||||||
else:
|
|
||||||
print "FLAG : %d " % flag
|
|
||||||
deresult = json.dumps(result)
|
|
||||||
print deresult
|
|
||||||
print "Total Size: %d " % len(result)
|
|
||||||
return deresult
|
|
||||||
|
|
||||||
def idid(deinput):
|
|
||||||
#'''''''''''''''1st API''''''''''''''''''''''''
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXididXXXXXXXXXXX"
|
|
||||||
exp1 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''2nd API''''''''''''''''''''''''
|
|
||||||
exp2 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''3rd API''''''''''''''''''''''''
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#''''''''''''''''''data 1'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
ReId1=data1["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId1 = []
|
|
||||||
try:
|
|
||||||
FId1 = data1["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId1 = []
|
|
||||||
try:
|
|
||||||
AuId1= data1["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId1=[]
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= data1["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 2'''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#''''''''''''''''''data 3'''''''''id->XXXX->id->id''''''''''''''''''maybe big enough > 10w
|
|
||||||
Id3 = []
|
|
||||||
FId3 = []
|
|
||||||
AuId3 = []
|
|
||||||
CJId3 = []
|
|
||||||
for i in data3["entities"]:
|
|
||||||
# id -> F.FId -> id -> id
|
|
||||||
try:
|
|
||||||
FId_data3 = i["F"]
|
|
||||||
for tmp in FId_data3:
|
|
||||||
for x in FId1:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
result.append([deinput[0],tmp["FId"],i["Id"],deinput[1]])
|
|
||||||
#FId3.append(tmp["FId"])#
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> AA.AuId -> id -> id
|
|
||||||
try:
|
|
||||||
AuId_data3=i["AA"]
|
|
||||||
for tmp in AuId_data3:
|
|
||||||
for x in AuId1:
|
|
||||||
if x["AuId"]==tmp["AuId"]:
|
|
||||||
result.append([deinput[0],tmp["AuId"],i["Id"],deinput[1]])
|
|
||||||
#AuId3.append(tmp["AuId"])#'''''''''''''''''''''need optimization
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
# id -> C.CId/J.JId -> id -> id
|
|
||||||
try:
|
|
||||||
CJId3=i["J"]["JId"]#'''''''''''''''''''''need optimization
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
try:
|
|
||||||
CJId3=i["C"]["CId"]
|
|
||||||
if CJId3==CJId1:
|
|
||||||
result.append([deinput[0],CJId3,i["Id"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#''''''''''''''''''operation''''''''''1 and 2 hop'''''''''''''''''
|
|
||||||
#id -> id
|
|
||||||
for Reid in ReId1:
|
|
||||||
if deinput[1] == Reid:
|
|
||||||
result.append([deinput[0],Reid])
|
|
||||||
break
|
|
||||||
#id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
#print 'x: %d ' % x['FId']
|
|
||||||
for y in FId1:
|
|
||||||
#print y['FId']
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],x['FId'],deinput[1]])
|
|
||||||
#id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId1:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],x['AuId'],deinput[1]])
|
|
||||||
#id -> C.CId/J.JId -> id
|
|
||||||
if CJId1==CJId2:
|
|
||||||
result.append([deinput[0],CJId1,deinput[1]])
|
|
||||||
|
|
||||||
#''''''''''''''''''''4th API'''''''''''''''''''''''''''''
|
|
||||||
#id -> id -> XXXXXX -> id ************************************************************need gevent
|
|
||||||
for Reid in ReId1:
|
|
||||||
exp4 = 'Id = %d' % Reid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId,F.FId,AA.AuId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
try:
|
|
||||||
FId4 = data4["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId4 = []
|
|
||||||
try:
|
|
||||||
AuId4= data4["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId4=[]
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId4= data4["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId4=[]
|
|
||||||
|
|
||||||
#id -> id -> id #id -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Reid,deinput[1]])
|
|
||||||
for Id in Id3:
|
|
||||||
if rid == Id:
|
|
||||||
result.append([deinput[0],Reid,rid,deinput[1]])
|
|
||||||
#id -> id -> F.FId -> id
|
|
||||||
for x in FId2:
|
|
||||||
for y in FId4:
|
|
||||||
if y['FId']==x['FId']:
|
|
||||||
result.append([deinput[0],Reid,x['FId'],deinput[1]])
|
|
||||||
#id -> id -> AA.AuId -> id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AuId4:
|
|
||||||
if y['AuId']==x['AuId']:
|
|
||||||
result.append([deinput[0],Reid,x['AuId'],deinput[1]])
|
|
||||||
#id -> id -> C.CId/J.JId -> id
|
|
||||||
if CJId4==CJId2:
|
|
||||||
result.append([deinput[0],Reid,CJId4,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
def idauid(deinput,data2):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXidauidXXXXXXXXXXX"
|
|
||||||
'''exp1 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id,AA.AuId,AA.AfId,F.FId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()'''
|
|
||||||
data1 = data2
|
|
||||||
#'''''''''''''''''''''''''2nd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp2 = 'Id = %d' % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'RId,AA.AuId,AA.AfId,F.FId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data 2")
|
|
||||||
print data2
|
|
||||||
|
|
||||||
try:
|
|
||||||
ReId2 = data2["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId2 = []
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2 = data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2 = []
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2 = data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2 =[]
|
|
||||||
|
|
||||||
for tmp in AuId2:
|
|
||||||
if deinput[1] == tmp["AuId"]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # Id -> AA.AuId (1-hop)
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
print ("Data1")
|
|
||||||
print data1
|
|
||||||
|
|
||||||
AfId1=[]
|
|
||||||
Id1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
for tmp in ReId2:
|
|
||||||
if i1["Id"] == tmp:# Id -> Id -> AA.AuId (2-hop)
|
|
||||||
result.append([deinput[0],i1["Id"],deinput[1]])
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
for x in AuId2:
|
|
||||||
if x["AuId"] == tmp["AuId"]:
|
|
||||||
# Id -> AA.AuId -> Id -> AA.AuId (3-hop) (new add~~)
|
|
||||||
result.append([deinput[0],x["AuId"],i1["Id"],deinput[1]])
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"] == tmp["FId"]:
|
|
||||||
# Id -> F.FId -> Id -> AA.AuId (3-hop)
|
|
||||||
result.append([deinput[0],x["FId"],i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in i1["AA"]:
|
|
||||||
if tmp["AuId"] == deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1 = i1["J"]["JId"] # Id -> C.CId/J.JId -> Id -> AA.AuId (3-hop)
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],CJId2,i1["Id"],deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for author2 in AuId2:
|
|
||||||
exp3 = "Composite(AA.AuId = %d )" % author2["AuId"]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
AfId3=[]
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
try:
|
|
||||||
for tmp in i3["AA"]:
|
|
||||||
if tmp["AuId"] == author2["AuId"]:
|
|
||||||
if tmp["AfId"] not in AfId3:
|
|
||||||
AfId3.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
for x in AfId3:
|
|
||||||
for y in AfId1:
|
|
||||||
if x == y :
|
|
||||||
result.append([deinput[0],author2["AuId"],x,deinput[1]])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for rid in ReId2:
|
|
||||||
exp4 = 'Id = %d' % rid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '10000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id -> id
|
|
||||||
for rid4 in ReId4:
|
|
||||||
for tmp in Id1:
|
|
||||||
if rid4 == tmp:
|
|
||||||
result.append([deinput[0],rid,rid4,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def auidid(deinput,data1):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauididXXXXXXXXXXX"
|
|
||||||
'''exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp1,
|
|
||||||
'offset': '0',
|
|
||||||
'model': 'latest',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id,RId,F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()'''
|
|
||||||
#print data
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''2nd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp2 = 'Id = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'count': '100000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'F.FId,AA.AuId,AA.AfId,C.CId,J.JId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data2
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
exp3 = 'RId = %d' % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id',
|
|
||||||
'model': 'latest',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
try:
|
|
||||||
FId2 = data2["entities"][0]["F"]
|
|
||||||
except (KeyError):
|
|
||||||
FId2 = []
|
|
||||||
try:
|
|
||||||
AuId2= data2["entities"][0]["AA"]
|
|
||||||
except (KeyError):
|
|
||||||
AuId2=[]
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["J"]["JId"]
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId2= data2["entities"][0]["C"]["CId"]
|
|
||||||
except:
|
|
||||||
CJId2=[]
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
if i1["Id"]==deinput[1]:
|
|
||||||
result.append([deinput[0],deinput[1]]) # AA.AuId -> Id
|
|
||||||
try:
|
|
||||||
FId1 = i1["F"]
|
|
||||||
for tmp in FId1:
|
|
||||||
for x in FId2:
|
|
||||||
if x["FId"]==tmp["FId"]:
|
|
||||||
# AA.AuId -> Id -> F.FId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["FId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
for x in AuId2:
|
|
||||||
if tmp["AuId"]==x["AuId"]:
|
|
||||||
# AA.AuId -> Id -> AA.AuId -> Id
|
|
||||||
result.append([deinput[0],i1["Id"],tmp["AuId"],deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except(KeyError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
CJId1= i1["J"]["JId"] # AA.AuId -> Id -> C.CId/J.JId -> Id
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except (KeyError):
|
|
||||||
try:
|
|
||||||
CJId1= i1["C"]["CId"]
|
|
||||||
if CJId1 == CJId2:
|
|
||||||
result.append([deinput[0],i1["Id"],CJId1,deinput[1]])
|
|
||||||
except:
|
|
||||||
CJId1=[]
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId -> Id
|
|
||||||
for x in AuId2:
|
|
||||||
for y in AfId1:
|
|
||||||
try:
|
|
||||||
if y==x["AfId"]:
|
|
||||||
result.append([deinput[0],y,x["AuId"],deinput[1]])
|
|
||||||
except(KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 3''''''''''''''''''''''''''''''''
|
|
||||||
Id3 = []
|
|
||||||
for i3 in data3["entities"]:
|
|
||||||
Id3.append(i3["Id"])
|
|
||||||
|
|
||||||
#************************************************************need gevent
|
|
||||||
#''''''''''''''''''''4th API''''''''''''''''''''''''''''''''''''
|
|
||||||
for Aid in Id1:
|
|
||||||
exp4 = 'Id = %d' % Aid
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp4,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data4 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
#print data4
|
|
||||||
try:
|
|
||||||
ReId4= data4["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId4 = []
|
|
||||||
# AA.AuId -> id -> id # AA.AuId -> id -> id -> id
|
|
||||||
for rid in ReId4:
|
|
||||||
if deinput[1] == rid:
|
|
||||||
result.append([deinput[0],Aid,deinput[1]])
|
|
||||||
for tmp in Id3:
|
|
||||||
if rid == tmp:
|
|
||||||
result.append([deinput[0],Aid,rid,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
def auau(deinput,data1,data2):
|
|
||||||
#'''''''''''''''''''''''''1st API'''''''''''''''''''''''''''''''''
|
|
||||||
result=[]
|
|
||||||
print "XXXXXXXXXXauidauidXXXXXXXXXX"
|
|
||||||
'''exp1 = "Composite(AA.AuId = %d )" % deinput[0]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr': exp1,
|
|
||||||
'model': 'latest',
|
|
||||||
'offset': '0',
|
|
||||||
'count': '10000',
|
|
||||||
'attributes': 'Id,AA.AfId,AA.AuId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data1 = json.loads(data)
|
|
||||||
conn.close()'''
|
|
||||||
#'''''''''''''''''''''''''2nd API'''''''''''''''''''''''''''''''''
|
|
||||||
'''exp2 = "Composite(AA.AuId = %d )" % deinput[1]
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp2,
|
|
||||||
'count': '1000',
|
|
||||||
'model': 'latest',
|
|
||||||
'attributes': 'Id,AA.AuId,AA.AfId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data2 = json.loads(data)
|
|
||||||
conn.close()'''
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 2''''''''''''''''''''''''''''''''
|
|
||||||
AfId2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
try:
|
|
||||||
AuId2= id2["AA"]
|
|
||||||
for tmp in AuId2:
|
|
||||||
if tmp["AuId"]==deinput[1]:
|
|
||||||
if tmp["AfId"] not in AfId2:
|
|
||||||
AfId2.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
Id2=[]
|
|
||||||
for id2 in data2["entities"]:
|
|
||||||
Id2.append(id2["Id"])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''data 1''''''''''''''''''''''''''''''''
|
|
||||||
#print data1
|
|
||||||
Id1=[]
|
|
||||||
AfId1=[]
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
Id1.append(i1["Id"])
|
|
||||||
print Id1
|
|
||||||
for i1 in data1["entities"]:
|
|
||||||
try:
|
|
||||||
AuId1= i1["AA"]
|
|
||||||
for tmp in AuId1:
|
|
||||||
if tmp["AuId"]==deinput[0]:
|
|
||||||
if tmp["AfId"] not in AfId1:
|
|
||||||
AfId1.append(tmp["AfId"])
|
|
||||||
break
|
|
||||||
except (KeyError):
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
# AA.AuId -> AA.AfId -> AA.AuId
|
|
||||||
for x in AfId1:
|
|
||||||
for y in AfId2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
# AA.AuId -> Id -> AA.AuId
|
|
||||||
for x in Id1:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],x,deinput[1]])
|
|
||||||
|
|
||||||
#'''''''''''''''''''''''''3rd API'''''''''''''''''''''''''''''''''
|
|
||||||
for aaid1 in Id1:
|
|
||||||
exp3 = 'Id = %d' % aaid1
|
|
||||||
params1 = urllib.urlencode({
|
|
||||||
'expr':exp3,
|
|
||||||
'count': '100000',
|
|
||||||
'attributes': 'RId',
|
|
||||||
'subscription-key': 'f7cc29509a8443c5b3a5e56b0e38b5a6',
|
|
||||||
})
|
|
||||||
conn = httplib.HTTPSConnection('oxfordhk.azure-api.net')
|
|
||||||
conn.request("GET", "/academic/v1.0/evaluate?%s" % params1)
|
|
||||||
response = conn.getresponse()
|
|
||||||
data = response.read()
|
|
||||||
data3 = json.loads(data)
|
|
||||||
conn.close()
|
|
||||||
try:
|
|
||||||
ReId3=data3["entities"][0]["RId"]
|
|
||||||
except (KeyError):
|
|
||||||
ReId3 = []
|
|
||||||
# AA.AuId -> Id -> Id -> AA.AuId
|
|
||||||
for x in ReId3:
|
|
||||||
for y in Id2:
|
|
||||||
if x==y:
|
|
||||||
result.append([deinput[0],aaid1,x,deinput[1]])
|
|
||||||
return result
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run()
|
|
Binary file not shown.
Loading…
Reference in new issue