1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120
|
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.32
#
# Don't modify this file, modify the SWIG interface instead.
import _xapian
import new
new_instancemethod = new.instancemethod
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'PySwigObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static) or hasattr(self,name):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError,name
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
import types
try:
_object = types.ObjectType
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
del types
def _swig_setattr_nondynamic_method(set):
def set_attr(self,name,value):
if (name == "thisown"): return self.this.own(value)
if hasattr(self,name) or (name == "this"):
set(self,name,value)
else:
raise AttributeError("You cannot add attributes to %s" % self)
return set_attr
try:
import weakref
weakref_proxy = weakref.proxy
except:
weakref_proxy = lambda x: x
class PySwigIterator(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_PySwigIterator
def __iter__(self): return self
PySwigIterator.value = new_instancemethod(_xapian.PySwigIterator_value,None,PySwigIterator)
PySwigIterator.incr = new_instancemethod(_xapian.PySwigIterator_incr,None,PySwigIterator)
PySwigIterator.decr = new_instancemethod(_xapian.PySwigIterator_decr,None,PySwigIterator)
PySwigIterator.distance = new_instancemethod(_xapian.PySwigIterator_distance,None,PySwigIterator)
PySwigIterator.equal = new_instancemethod(_xapian.PySwigIterator_equal,None,PySwigIterator)
PySwigIterator.copy = new_instancemethod(_xapian.PySwigIterator_copy,None,PySwigIterator)
PySwigIterator.next = new_instancemethod(_xapian.PySwigIterator_next,None,PySwigIterator)
PySwigIterator.previous = new_instancemethod(_xapian.PySwigIterator_previous,None,PySwigIterator)
PySwigIterator.advance = new_instancemethod(_xapian.PySwigIterator_advance,None,PySwigIterator)
PySwigIterator.__eq__ = new_instancemethod(_xapian.PySwigIterator___eq__,None,PySwigIterator)
PySwigIterator.__ne__ = new_instancemethod(_xapian.PySwigIterator___ne__,None,PySwigIterator)
PySwigIterator.__iadd__ = new_instancemethod(_xapian.PySwigIterator___iadd__,None,PySwigIterator)
PySwigIterator.__isub__ = new_instancemethod(_xapian.PySwigIterator___isub__,None,PySwigIterator)
PySwigIterator.__add__ = new_instancemethod(_xapian.PySwigIterator___add__,None,PySwigIterator)
PySwigIterator.__sub__ = new_instancemethod(_xapian.PySwigIterator___sub__,None,PySwigIterator)
PySwigIterator_swigregister = _xapian.PySwigIterator_swigregister
PySwigIterator_swigregister(PySwigIterator)
MSET_DID = _xapian.MSET_DID
MSET_WT = _xapian.MSET_WT
MSET_RANK = _xapian.MSET_RANK
MSET_PERCENT = _xapian.MSET_PERCENT
MSET_DOCUMENT = _xapian.MSET_DOCUMENT
ESET_TNAME = _xapian.ESET_TNAME
ESET_WT = _xapian.ESET_WT
class Error(Exception):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Error, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Error, name)
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_Error
Error.get_type = new_instancemethod(_xapian.Error_get_type,None,Error)
Error.get_msg = new_instancemethod(_xapian.Error_get_msg,None,Error)
Error.get_context = new_instancemethod(_xapian.Error_get_context,None,Error)
Error.get_error_string = new_instancemethod(_xapian.Error_get_error_string,None,Error)
Error.get_errno = new_instancemethod(_xapian.Error_get_errno,None,Error)
Error.__str__ = new_instancemethod(_xapian.Error___str__,None,Error)
Error_swigregister = _xapian.Error_swigregister
Error_swigregister(Error)
class LogicError(Error):
__swig_setmethods__ = {}
for _s in [Error]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, LogicError, name, value)
__swig_getmethods__ = {}
for _s in [Error]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, LogicError, name)
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_LogicError
LogicError_swigregister = _xapian.LogicError_swigregister
LogicError_swigregister(LogicError)
class RuntimeError(Error):
__swig_setmethods__ = {}
for _s in [Error]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, RuntimeError, name, value)
__swig_getmethods__ = {}
for _s in [Error]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, RuntimeError, name)
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_RuntimeError
RuntimeError_swigregister = _xapian.RuntimeError_swigregister
RuntimeError_swigregister(RuntimeError)
class AssertionError(LogicError):
__swig_setmethods__ = {}
for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, AssertionError, name, value)
__swig_getmethods__ = {}
for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, AssertionError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.AssertionError_swiginit(self,_xapian.new_AssertionError(*args))
__swig_destroy__ = _xapian.delete_AssertionError
AssertionError_swigregister = _xapian.AssertionError_swigregister
AssertionError_swigregister(AssertionError)
class InvalidArgumentError(LogicError):
__swig_setmethods__ = {}
for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, InvalidArgumentError, name, value)
__swig_getmethods__ = {}
for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, InvalidArgumentError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.InvalidArgumentError_swiginit(self,_xapian.new_InvalidArgumentError(*args))
__swig_destroy__ = _xapian.delete_InvalidArgumentError
InvalidArgumentError_swigregister = _xapian.InvalidArgumentError_swigregister
InvalidArgumentError_swigregister(InvalidArgumentError)
class InvalidOperationError(LogicError):
__swig_setmethods__ = {}
for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, InvalidOperationError, name, value)
__swig_getmethods__ = {}
for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, InvalidOperationError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.InvalidOperationError_swiginit(self,_xapian.new_InvalidOperationError(*args))
__swig_destroy__ = _xapian.delete_InvalidOperationError
InvalidOperationError_swigregister = _xapian.InvalidOperationError_swigregister
InvalidOperationError_swigregister(InvalidOperationError)
class UnimplementedError(LogicError):
__swig_setmethods__ = {}
for _s in [LogicError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, UnimplementedError, name, value)
__swig_getmethods__ = {}
for _s in [LogicError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, UnimplementedError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.UnimplementedError_swiginit(self,_xapian.new_UnimplementedError(*args))
__swig_destroy__ = _xapian.delete_UnimplementedError
UnimplementedError_swigregister = _xapian.UnimplementedError_swigregister
UnimplementedError_swigregister(UnimplementedError)
class DatabaseError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseError_swiginit(self,_xapian.new_DatabaseError(*args))
__swig_destroy__ = _xapian.delete_DatabaseError
DatabaseError_swigregister = _xapian.DatabaseError_swigregister
DatabaseError_swigregister(DatabaseError)
class DatabaseCorruptError(DatabaseError):
__swig_setmethods__ = {}
for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCorruptError, name, value)
__swig_getmethods__ = {}
for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseCorruptError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseCorruptError_swiginit(self,_xapian.new_DatabaseCorruptError(*args))
__swig_destroy__ = _xapian.delete_DatabaseCorruptError
DatabaseCorruptError_swigregister = _xapian.DatabaseCorruptError_swigregister
DatabaseCorruptError_swigregister(DatabaseCorruptError)
class DatabaseCreateError(DatabaseError):
__swig_setmethods__ = {}
for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseCreateError, name, value)
__swig_getmethods__ = {}
for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseCreateError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseCreateError_swiginit(self,_xapian.new_DatabaseCreateError(*args))
__swig_destroy__ = _xapian.delete_DatabaseCreateError
DatabaseCreateError_swigregister = _xapian.DatabaseCreateError_swigregister
DatabaseCreateError_swigregister(DatabaseCreateError)
class DatabaseLockError(DatabaseError):
__swig_setmethods__ = {}
for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseLockError, name, value)
__swig_getmethods__ = {}
for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseLockError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseLockError_swiginit(self,_xapian.new_DatabaseLockError(*args))
__swig_destroy__ = _xapian.delete_DatabaseLockError
DatabaseLockError_swigregister = _xapian.DatabaseLockError_swigregister
DatabaseLockError_swigregister(DatabaseLockError)
class DatabaseModifiedError(DatabaseError):
__swig_setmethods__ = {}
for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseModifiedError, name, value)
__swig_getmethods__ = {}
for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseModifiedError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseModifiedError_swiginit(self,_xapian.new_DatabaseModifiedError(*args))
__swig_destroy__ = _xapian.delete_DatabaseModifiedError
DatabaseModifiedError_swigregister = _xapian.DatabaseModifiedError_swigregister
DatabaseModifiedError_swigregister(DatabaseModifiedError)
class DatabaseOpeningError(DatabaseError):
__swig_setmethods__ = {}
for _s in [DatabaseError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseOpeningError, name, value)
__swig_getmethods__ = {}
for _s in [DatabaseError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseOpeningError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseOpeningError_swiginit(self,_xapian.new_DatabaseOpeningError(*args))
__swig_destroy__ = _xapian.delete_DatabaseOpeningError
DatabaseOpeningError_swigregister = _xapian.DatabaseOpeningError_swigregister
DatabaseOpeningError_swigregister(DatabaseOpeningError)
class DatabaseVersionError(DatabaseOpeningError):
__swig_setmethods__ = {}
for _s in [DatabaseOpeningError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DatabaseVersionError, name, value)
__swig_getmethods__ = {}
for _s in [DatabaseOpeningError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DatabaseVersionError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DatabaseVersionError_swiginit(self,_xapian.new_DatabaseVersionError(*args))
__swig_destroy__ = _xapian.delete_DatabaseVersionError
DatabaseVersionError_swigregister = _xapian.DatabaseVersionError_swigregister
DatabaseVersionError_swigregister(DatabaseVersionError)
class DocNotFoundError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, DocNotFoundError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, DocNotFoundError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.DocNotFoundError_swiginit(self,_xapian.new_DocNotFoundError(*args))
__swig_destroy__ = _xapian.delete_DocNotFoundError
DocNotFoundError_swigregister = _xapian.DocNotFoundError_swigregister
DocNotFoundError_swigregister(DocNotFoundError)
class FeatureUnavailableError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, FeatureUnavailableError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, FeatureUnavailableError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.FeatureUnavailableError_swiginit(self,_xapian.new_FeatureUnavailableError(*args))
__swig_destroy__ = _xapian.delete_FeatureUnavailableError
FeatureUnavailableError_swigregister = _xapian.FeatureUnavailableError_swigregister
FeatureUnavailableError_swigregister(FeatureUnavailableError)
class InternalError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, InternalError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, InternalError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.InternalError_swiginit(self,_xapian.new_InternalError(*args))
__swig_destroy__ = _xapian.delete_InternalError
InternalError_swigregister = _xapian.InternalError_swigregister
InternalError_swigregister(InternalError)
class NetworkError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, NetworkError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, NetworkError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.NetworkError_swiginit(self,_xapian.new_NetworkError(*args))
__swig_destroy__ = _xapian.delete_NetworkError
NetworkError_swigregister = _xapian.NetworkError_swigregister
NetworkError_swigregister(NetworkError)
class NetworkTimeoutError(NetworkError):
__swig_setmethods__ = {}
for _s in [NetworkError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, NetworkTimeoutError, name, value)
__swig_getmethods__ = {}
for _s in [NetworkError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, NetworkTimeoutError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.NetworkTimeoutError_swiginit(self,_xapian.new_NetworkTimeoutError(*args))
__swig_destroy__ = _xapian.delete_NetworkTimeoutError
NetworkTimeoutError_swigregister = _xapian.NetworkTimeoutError_swigregister
NetworkTimeoutError_swigregister(NetworkTimeoutError)
class QueryParserError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, QueryParserError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, QueryParserError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.QueryParserError_swiginit(self,_xapian.new_QueryParserError(*args))
__swig_destroy__ = _xapian.delete_QueryParserError
QueryParserError_swigregister = _xapian.QueryParserError_swigregister
QueryParserError_swigregister(QueryParserError)
class RangeError(RuntimeError):
__swig_setmethods__ = {}
for _s in [RuntimeError]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, RangeError, name, value)
__swig_getmethods__ = {}
for _s in [RuntimeError]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, RangeError, name)
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.RangeError_swiginit(self,_xapian.new_RangeError(*args))
__swig_destroy__ = _xapian.delete_RangeError
RangeError_swigregister = _xapian.RangeError_swigregister
RangeError_swigregister(RangeError)
version_string = _xapian.version_string
major_version = _xapian.major_version
minor_version = _xapian.minor_version
revision = _xapian.revision
xapian_version_string = _xapian.xapian_version_string
xapian_major_version = _xapian.xapian_major_version
xapian_minor_version = _xapian.xapian_minor_version
xapian_revision = _xapian.xapian_revision
class PositionIterator(object):
"""
An iterator pointing to items in a list of positions.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed.
Xapian::PositionIterator::PositionIterator(const PositionIterator &o)
The internals are reference counted, so copying is also cheap.
"""
_xapian.PositionIterator_swiginit(self,_xapian.new_PositionIterator(*args))
__swig_destroy__ = _xapian.delete_PositionIterator
def skip_to(*args):
"""
void
Xapian::PositionIterator::skip_to(Xapian::termpos pos)
"""
return _xapian.PositionIterator_skip_to(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::PositionIterator::get_description() const
"""
return _xapian.PositionIterator___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::PositionIterator::get_description() const
"""
return _xapian.PositionIterator_get_description(*args)
PositionIterator.get_termpos = new_instancemethod(_xapian.PositionIterator_get_termpos,None,PositionIterator)
PositionIterator.next = new_instancemethod(_xapian.PositionIterator_next,None,PositionIterator)
PositionIterator.equals = new_instancemethod(_xapian.PositionIterator_equals,None,PositionIterator)
PositionIterator.skip_to = new_instancemethod(_xapian.PositionIterator_skip_to,None,PositionIterator)
PositionIterator.__str__ = new_instancemethod(_xapian.PositionIterator___str__,None,PositionIterator)
PositionIterator.get_description = new_instancemethod(_xapian.PositionIterator_get_description,None,PositionIterator)
PositionIterator.__eq__ = new_instancemethod(_xapian.PositionIterator___eq__,None,PositionIterator)
PositionIterator.__ne__ = new_instancemethod(_xapian.PositionIterator___ne__,None,PositionIterator)
PositionIterator_swigregister = _xapian.PositionIterator_swigregister
PositionIterator_swigregister(PositionIterator)
cvar = _xapian.cvar
BAD_VALUENO = cvar.BAD_VALUENO
class PostingIterator(object):
"""
An iterator pointing to items in a list of postings.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_PostingIterator
def __init__(self, *args):
"""
Copying is allowed.
Xapian::PostingIterator::PostingIterator(const PostingIterator &other)
The internals are reference counted, so copying is also cheap.
"""
_xapian.PostingIterator_swiginit(self,_xapian.new_PostingIterator(*args))
def skip_to(*args):
"""
Skip the iterator to document did, or the first document after did if
did isn't in the list of documents being iterated.
void Xapian::PostingIterator::skip_to(Xapian::docid did)
"""
return _xapian.PostingIterator_skip_to(*args)
def get_doclength(*args):
"""
Get the length of the document at the current position in the
postlist.
Xapian::doclength Xapian::PostingIterator::get_doclength() const
This information may be stored in the postlist, in which case this
lookup should be extremely fast (indeed, not require further disk
access). If the information is not present in the postlist, it will be
retrieved from the database, at a greater performance cost.
"""
return _xapian.PostingIterator_get_doclength(*args)
def get_wdf(*args):
"""
Get the within document frequency of the document at the current
position in the postlist.
Xapian::termcount Xapian::PostingIterator::get_wdf() const
"""
return _xapian.PostingIterator_get_wdf(*args)
def positionlist_begin(*args):
"""
Return PositionIterator pointing to start of positionlist for current
document.
PositionIterator Xapian::PostingIterator::positionlist_begin() const
"""
return _xapian.PostingIterator_positionlist_begin(*args)
def positionlist_end(*args):
"""
Return PositionIterator pointing to end of positionlist for current
document.
PositionIterator Xapian::PostingIterator::positionlist_end() const
"""
return _xapian.PostingIterator_positionlist_end(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::PostingIterator::get_description() const
"""
return _xapian.PostingIterator___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::PostingIterator::get_description() const
"""
return _xapian.PostingIterator_get_description(*args)
PostingIterator.skip_to = new_instancemethod(_xapian.PostingIterator_skip_to,None,PostingIterator)
PostingIterator.get_doclength = new_instancemethod(_xapian.PostingIterator_get_doclength,None,PostingIterator)
PostingIterator.get_wdf = new_instancemethod(_xapian.PostingIterator_get_wdf,None,PostingIterator)
PostingIterator.positionlist_begin = new_instancemethod(_xapian.PostingIterator_positionlist_begin,None,PostingIterator)
PostingIterator.positionlist_end = new_instancemethod(_xapian.PostingIterator_positionlist_end,None,PostingIterator)
PostingIterator.__str__ = new_instancemethod(_xapian.PostingIterator___str__,None,PostingIterator)
PostingIterator.get_description = new_instancemethod(_xapian.PostingIterator_get_description,None,PostingIterator)
PostingIterator.__eq__ = new_instancemethod(_xapian.PostingIterator___eq__,None,PostingIterator)
PostingIterator.__ne__ = new_instancemethod(_xapian.PostingIterator___ne__,None,PostingIterator)
PostingIterator.get_docid = new_instancemethod(_xapian.PostingIterator_get_docid,None,PostingIterator)
PostingIterator.next = new_instancemethod(_xapian.PostingIterator_next,None,PostingIterator)
PostingIterator.equals = new_instancemethod(_xapian.PostingIterator_equals,None,PostingIterator)
PostingIterator_swigregister = _xapian.PostingIterator_swigregister
PostingIterator_swigregister(PostingIterator)
__eq__ = _xapian.__eq__
__ne__ = _xapian.__ne__
class TermIterator(object):
"""
An iterator pointing to items in a list of terms.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed.
Xapian::TermIterator::TermIterator(const TermIterator &other)
The internals are reference counted, so copying is also cheap.
"""
_xapian.TermIterator_swiginit(self,_xapian.new_TermIterator(*args))
__swig_destroy__ = _xapian.delete_TermIterator
def skip_to(*args):
"""
Skip the iterator to term tname, or the first term after tname if
tname isn't in the list of terms being iterated.
void Xapian::TermIterator::skip_to(const std::string &tname)
"""
return _xapian.TermIterator_skip_to(*args)
def get_wdf(*args):
"""
Return the wdf of the current term (if meaningful).
Xapian::termcount Xapian::TermIterator::get_wdf() const
The wdf (within document frequency) is the number of occurences of a
term in a particular document.
"""
return _xapian.TermIterator_get_wdf(*args)
def get_termfreq(*args):
"""
Return the term frequency of the current term (if meaningful).
Xapian::doccount Xapian::TermIterator::get_termfreq() const
The term frequency is the number of documents which a term indexes.
"""
return _xapian.TermIterator_get_termfreq(*args)
def positionlist_begin(*args):
"""
Return PositionIterator pointing to start of positionlist for current
term.
PositionIterator Xapian::TermIterator::positionlist_begin() const
"""
return _xapian.TermIterator_positionlist_begin(*args)
def positionlist_end(*args):
"""
Return PositionIterator pointing to end of positionlist for current
term.
PositionIterator Xapian::TermIterator::positionlist_end() const
"""
return _xapian.TermIterator_positionlist_end(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::TermIterator::get_description() const
"""
return _xapian.TermIterator___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::TermIterator::get_description() const
"""
return _xapian.TermIterator_get_description(*args)
TermIterator.get_term = new_instancemethod(_xapian.TermIterator_get_term,None,TermIterator)
TermIterator.next = new_instancemethod(_xapian.TermIterator_next,None,TermIterator)
TermIterator.equals = new_instancemethod(_xapian.TermIterator_equals,None,TermIterator)
TermIterator.skip_to = new_instancemethod(_xapian.TermIterator_skip_to,None,TermIterator)
TermIterator.get_wdf = new_instancemethod(_xapian.TermIterator_get_wdf,None,TermIterator)
TermIterator.get_termfreq = new_instancemethod(_xapian.TermIterator_get_termfreq,None,TermIterator)
TermIterator.positionlist_begin = new_instancemethod(_xapian.TermIterator_positionlist_begin,None,TermIterator)
TermIterator.positionlist_end = new_instancemethod(_xapian.TermIterator_positionlist_end,None,TermIterator)
TermIterator.__str__ = new_instancemethod(_xapian.TermIterator___str__,None,TermIterator)
TermIterator.get_description = new_instancemethod(_xapian.TermIterator_get_description,None,TermIterator)
TermIterator.__eq__ = new_instancemethod(_xapian.TermIterator___eq__,None,TermIterator)
TermIterator.__ne__ = new_instancemethod(_xapian.TermIterator___ne__,None,TermIterator)
TermIterator_swigregister = _xapian.TermIterator_swigregister
TermIterator_swigregister(TermIterator)
class ValueIterator(object):
"""
An iterator pointing to values associated with a document.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed (and is cheap).
Xapian::ValueIterator::ValueIterator(const ValueIterator &other)
"""
_xapian.ValueIterator_swiginit(self,_xapian.new_ValueIterator(*args))
__swig_destroy__ = _xapian.delete_ValueIterator
def get_valueno(*args):
"""
Get the number of the value at the current position.
Xapian::valueno Xapian::ValueIterator::get_valueno() const
"""
return _xapian.ValueIterator_get_valueno(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::ValueIterator::get_description() const
"""
return _xapian.ValueIterator___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::ValueIterator::get_description() const
"""
return _xapian.ValueIterator_get_description(*args)
ValueIterator.get_value = new_instancemethod(_xapian.ValueIterator_get_value,None,ValueIterator)
ValueIterator.next = new_instancemethod(_xapian.ValueIterator_next,None,ValueIterator)
ValueIterator.equals = new_instancemethod(_xapian.ValueIterator_equals,None,ValueIterator)
ValueIterator.get_valueno = new_instancemethod(_xapian.ValueIterator_get_valueno,None,ValueIterator)
ValueIterator.__str__ = new_instancemethod(_xapian.ValueIterator___str__,None,ValueIterator)
ValueIterator.get_description = new_instancemethod(_xapian.ValueIterator_get_description,None,ValueIterator)
ValueIterator.__eq__ = new_instancemethod(_xapian.ValueIterator___eq__,None,ValueIterator)
ValueIterator.__ne__ = new_instancemethod(_xapian.ValueIterator___ne__,None,ValueIterator)
ValueIterator_swigregister = _xapian.ValueIterator_swigregister
ValueIterator_swigregister(ValueIterator)
class Document(object):
"""
A document in the database - holds data, values, terms, and postings.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Make a new empty Document.
Xapian::Document::Document()
"""
_xapian.Document_swiginit(self,_xapian.new_Document(*args))
__swig_destroy__ = _xapian.delete_Document
def get_value(*args):
"""
Get value by number.
std::string Xapian::Document::get_value(Xapian::valueno valueno) const
Returns an empty string if no value with the given number is present
in the document.
Parameters:
-----------
valueno: The number of the value.
"""
return _xapian.Document_get_value(*args)
def add_value(*args):
"""
Add a new value.
void Xapian::Document::add_value(Xapian::valueno valueno, const
std::string &value)
It will replace any existing value with the same number.
"""
return _xapian.Document_add_value(*args)
def remove_value(*args):
"""
Remove any value with the given number.
void Xapian::Document::remove_value(Xapian::valueno valueno)
"""
return _xapian.Document_remove_value(*args)
def clear_values(*args):
"""
Remove all values associated with the document.
void Xapian::Document::clear_values()
"""
return _xapian.Document_clear_values(*args)
def get_data(*args):
"""
Get data stored in the document.
std::string Xapian::Document::get_data() const
This is a potentially expensive operation, and shouldn't normally be
used in a match decider functor. Put data for use by match deciders in
a value instead.
"""
return _xapian.Document_get_data(*args)
def set_data(*args):
"""
Set data stored in the document.
void Xapian::Document::set_data(const std::string &data)
"""
return _xapian.Document_set_data(*args)
def add_posting(*args):
"""
Add an occurrence of a term at a particular position.
void Xapian::Document::add_posting(const std::string &tname,
Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Multiple occurrences of the term at the same position are represented
only once in the positional information, but do increase the wdf.
If the term is not already in the document, it will be added to it.
Parameters:
-----------
tname: The name of the term.
tpos: The position of the term.
wdfinc: The increment that will be applied to the wdf for this term.
"""
return _xapian.Document_add_posting(*args)
def add_term(*args):
"""
Add a term to the document, without positional information.
void Xapian::Document::add_term(const std::string &tname,
Xapian::termcount wdfinc=1)
Any existing positional information for the term will be left
unmodified.
Parameters:
-----------
tname: The name of the term.
wdfinc: The increment that will be applied to the wdf for this term.
"""
return _xapian.Document_add_term(*args)
def remove_posting(*args):
"""
Remove a posting of a term from the document.
void Xapian::Document::remove_posting(const std::string &tname,
Xapian::termpos tpos, Xapian::termcount wdfdec=1)
Note that the term will still index the document even if all
occurrences are removed. To remove a term from a document completely,
use remove_term().
Parameters:
-----------
tname: The name of the term.
tpos: The position of the term.
wdfdec: The decrement that will be applied to the wdf when removing
this posting. The wdf will not go below the value of 0.
Parameters:
-----------
Xapian::InvalidArgumentError: will be thrown if the term is not at
the position specified in the position list for this term in this
document.
Xapian::InvalidArgumentError: will be thrown if the term is not in
the document
"""
return _xapian.Document_remove_posting(*args)
def remove_term(*args):
"""
Remove a term and all postings associated with it.
void Xapian::Document::remove_term(const std::string &tname)
Parameters:
-----------
tname: The name of the term.
Parameters:
-----------
Xapian::InvalidArgumentError: will be thrown if the term is not in
the document
"""
return _xapian.Document_remove_term(*args)
def clear_terms(*args):
"""
Remove all terms (and postings) from the document.
void Xapian::Document::clear_terms()
"""
return _xapian.Document_clear_terms(*args)
def termlist_count(*args):
"""
The length of the termlist - i.e.
Xapian::termcount Xapian::Document::termlist_count() const
the number of different terms which index this document.
"""
return _xapian.Document_termlist_count(*args)
def termlist_begin(*args):
"""
Iterator for the terms in this document.
TermIterator Xapian::Document::termlist_begin() const
"""
return _xapian.Document_termlist_begin(*args)
def termlist_end(*args):
"""
Equivalent end iterator for termlist_begin().
TermIterator Xapian::Document::termlist_end() const
"""
return _xapian.Document_termlist_end(*args)
def values_count(*args):
"""
Count the values in this document.
Xapian::termcount Xapian::Document::values_count() const
"""
return _xapian.Document_values_count(*args)
def values_begin(*args):
"""
Iterator for the values in this document.
ValueIterator Xapian::Document::values_begin() const
"""
return _xapian.Document_values_begin(*args)
def values_end(*args):
"""
Equivalent end iterator for values_begin().
ValueIterator Xapian::Document::values_end() const
"""
return _xapian.Document_values_end(*args)
def get_docid(*args):
"""
Get the document id which is associated with this document (if any).
docid Xapian::Document::get_docid() const
NB If multiple databases are being searched together, then this will
be the document id in the individual database, not the merged
database!
If this document came from a database, return the document id in that
database. Otherwise, return 0.
"""
return _xapian.Document_get_docid(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::Document::get_description() const
"""
return _xapian.Document___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::Document::get_description() const
"""
return _xapian.Document_get_description(*args)
Document.get_value = new_instancemethod(_xapian.Document_get_value,None,Document)
Document.add_value = new_instancemethod(_xapian.Document_add_value,None,Document)
Document.remove_value = new_instancemethod(_xapian.Document_remove_value,None,Document)
Document.clear_values = new_instancemethod(_xapian.Document_clear_values,None,Document)
Document.get_data = new_instancemethod(_xapian.Document_get_data,None,Document)
Document.set_data = new_instancemethod(_xapian.Document_set_data,None,Document)
Document.add_posting = new_instancemethod(_xapian.Document_add_posting,None,Document)
Document.add_term = new_instancemethod(_xapian.Document_add_term,None,Document)
Document.remove_posting = new_instancemethod(_xapian.Document_remove_posting,None,Document)
Document.remove_term = new_instancemethod(_xapian.Document_remove_term,None,Document)
Document.clear_terms = new_instancemethod(_xapian.Document_clear_terms,None,Document)
Document.termlist_count = new_instancemethod(_xapian.Document_termlist_count,None,Document)
Document.termlist_begin = new_instancemethod(_xapian.Document_termlist_begin,None,Document)
Document.termlist_end = new_instancemethod(_xapian.Document_termlist_end,None,Document)
Document.values_count = new_instancemethod(_xapian.Document_values_count,None,Document)
Document.values_begin = new_instancemethod(_xapian.Document_values_begin,None,Document)
Document.values_end = new_instancemethod(_xapian.Document_values_end,None,Document)
Document.get_docid = new_instancemethod(_xapian.Document_get_docid,None,Document)
Document.__str__ = new_instancemethod(_xapian.Document___str__,None,Document)
Document.get_description = new_instancemethod(_xapian.Document_get_description,None,Document)
Document_swigregister = _xapian.Document_swigregister
Document_swigregister(Document)
class MSet(object):
"""
A match set ( MSet).
This class represents (a portion of) the results of a query.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed (and is cheap).
Xapian::MSet::MSet(const MSet &other)
"""
_xapian.MSet_swiginit(self,_xapian.new_MSet(*args))
__swig_destroy__ = _xapian.delete_MSet
def fetch(*args):
"""
Fetch all the items in the MSet.
void Xapian::MSet::fetch() const
"""
return _xapian.MSet_fetch(*args)
def convert_to_percent(*args):
"""
Return the percentage score for a particular item.
Xapian::percent Xapian::MSet::convert_to_percent(const MSetIterator
&it) const
"""
return _xapian.MSet_convert_to_percent(*args)
def get_termfreq(*args):
"""
Return the term frequency of the given query term.
Xapian::doccount Xapian::MSet::get_termfreq(const std::string &tname)
const
Parameters:
-----------
tname: The term to look for.
Parameters:
-----------
Xapian::InvalidArgumentError: is thrown if the term was not in the
query.
"""
return _xapian.MSet_get_termfreq(*args)
def get_termweight(*args):
"""
Return the term weight of the given query term.
Xapian::weight Xapian::MSet::get_termweight(const std::string &tname)
const
Parameters:
-----------
tname: The term to look for.
Parameters:
-----------
Xapian::InvalidArgumentError: is thrown if the term was not in the
query.
"""
return _xapian.MSet_get_termweight(*args)
def get_firstitem(*args):
"""
The index of the first item in the result which was put into the MSet.
Xapian::doccount Xapian::MSet::get_firstitem() const
This corresponds to the parameter "first" specified in
Xapian::Enquire::get_mset(). A value of 0 corresponds to the highest
result being the first item in the MSet.
"""
return _xapian.MSet_get_firstitem(*args)
def get_matches_lower_bound(*args):
"""
A lower bound on the number of documents in the database which match
the query.
Xapian::doccount Xapian::MSet::get_matches_lower_bound() const
This figure takes into account collapsing of duplicates, and weighting
cutoff values.
This number is usually considerably less than the actual number of
documents which match the query.
"""
return _xapian.MSet_get_matches_lower_bound(*args)
def get_matches_estimated(*args):
"""
An estimate for the number of documents in the database which match
the query.
Xapian::doccount Xapian::MSet::get_matches_estimated() const
This figure takes into account collapsing of duplicates, and weighting
cutoff values.
This value is returned because there is sometimes a request to display
such information. However, our experience is that presenting this
value to users causes them to worry about the large number of results,
rather than how useful those at the top of the result set are, and is
thus undesirable.
"""
return _xapian.MSet_get_matches_estimated(*args)
def get_matches_upper_bound(*args):
"""
An upper bound on the number of documents in the database which match
the query.
Xapian::doccount Xapian::MSet::get_matches_upper_bound() const
This figure takes into account collapsing of duplicates, and weighting
cutoff values.
This number is usually considerably greater than the actual number of
documents which match the query.
"""
return _xapian.MSet_get_matches_upper_bound(*args)
def get_max_possible(*args):
"""
The maximum possible weight in the MSet.
Xapian::weight Xapian::MSet::get_max_possible() const
This weight is likely not to be attained in the set of results, but
represents an upper bound on the weight which a document could attain
for the given query.
"""
return _xapian.MSet_get_max_possible(*args)
def get_max_attained(*args):
"""
The greatest weight which is attained by any document in the database.
Xapian::weight Xapian::MSet::get_max_attained() const
If firstitem == 0, this is the weight of the first entry in items.
If no documents are found by the query, this will be 0.
Note that calculation of max_attained requires calculation of at least
one result item - therefore, if no items were requested when the query
was performed (by specifying maxitems = 0 in
Xapian::Enquire::get_mset()), this value will be 0.
"""
return _xapian.MSet_get_max_attained(*args)
def size(*args):
"""
The number of items in this MSet.
Xapian::doccount Xapian::MSet::size() const
"""
return _xapian.MSet_size(*args)
def empty(*args):
"""
Test if this MSet is empty.
bool Xapian::MSet::empty() const
"""
return _xapian.MSet_empty(*args)
def begin(*args):
"""
Iterator for the terms in this MSet.
MSetIterator Xapian::MSet::begin() const
"""
return _xapian.MSet_begin(*args)
def end(*args):
"""
End iterator corresponding to begin().
MSetIterator Xapian::MSet::end() const
"""
return _xapian.MSet_end(*args)
def back(*args):
"""
Iterator pointing to the last element of this MSet.
MSetIterator Xapian::MSet::back() const
"""
return _xapian.MSet_back(*args)
def get_hit(*args):
"""
Get an item from the MSet.
The supplied index is relative to the start of the MSet, not the absolute rank
of the item.
"""
return _xapian.MSet_get_hit(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::MSet::get_description() const
"""
return _xapian.MSet___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::MSet::get_description() const
"""
return _xapian.MSet_get_description(*args)
items = _swig_property(_xapian.MSet_items_get)
MSet.fetch = new_instancemethod(_xapian.MSet_fetch,None,MSet)
MSet.convert_to_percent = new_instancemethod(_xapian.MSet_convert_to_percent,None,MSet)
MSet.get_termfreq = new_instancemethod(_xapian.MSet_get_termfreq,None,MSet)
MSet.get_termweight = new_instancemethod(_xapian.MSet_get_termweight,None,MSet)
MSet.get_firstitem = new_instancemethod(_xapian.MSet_get_firstitem,None,MSet)
MSet.get_matches_lower_bound = new_instancemethod(_xapian.MSet_get_matches_lower_bound,None,MSet)
MSet.get_matches_estimated = new_instancemethod(_xapian.MSet_get_matches_estimated,None,MSet)
MSet.get_matches_upper_bound = new_instancemethod(_xapian.MSet_get_matches_upper_bound,None,MSet)
MSet.get_max_possible = new_instancemethod(_xapian.MSet_get_max_possible,None,MSet)
MSet.get_max_attained = new_instancemethod(_xapian.MSet_get_max_attained,None,MSet)
MSet.size = new_instancemethod(_xapian.MSet_size,None,MSet)
MSet.empty = new_instancemethod(_xapian.MSet_empty,None,MSet)
MSet.begin = new_instancemethod(_xapian.MSet_begin,None,MSet)
MSet.end = new_instancemethod(_xapian.MSet_end,None,MSet)
MSet.back = new_instancemethod(_xapian.MSet_back,None,MSet)
MSet.get_hit = new_instancemethod(_xapian.MSet_get_hit,None,MSet)
MSet.get_document_percentage = new_instancemethod(_xapian.MSet_get_document_percentage,None,MSet)
MSet.get_document = new_instancemethod(_xapian.MSet_get_document,None,MSet)
MSet.get_docid = new_instancemethod(_xapian.MSet_get_docid,None,MSet)
MSet.get_document_id = new_instancemethod(_xapian.MSet_get_document_id,None,MSet)
MSet.__str__ = new_instancemethod(_xapian.MSet___str__,None,MSet)
MSet.get_description = new_instancemethod(_xapian.MSet_get_description,None,MSet)
MSet.__cmp__ = new_instancemethod(_xapian.MSet___cmp__,None,MSet)
MSet_swigregister = _xapian.MSet_swigregister
MSet_swigregister(MSet)
class MSetIterator(object):
"""
An iterator pointing to items in an MSet.
This is used for access to individual results of a match.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed (and is cheap).
Xapian::MSetIterator::MSetIterator(const MSetIterator &other)
"""
_xapian.MSetIterator_swiginit(self,_xapian.new_MSetIterator(*args))
__swig_destroy__ = _xapian.delete_MSetIterator
def get_document(*args):
"""
Get a Xapian::Document object for the current position.
Xapian::Document Xapian::MSetIterator::get_document() const
This method returns a Xapian::Document object which provides the
information about the document pointed to by the MSetIterator.
If the underlying database has suitable support, using this call
(rather than asking the database for a document based on its document
ID) will enable the system to ensure that the correct data is
returned, and that the document has not been deleted or changed since
the query was performed.
A Xapian::Document object containing the document data.
Parameters:
-----------
Xapian::DocNotFoundError: The document specified could not be found
in the database.
"""
return _xapian.MSetIterator_get_document(*args)
def get_rank(*args):
"""
Get the rank of the document at the current position.
Xapian::doccount Xapian::MSetIterator::get_rank() const
The rank is the position that this document is at in the ordered list
of results of the query. The result is 0-based - i.e. the top-ranked
document has a rank of 0.
"""
return _xapian.MSetIterator_get_rank(*args)
def get_weight(*args):
"""
Get the weight of the document at the current position.
Xapian::weight Xapian::MSetIterator::get_weight() const
"""
return _xapian.MSetIterator_get_weight(*args)
def get_collapse_key(*args):
"""
Get the collapse key for this document.
std::string Xapian::MSetIterator::get_collapse_key() const
"""
return _xapian.MSetIterator_get_collapse_key(*args)
def get_collapse_count(*args):
"""
Get an estimate of the number of documents that have been collapsed
into this one.
Xapian::doccount Xapian::MSetIterator::get_collapse_count() const
The estimate will always be less than or equal to the actual number of
other documents satisfying the match criteria with the same collapse
key as this document.
This method may return 0 even though there are other documents with
the same collapse key which satisfying the match criteria. However if
this method returns non-zero, there definitely are other such
documents. So this method may be used to inform the user that there
are "at least N other matches in this group", or to control whether
to offer a "show other documents in this group" feature (but note
that it may not offer it in every case where it would show other
documents).
"""
return _xapian.MSetIterator_get_collapse_count(*args)
def get_percent(*args):
"""
This returns the weight of the document as a percentage score.
Xapian::percent Xapian::MSetIterator::get_percent() const
The return value will be in the range 0 to 100: 0 meaning that the
item did not match the query at all.
"""
return _xapian.MSetIterator_get_percent(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::MSetIterator::get_description() const
"""
return _xapian.MSetIterator___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::MSetIterator::get_description() const
"""
return _xapian.MSetIterator_get_description(*args)
MSetIterator.get_docid = new_instancemethod(_xapian.MSetIterator_get_docid,None,MSetIterator)
MSetIterator.next = new_instancemethod(_xapian.MSetIterator_next,None,MSetIterator)
MSetIterator.prev = new_instancemethod(_xapian.MSetIterator_prev,None,MSetIterator)
MSetIterator.equals = new_instancemethod(_xapian.MSetIterator_equals,None,MSetIterator)
MSetIterator.get_document = new_instancemethod(_xapian.MSetIterator_get_document,None,MSetIterator)
MSetIterator.get_rank = new_instancemethod(_xapian.MSetIterator_get_rank,None,MSetIterator)
MSetIterator.get_weight = new_instancemethod(_xapian.MSetIterator_get_weight,None,MSetIterator)
MSetIterator.get_collapse_key = new_instancemethod(_xapian.MSetIterator_get_collapse_key,None,MSetIterator)
MSetIterator.get_collapse_count = new_instancemethod(_xapian.MSetIterator_get_collapse_count,None,MSetIterator)
MSetIterator.get_percent = new_instancemethod(_xapian.MSetIterator_get_percent,None,MSetIterator)
MSetIterator.__str__ = new_instancemethod(_xapian.MSetIterator___str__,None,MSetIterator)
MSetIterator.get_description = new_instancemethod(_xapian.MSetIterator_get_description,None,MSetIterator)
MSetIterator.__eq__ = new_instancemethod(_xapian.MSetIterator___eq__,None,MSetIterator)
MSetIterator.__ne__ = new_instancemethod(_xapian.MSetIterator___ne__,None,MSetIterator)
MSetIterator_swigregister = _xapian.MSetIterator_swigregister
MSetIterator_swigregister(MSetIterator)
class ESet(object):
"""
Class representing an ordered set of expand terms (an ESet).
This set represents the results of an expand operation, which is
performed by Xapian::Enquire::get_eset().
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed (and is cheap).
Xapian::ESet::ESet(const ESet &other)
"""
_xapian.ESet_swiginit(self,_xapian.new_ESet(*args))
__swig_destroy__ = _xapian.delete_ESet
def get_ebound(*args):
"""
A lower bound on the number of terms which are in the full set of
results of the expand.
Xapian::termcount Xapian::ESet::get_ebound() const
This will be greater than or equal to size()
"""
return _xapian.ESet_get_ebound(*args)
def size(*args):
"""
The number of terms in this E-Set.
Xapian::termcount Xapian::ESet::size() const
"""
return _xapian.ESet_size(*args)
def empty(*args):
"""
Test if this E-Set is empty.
bool Xapian::ESet::empty() const
"""
return _xapian.ESet_empty(*args)
def begin(*args):
"""
Iterator for the terms in this E-Set.
ESetIterator Xapian::ESet::begin() const
"""
return _xapian.ESet_begin(*args)
def end(*args):
"""
End iterator corresponding to begin().
ESetIterator Xapian::ESet::end() const
"""
return _xapian.ESet_end(*args)
def back(*args):
"""
Iterator pointing to the last element of this E-Set.
ESetIterator Xapian::ESet::back() const
"""
return _xapian.ESet_back(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::ESet::get_description() const
"""
return _xapian.ESet___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::ESet::get_description() const
"""
return _xapian.ESet_get_description(*args)
items = _swig_property(_xapian.ESet_items_get)
ESet.get_ebound = new_instancemethod(_xapian.ESet_get_ebound,None,ESet)
ESet.size = new_instancemethod(_xapian.ESet_size,None,ESet)
ESet.empty = new_instancemethod(_xapian.ESet_empty,None,ESet)
ESet.begin = new_instancemethod(_xapian.ESet_begin,None,ESet)
ESet.end = new_instancemethod(_xapian.ESet_end,None,ESet)
ESet.back = new_instancemethod(_xapian.ESet_back,None,ESet)
ESet.__str__ = new_instancemethod(_xapian.ESet___str__,None,ESet)
ESet.get_description = new_instancemethod(_xapian.ESet_get_description,None,ESet)
ESet_swigregister = _xapian.ESet_swigregister
ESet_swigregister(ESet)
class ESetIterator(object):
"""
Iterate through terms in the ESet.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Copying is allowed (and is cheap).
Xapian::ESetIterator::ESetIterator(const ESetIterator &other)
"""
_xapian.ESetIterator_swiginit(self,_xapian.new_ESetIterator(*args))
__swig_destroy__ = _xapian.delete_ESetIterator
def get_weight(*args):
"""
Get the weight of the term at the current position.
Xapian::weight Xapian::ESetIterator::get_weight() const
"""
return _xapian.ESetIterator_get_weight(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::ESetIterator::get_description() const
"""
return _xapian.ESetIterator___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::ESetIterator::get_description() const
"""
return _xapian.ESetIterator_get_description(*args)
ESetIterator.get_termname = new_instancemethod(_xapian.ESetIterator_get_termname,None,ESetIterator)
ESetIterator.get_term = new_instancemethod(_xapian.ESetIterator_get_term,None,ESetIterator)
ESetIterator.next = new_instancemethod(_xapian.ESetIterator_next,None,ESetIterator)
ESetIterator.prev = new_instancemethod(_xapian.ESetIterator_prev,None,ESetIterator)
ESetIterator.equals = new_instancemethod(_xapian.ESetIterator_equals,None,ESetIterator)
ESetIterator.get_weight = new_instancemethod(_xapian.ESetIterator_get_weight,None,ESetIterator)
ESetIterator.__str__ = new_instancemethod(_xapian.ESetIterator___str__,None,ESetIterator)
ESetIterator.get_description = new_instancemethod(_xapian.ESetIterator_get_description,None,ESetIterator)
ESetIterator.__eq__ = new_instancemethod(_xapian.ESetIterator___eq__,None,ESetIterator)
ESetIterator.__ne__ = new_instancemethod(_xapian.ESetIterator___ne__,None,ESetIterator)
ESetIterator_swigregister = _xapian.ESetIterator_swigregister
ESetIterator_swigregister(ESetIterator)
class RSet(object):
"""
A relevance set (R-Set).
This is the set of documents which are marked as relevant, for use in
modifying the term weights, and in performing query expansion.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Default constructor.
Xapian::RSet::RSet()
"""
_xapian.RSet_swiginit(self,_xapian.new_RSet(*args))
__swig_destroy__ = _xapian.delete_RSet
def size(*args):
"""
The number of documents in this R-Set.
Xapian::doccount Xapian::RSet::size() const
"""
return _xapian.RSet_size(*args)
def empty(*args):
"""
Test if this R-Set is empty.
bool Xapian::RSet::empty() const
"""
return _xapian.RSet_empty(*args)
def add_document(*args):
"""
Add a document to the relevance set.
void Xapian::RSet::add_document(const Xapian::MSetIterator &i)
"""
return _xapian.RSet_add_document(*args)
def remove_document(*args):
"""
Remove a document from the relevance set.
void Xapian::RSet::remove_document(const Xapian::MSetIterator &i)
"""
return _xapian.RSet_remove_document(*args)
def contains(*args):
"""
Test if a given document in the relevance set.
bool Xapian::RSet::contains(const Xapian::MSetIterator &i) const
"""
return _xapian.RSet_contains(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::RSet::get_description() const
"""
return _xapian.RSet___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::RSet::get_description() const
"""
return _xapian.RSet_get_description(*args)
RSet.size = new_instancemethod(_xapian.RSet_size,None,RSet)
RSet.empty = new_instancemethod(_xapian.RSet_empty,None,RSet)
RSet.add_document = new_instancemethod(_xapian.RSet_add_document,None,RSet)
RSet.remove_document = new_instancemethod(_xapian.RSet_remove_document,None,RSet)
RSet.contains = new_instancemethod(_xapian.RSet_contains,None,RSet)
RSet.__str__ = new_instancemethod(_xapian.RSet___str__,None,RSet)
RSet.get_description = new_instancemethod(_xapian.RSet_get_description,None,RSet)
RSet_swigregister = _xapian.RSet_swigregister
RSet_swigregister(RSet)
class MatchDecider(object):
"""
Base class for matcher decision functor.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_MatchDecider
def __init__(self, *args):
if self.__class__ == MatchDecider:
args = (None,) + args
else:
args = (self,) + args
_xapian.MatchDecider_swiginit(self,_xapian.new_MatchDecider(*args))
def __disown__(self):
self.this.disown()
_xapian.disown_MatchDecider(self)
return weakref_proxy(self)
MatchDecider.__call__ = new_instancemethod(_xapian.MatchDecider___call__,None,MatchDecider)
MatchDecider_swigregister = _xapian.MatchDecider_swigregister
MatchDecider_swigregister(MatchDecider)
class ExpandDecider(object):
"""
Virtual base class for expand decider functor.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_ExpandDecider
def __init__(self, *args):
if self.__class__ == ExpandDecider:
args = (None,) + args
else:
args = (self,) + args
_xapian.ExpandDecider_swiginit(self,_xapian.new_ExpandDecider(*args))
def __disown__(self):
self.this.disown()
_xapian.disown_ExpandDecider(self)
return weakref_proxy(self)
ExpandDecider.__call__ = new_instancemethod(_xapian.ExpandDecider___call__,None,ExpandDecider)
ExpandDecider_swigregister = _xapian.ExpandDecider_swigregister
ExpandDecider_swigregister(ExpandDecider)
class Enquire(object):
"""
This class provides an interface to the information retrieval system
for the purpose of searching.
Databases are usually opened lazily, so exceptions may not be thrown
where you would expect them to be. You should catch Xapian::Error
exceptions when calling any method in Xapian::Enquire.
Parameters:
-----------
Xapian::InvalidArgumentError: will be thrown if an invalid argument
is supplied, for example, an unknown database type.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Create a Xapian::Enquire object.
Xapian::Enquire::Enquire(const Database &database, ErrorHandler
*errorhandler_=0)
This specification cannot be changed once the Xapian::Enquire is
opened: you must create a new Xapian::Enquire object to access a
different database, or set of databases.
The database supplied must have been initialised (ie, must not be the
result of calling the Database::Database() constructor). If you need
to handle a situation where you have no index gracefully, a database
created with InMemory::open() can be passed here, which represents a
completely empty database.
Parameters:
-----------
database: Specification of the database or databases to use.
errorhandler_: A pointer to the error handler to use. Ownership of
the object pointed to is not assumed by the Xapian::Enquire object -
the user should delete the Xapian::ErrorHandler object after the
Xapian::Enquire object is deleted. To use no error handler, this
parameter should be 0.
Parameters:
-----------
Xapian::InvalidArgumentError: will be thrown if an initialised
Database object is supplied.
"""
_xapian.Enquire_swiginit(self,_xapian.new_Enquire(*args))
__swig_destroy__ = _xapian.delete_Enquire
def set_query(*args):
"""
Set the query to run.
void Xapian::Enquire::set_query(const Xapian::Query &query,
Xapian::termcount qlen=0)
Parameters:
-----------
query: the new query to run.
qlen: the query length to use in weight calculations - by default the
sum of the wqf of all terms is used.
"""
return _xapian.Enquire_set_query(*args)
def get_query(*args):
"""
Get the query which has been set.
const Xapian::Query& Xapian::Enquire::get_query() const
This is only valid after set_query() has been called.
Parameters:
-----------
Xapian::InvalidArgumentError: will be thrown if query has not yet
been set.
"""
return _xapian.Enquire_get_query(*args)
def set_weighting_scheme(*args):
"""
Set the weighting scheme to use for queries.
void Xapian::Enquire::set_weighting_scheme(const Weight &weight_)
Parameters:
-----------
weight_: the new weighting scheme. If no weighting scheme is
specified, the default is BM25 with the default parameters.
"""
return _xapian.Enquire_set_weighting_scheme(*args)
def set_collapse_key(*args):
"""
Set the collapse key to use for queries.
void Xapian::Enquire::set_collapse_key(Xapian::valueno collapse_key)
Parameters:
-----------
collapse_key: value number to collapse on - at most one MSet entry
with each particular value will be returned.
The entry returned will be the best entry with that particular value
(highest weight or highest sorting key).
An example use might be to create a value for each document containing
an MD5 hash of the document contents. Then duplicate documents from
different sources can be eliminated at search time (it's better to
eliminate duplicates at index time, but this may not be always be
possible - for example the search may be over more than one Xapian
database).
Another use is to group matches in a particular category (e.g. you
might collapse a mailing list search on the Subject: so that there's
only one result per discussion thread). In this case you can use
get_collapse_count() to give the user some idea how many other results
there are. And if you index the Subject: as a boolean term as well as
putting it in a value, you can offer a link to a non-collapsed search
restricted to that thread using a boolean filter.
(default is Xapian::BAD_VALUENO which means no collapsing).
"""
return _xapian.Enquire_set_collapse_key(*args)
ASCENDING = _xapian.Enquire_ASCENDING
DESCENDING = _xapian.Enquire_DESCENDING
DONT_CARE = _xapian.Enquire_DONT_CARE
def set_docid_order(*args):
"""
Set the direction in which documents are ordered by document id in the
returned MSet.
void Xapian::Enquire::set_docid_order(docid_order order)
This order only has an effect on documents which would otherwise have
equal rank. For a weighted probabilistic match with no sort value,
this means documents with equal weight. For a boolean match, with no
sort value, this means all documents. And if a sort value is used,
this means documents with equal sort value (and also equal weight if
ordering on relevance after the sort).
Parameters:
-----------
order: This can be: Xapian::Enquire::ASCENDING docids sort in
ascending order (default)
Xapian::Enquire::DESCENDING docids sort in descending order
Xapian::Enquire::DONT_CARE docids sort in whatever order is most
efficient for the backend
Note: If you add documents in strict date order, then a boolean search
- i.e. set_weighting_scheme(Xapian::BoolWeight()) - with
set_docid_order(Xapian::Enquire::DESCENDING) is a very efficient way
to perform "sort by date, newest first".
"""
return _xapian.Enquire_set_docid_order(*args)
def set_cutoff(*args):
"""
Set the percentage and/or weight cutoffs.
void Xapian::Enquire::set_cutoff(Xapian::percent percent_cutoff,
Xapian::weight weight_cutoff=0)
Parameters:
-----------
percent_cutoff: Minimum percentage score for returned documents. If a
document has a lower percentage score than this, it will not appear in
the MSet. If your intention is to return only matches which contain
all the terms in the query, then it's more efficient to use
Xapian::Query::OP_AND instead of Xapian::Query::OP_OR in the query
than to use set_cutoff(100). (default 0 => no percentage cut-off).
weight_cutoff: Minimum weight for a document to be returned. If a
document has a lower score that this, it will not appear in the MSet.
It is usually only possible to choose an appropriate weight for cutoff
based on the results of a previous run of the same query; this is thus
mainly useful for alerting operations. The other potential use is with
a user specified weighting scheme. (default 0 => no weight cut-off).
"""
return _xapian.Enquire_set_cutoff(*args)
def set_sort_by_relevance(*args):
"""
Set the sorting to be by relevance only.
void Xapian::Enquire::set_sort_by_relevance()
This is the default.
"""
return _xapian.Enquire_set_sort_by_relevance(*args)
def set_sort_by_value(*args):
"""
Set the sorting to be by value only.
void Xapian::Enquire::set_sort_by_value(Xapian::valueno sort_key, bool
ascending=true)
NB sorting of values uses a string comparison, so you'll need to store
numbers padded with leading zeros or spaces, or with the number of
digits prepended.
Parameters:
-----------
sort_key: value number to sort on.
ascending: If true, documents values which sort higher by string
compare are better. If false, the sort order is reversed. (default
true)
"""
return _xapian.Enquire_set_sort_by_value(*args)
def set_sort_by_value_then_relevance(*args):
"""
Set the sorting to be by value, then by relevance for documents with
the same value.
void Xapian::Enquire::set_sort_by_value_then_relevance(Xapian::valueno
sort_key, bool ascending=true)
NB sorting of values uses a string comparison, so you'll need to store
numbers padded with leading zeros or spaces, or with the number of
digits prepended.
Parameters:
-----------
sort_key: value number to sort on.
ascending: If true, documents values which sort higher by string
compare are better. If false, the sort order is reversed. (default
true)
"""
return _xapian.Enquire_set_sort_by_value_then_relevance(*args)
def set_sort_by_relevance_then_value(*args):
"""
Set the sorting to be by relevance then value.
void Xapian::Enquire::set_sort_by_relevance_then_value(Xapian::valueno
sort_key, bool ascending=true)
NB sorting of values uses a string comparison, so you'll need to store
numbers padded with leading zeros or spaces, or with the number of
digits prepended.
Note that with the default BM25 weighting scheme parameters, non-
identical documents will rarely have the same weight, so this setting
will give very similar results to set_sort_by_relevance(). It becomes
more useful with particular BM25 parameter settings (e.g.
BM25Weight(1,0,1,0,0)) or custom weighting schemes.
Parameters:
-----------
sort_key: value number to sort on.
ascending: If true, documents values which sort higher by string
compare are better. If false, the sort order is reversed. (default
true)
"""
return _xapian.Enquire_set_sort_by_relevance_then_value(*args)
def set_sort_by_key(*args):
"""
Set the sorting to be by key generated from values only.
void Xapian::Enquire::set_sort_by_key(Xapian::Sorter *sorter, bool
ascending=true)
Parameters:
-----------
sorter: The functor to use for generating keys.
ascending: If true, documents values which sort higher by string
compare are better. If false, the sort order is reversed. (default
true)
"""
return _xapian.Enquire_set_sort_by_key(*args)
def set_sort_by_key_then_relevance(*args):
"""
Set the sorting to be by keys generated from values, then by relevance
for documents with identical keys.
void Xapian::Enquire::set_sort_by_key_then_relevance(Xapian::Sorter
*sorter, bool ascending=true)
Parameters:
-----------
sorter: The functor to use for generating keys.
ascending: If true, keys which sort higher by string compare are
better. If false, the sort order is reversed. (default true)
"""
return _xapian.Enquire_set_sort_by_key_then_relevance(*args)
def set_sort_by_relevance_then_key(*args):
"""
Set the sorting to be by relevance, then by keys generated from
values.
void Xapian::Enquire::set_sort_by_relevance_then_key(Xapian::Sorter
*sorter, bool ascending=true)
Note that with the default BM25 weighting scheme parameters, non-
identical documents will rarely have the same weight, so this setting
will give very similar results to set_sort_by_relevance(). It becomes
more useful with particular BM25 parameter settings (e.g.
BM25Weight(1,0,1,0,0)) or custom weighting schemes.
Parameters:
-----------
sorter: The functor to use for generating keys.
ascending: If true, keys which sort higher by string compare are
better. If false, the sort order is reversed. (default true)
"""
return _xapian.Enquire_set_sort_by_relevance_then_key(*args)
INCLUDE_QUERY_TERMS = _xapian.Enquire_INCLUDE_QUERY_TERMS
USE_EXACT_TERMFREQ = _xapian.Enquire_USE_EXACT_TERMFREQ
def get_mset(*args):
"""
MSet
Xapian::Enquire::get_mset(Xapian::doccount first, Xapian::doccount
maxitems, const RSet *omrset, const MatchDecider *mdecider=0) const
"""
return _xapian.Enquire_get_mset(*args)
def get_eset(*args):
"""
Get the expand set for the given rset.
ESet Xapian::Enquire::get_eset(Xapian::termcount maxitems, const RSet
&omrset, const Xapian::ExpandDecider *edecider) const
Parameters:
-----------
maxitems: the maximum number of items to return.
omrset: the relevance set to use when performing the expand
operation.
edecider: a decision functor to use to decide whether a given term
should be put in the ESet
An ESet object containing the results of the expand.
Parameters:
-----------
Xapian::InvalidArgumentError: See class documentation.
"""
return _xapian.Enquire_get_eset(*args)
def get_matching_terms_begin(*args):
"""
Get terms which match a given document, by match set item.
TermIterator Xapian::Enquire::get_matching_terms_begin(const
MSetIterator &it) const
This method returns the terms in the current query which match the
given document.
If the underlying database has suitable support, using this call
(rather than passing a Xapian::docid) will enable the system to ensure
that the correct data is returned, and that the document has not been
deleted or changed since the query was performed.
Parameters:
-----------
it: The iterator for which to retrieve the matching terms.
An iterator returning the terms which match the document. The terms
will be returned (as far as this makes any sense) in the same order as
the terms in the query. Terms will not occur more than once, even if
they do in the query.
Parameters:
-----------
Xapian::InvalidArgumentError: See class documentation.
Xapian::DocNotFoundError: The document specified could not be found
in the database.
"""
return _xapian.Enquire_get_matching_terms_begin(*args)
def get_matching_terms_end(*args):
"""
End iterator corresponding to get_matching_terms_begin().
TermIterator Xapian::Enquire::get_matching_terms_end(const
MSetIterator &) const
"""
return _xapian.Enquire_get_matching_terms_end(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::Enquire::get_description() const
"""
return _xapian.Enquire___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::Enquire::get_description() const
"""
return _xapian.Enquire_get_description(*args)
Enquire.set_query = new_instancemethod(_xapian.Enquire_set_query,None,Enquire)
Enquire.get_query = new_instancemethod(_xapian.Enquire_get_query,None,Enquire)
Enquire.set_weighting_scheme = new_instancemethod(_xapian.Enquire_set_weighting_scheme,None,Enquire)
Enquire.set_collapse_key = new_instancemethod(_xapian.Enquire_set_collapse_key,None,Enquire)
Enquire.set_docid_order = new_instancemethod(_xapian.Enquire_set_docid_order,None,Enquire)
Enquire.set_cutoff = new_instancemethod(_xapian.Enquire_set_cutoff,None,Enquire)
Enquire.set_sort_by_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_relevance,None,Enquire)
Enquire.set_sort_by_value = new_instancemethod(_xapian.Enquire_set_sort_by_value,None,Enquire)
Enquire.set_sort_by_value_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_value_then_relevance,None,Enquire)
Enquire.set_sort_by_relevance_then_value = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_value,None,Enquire)
Enquire.set_sort_by_key = new_instancemethod(_xapian.Enquire_set_sort_by_key,None,Enquire)
Enquire.set_sort_by_key_then_relevance = new_instancemethod(_xapian.Enquire_set_sort_by_key_then_relevance,None,Enquire)
Enquire.set_sort_by_relevance_then_key = new_instancemethod(_xapian.Enquire_set_sort_by_relevance_then_key,None,Enquire)
Enquire.get_mset = new_instancemethod(_xapian.Enquire_get_mset,None,Enquire)
Enquire.get_eset = new_instancemethod(_xapian.Enquire_get_eset,None,Enquire)
Enquire.get_matching_terms_begin = new_instancemethod(_xapian.Enquire_get_matching_terms_begin,None,Enquire)
Enquire.get_matching_terms_end = new_instancemethod(_xapian.Enquire_get_matching_terms_end,None,Enquire)
Enquire.register_match_decider = new_instancemethod(_xapian.Enquire_register_match_decider,None,Enquire)
Enquire.get_matching_terms = new_instancemethod(_xapian.Enquire_get_matching_terms,None,Enquire)
Enquire.__str__ = new_instancemethod(_xapian.Enquire___str__,None,Enquire)
Enquire.get_description = new_instancemethod(_xapian.Enquire_get_description,None,Enquire)
Enquire_swigregister = _xapian.Enquire_swigregister
Enquire_swigregister(Enquire)
class Weight(object):
"""
Abstract base class for weighting schemes.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_Weight
def name(*args):
"""
Name of the weighting scheme.
virtual std::string Xapian::Weight::name() const=0
If the subclass is called FooWeight, this should return "Foo".
"""
return _xapian.Weight_name(*args)
def serialise(*args):
"""
Serialise object parameters into a string.
virtual std::string Xapian::Weight::serialise() const=0
"""
return _xapian.Weight_serialise(*args)
def unserialise(*args):
"""
Create object given string serialisation returned by serialise().
virtual Weight* Xapian::Weight::unserialise(const std::string &s)
const=0
"""
return _xapian.Weight_unserialise(*args)
def get_sumpart(*args):
"""
Get a weight which is part of the sum over terms being performed.
virtual Xapian::weight Xapian::Weight::get_sumpart(Xapian::termcount
wdf, Xapian::doclength len) const=0
This returns a weight for a given term and document. These weights are
summed to give a total weight for the document.
Parameters:
-----------
wdf: the within document frequency of the term.
len: the (unnormalised) document length.
"""
return _xapian.Weight_get_sumpart(*args)
def get_maxpart(*args):
"""
Gets the maximum value that get_sumpart() may return.
virtual Xapian::weight Xapian::Weight::get_maxpart() const=0
This is used in optimising searches, by having the postlist tree decay
appropriately when parts of it can have limited, or no, further
effect.
"""
return _xapian.Weight_get_maxpart(*args)
def get_sumextra(*args):
"""
Get an extra weight for a document to add to the sum calculated over
the query terms.
virtual Xapian::weight Xapian::Weight::get_sumextra(Xapian::doclength
len) const=0
This returns a weight for a given document, and is used by some
weighting schemes to account for influence such as document length.
Parameters:
-----------
len: the (unnormalised) document length.
"""
return _xapian.Weight_get_sumextra(*args)
def get_maxextra(*args):
"""
Gets the maximum value that get_sumextra() may return.
virtual Xapian::weight Xapian::Weight::get_maxextra() const=0
This is used in optimising searches.
"""
return _xapian.Weight_get_maxextra(*args)
def get_sumpart_needs_doclength(*args):
"""
return false if the weight object doesn't need doclength
virtual bool Xapian::Weight::get_sumpart_needs_doclength() const
"""
return _xapian.Weight_get_sumpart_needs_doclength(*args)
Weight.name = new_instancemethod(_xapian.Weight_name,None,Weight)
Weight.serialise = new_instancemethod(_xapian.Weight_serialise,None,Weight)
Weight.unserialise = new_instancemethod(_xapian.Weight_unserialise,None,Weight)
Weight.get_sumpart = new_instancemethod(_xapian.Weight_get_sumpart,None,Weight)
Weight.get_maxpart = new_instancemethod(_xapian.Weight_get_maxpart,None,Weight)
Weight.get_sumextra = new_instancemethod(_xapian.Weight_get_sumextra,None,Weight)
Weight.get_maxextra = new_instancemethod(_xapian.Weight_get_maxextra,None,Weight)
Weight.get_sumpart_needs_doclength = new_instancemethod(_xapian.Weight_get_sumpart_needs_doclength,None,Weight)
Weight_swigregister = _xapian.Weight_swigregister
Weight_swigregister(Weight)
class BoolWeight(Weight):
"""
Boolean weighting scheme (everything gets 0).
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def clone(*args):
"""
Return a new weight object of this type.
BoolWeight* Xapian::BoolWeight::clone() const
A subclass called FooWeight taking parameters param1 and param2 should
implement this as:
virtual FooWeight * clone() const { return new FooWeight(param1,
param2); }
"""
return _xapian.BoolWeight_clone(*args)
def __init__(self, *args):
"""Xapian::BoolWeight::BoolWeight() """
_xapian.BoolWeight_swiginit(self,_xapian.new_BoolWeight(*args))
__swig_destroy__ = _xapian.delete_BoolWeight
def unserialise(*args):
"""
Create object given string serialisation returned by serialise().
BoolWeight* Xapian::BoolWeight::unserialise(const std::string &s)
const
"""
return _xapian.BoolWeight_unserialise(*args)
BoolWeight.clone = new_instancemethod(_xapian.BoolWeight_clone,None,BoolWeight)
BoolWeight.unserialise = new_instancemethod(_xapian.BoolWeight_unserialise,None,BoolWeight)
BoolWeight_swigregister = _xapian.BoolWeight_swigregister
BoolWeight_swigregister(BoolWeight)
class BM25Weight(Weight):
"""
BM25 weighting scheme.
BM25 weighting options : The BM25 formula is \\[
\\frac{k_{2}.n_{q}}{1+L_{d}}+\\sum_{t}\\frac{(k_{3}+1)q_{t
}}{k_{3}+q_{t}}.\\frac{(k_{1}+1)f_{t,d}}{k_{1}((1-b)+bL_{d})+f_{t,d}
}.w_{t} \\] where $w_{t}$ is the termweight of term t
$f_{t,d}$ is the within document frequency of term t in document d
$q_{t}$ is the within query frequency of term t
$L_{d}$ is the normalised length of document d
$n_{q}$ is the size of the query
$k_{1}$, $k_{2}$, $k_{3}$ and $b$ are user specified parameters
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""Xapian::BM25Weight::BM25Weight() """
_xapian.BM25Weight_swiginit(self,_xapian.new_BM25Weight(*args))
def clone(*args):
"""
Return a new weight object of this type.
BM25Weight* Xapian::BM25Weight::clone() const
A subclass called FooWeight taking parameters param1 and param2 should
implement this as:
virtual FooWeight * clone() const { return new FooWeight(param1,
param2); }
"""
return _xapian.BM25Weight_clone(*args)
__swig_destroy__ = _xapian.delete_BM25Weight
def unserialise(*args):
"""
Create object given string serialisation returned by serialise().
BM25Weight* Xapian::BM25Weight::unserialise(const std::string &s)
const
"""
return _xapian.BM25Weight_unserialise(*args)
BM25Weight.clone = new_instancemethod(_xapian.BM25Weight_clone,None,BM25Weight)
BM25Weight.unserialise = new_instancemethod(_xapian.BM25Weight_unserialise,None,BM25Weight)
BM25Weight_swigregister = _xapian.BM25Weight_swigregister
BM25Weight_swigregister(BM25Weight)
class TradWeight(Weight):
"""
Traditional probabilistic weighting scheme.
This class implements the Traditional Probabilistic Weighting scheme,
as described by the early papers on Probabilistic Retrieval. BM25
generally gives better results.
The Traditional weighting scheme formula is \\[
\\sum_{t}\\frac{f_{t,d}}{k.L_{d}+f_{t,d}}.w_{t} \\] where
$w_{t}$ is the termweight of term t
$f_{t,d}$ is the within document frequency of term t in document d
$L_{d}$ is the normalised length of document d
$k$ is a user specifiable parameter
TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that
the latter returns weights (k+1) times larger.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""Xapian::TradWeight::TradWeight() """
_xapian.TradWeight_swiginit(self,_xapian.new_TradWeight(*args))
def clone(*args):
"""
Return a new weight object of this type.
TradWeight* Xapian::TradWeight::clone() const
A subclass called FooWeight taking parameters param1 and param2 should
implement this as:
virtual FooWeight * clone() const { return new FooWeight(param1,
param2); }
"""
return _xapian.TradWeight_clone(*args)
__swig_destroy__ = _xapian.delete_TradWeight
def unserialise(*args):
"""
Create object given string serialisation returned by serialise().
TradWeight* Xapian::TradWeight::unserialise(const std::string &s)
const
"""
return _xapian.TradWeight_unserialise(*args)
TradWeight.clone = new_instancemethod(_xapian.TradWeight_clone,None,TradWeight)
TradWeight.unserialise = new_instancemethod(_xapian.TradWeight_unserialise,None,TradWeight)
TradWeight_swigregister = _xapian.TradWeight_swigregister
TradWeight_swigregister(TradWeight)
class Database(object):
"""
This class is used to access a database, or a group of databases.
For searching, this class is used in conjunction with an Enquire
object.
Parameters:
-----------
InvalidArgumentError: will be thrown if an invalid argument is
supplied, for example, an unknown database type.
DatabaseOpeningError: may be thrown if the database cannot be opened
(for example, a required file cannot be found).
DatabaseVersionError: may be thrown if the database is in an
unsupported format (for example, created by a newer version of Xapian
which uses an incompatible format).
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def add_database(*args):
"""
Add an existing database (or group of databases) to those accessed by
this object.
void Xapian::Database::add_database(const Database &database)
Parameters:
-----------
database: the database(s) to add.
"""
return _xapian.Database_add_database(*args)
__swig_destroy__ = _xapian.delete_Database
def __init__(self, *args):
"""
Copying is allowed.
Xapian::Database::Database(const Database &other)
The internals are reference counted, so copying is cheap.
"""
_xapian.Database_swiginit(self,_xapian.new_Database(*args))
def reopen(*args):
"""
Re-open the database.
void Xapian::Database::reopen()
This re-opens the database(s) to the latest available version(s). It
can be used either to make sure the latest results are returned, or to
recover from a Xapian::DatabaseModifiedError.
"""
return _xapian.Database_reopen(*args)
def __str__(*args):
"""
Return a string describing this object.
virtual std::string Xapian::Database::get_description() const
"""
return _xapian.Database___str__(*args)
def postlist_begin(*args):
"""
An iterator pointing to the start of the postlist for a given term.
PostingIterator Xapian::Database::postlist_begin(const std::string
&tname) const
If the term name is the empty string, the iterator returned will list
all the documents in the database. Such an iterator will always return
a WDF value of 1, since there is no obvious meaning for this quantity
in this case.
"""
return _xapian.Database_postlist_begin(*args)
def postlist_end(*args):
"""
Corresponding end iterator to postlist_begin().
PostingIterator Xapian::Database::postlist_end(const std::string &)
const
"""
return _xapian.Database_postlist_end(*args)
def termlist_begin(*args):
"""
An iterator pointing to the start of the termlist for a given
document.
TermIterator Xapian::Database::termlist_begin(Xapian::docid did) const
"""
return _xapian.Database_termlist_begin(*args)
def termlist_end(*args):
"""
Corresponding end iterator to termlist_begin().
TermIterator Xapian::Database::termlist_end(Xapian::docid) const
"""
return _xapian.Database_termlist_end(*args)
def positionlist_begin(*args):
"""
An iterator pointing to the start of the position list for a given
term in a given document.
PositionIterator Xapian::Database::positionlist_begin(Xapian::docid
did, const std::string &tname) const
"""
return _xapian.Database_positionlist_begin(*args)
def positionlist_end(*args):
"""
Corresponding end iterator to positionlist_begin().
PositionIterator Xapian::Database::positionlist_end(Xapian::docid,
const std::string &) const
"""
return _xapian.Database_positionlist_end(*args)
def allterms_begin(*args):
"""
An iterator which runs across all terms with a given prefix.
TermIterator Xapian::Database::allterms_begin(const std::string
&prefix) const
This is functionally similar to getting an iterator with
allterms_begin() and then calling skip_to(prefix) on that iterator to
move to the start of the prefix, but is more convenient (because it
detects the end of the prefixed terms), and may be more efficient than
simply calling skip_to() after opening the iterator, particularly for
network databases.
Parameters:
-----------
prefix: The prefix to restrict the returned terms to.
"""
return _xapian.Database_allterms_begin(*args)
def allterms_end(*args):
"""
Corresponding end iterator to allterms_begin(prefix).
TermIterator Xapian::Database::allterms_end(const std::string &) const
"""
return _xapian.Database_allterms_end(*args)
def get_doccount(*args):
"""
Get the number of documents in the database.
Xapian::doccount Xapian::Database::get_doccount() const
"""
return _xapian.Database_get_doccount(*args)
def get_lastdocid(*args):
"""
Get the highest document id which has been used in the database.
Xapian::docid Xapian::Database::get_lastdocid() const
"""
return _xapian.Database_get_lastdocid(*args)
def get_avlength(*args):
"""
Get the average length of the documents in the database.
Xapian::doclength Xapian::Database::get_avlength() const
"""
return _xapian.Database_get_avlength(*args)
def get_termfreq(*args):
"""
Get the number of documents in the database indexed by a given term.
Xapian::doccount Xapian::Database::get_termfreq(const std::string
&tname) const
"""
return _xapian.Database_get_termfreq(*args)
def term_exists(*args):
"""
Check if a given term exists in the database.
bool Xapian::Database::term_exists(const std::string &tname) const
Return true if and only if the term exists in the database. This is
the same as (get_termfreq(tname) != 0), but will often be more
efficient.
"""
return _xapian.Database_term_exists(*args)
def get_collection_freq(*args):
"""
Return the total number of occurrences of the given term.
Xapian::termcount Xapian::Database::get_collection_freq(const
std::string &tname) const
This is the sum of the number of occurrences of the term in each
document it indexes: i.e., the sum of the within document frequencies
of the term.
Parameters:
-----------
tname: The term whose collection frequency is being requested.
"""
return _xapian.Database_get_collection_freq(*args)
def get_doclength(*args):
"""
Get the length of a document.
Xapian::doclength Xapian::Database::get_doclength(Xapian::docid did)
const
"""
return _xapian.Database_get_doclength(*args)
def keep_alive(*args):
"""
Send a "keep-alive" to remote databases to stop them timing out.
void Xapian::Database::keep_alive()
"""
return _xapian.Database_keep_alive(*args)
def get_document(*args):
"""
Get a document from the database, given its document id.
Xapian::Document Xapian::Database::get_document(Xapian::docid did)
const
This method returns a Xapian::Document object which provides the
information about a document.
Parameters:
-----------
did: The document id for which to retrieve the data.
A Xapian::Document object containing the document data
Parameters:
-----------
Xapian::DocNotFoundError: The document specified could not be found
in the database.
"""
return _xapian.Database_get_document(*args)
def get_spelling_suggestion(*args):
"""
Suggest a spelling correction.
std::string Xapian::Database::get_spelling_suggestion(const
std::string &word, unsigned max_edit_distance=2) const
Parameters:
-----------
word: The potentially misspelled word.
max_edit_distance: Only consider words which are at most
max_edit_distance edits from word. An edit is a character insertion,
deletion, or the transposition of two adjacent characters (default is
2).
"""
return _xapian.Database_get_spelling_suggestion(*args)
def spellings_begin(*args):
"""
An iterator which returns all the spelling correction targets.
Xapian::TermIterator Xapian::Database::spellings_begin() const
This returns all the words which are considered as targets for the
spelling correction algorithm. The frequency of each word is available
as the term frequency of each entry in the returned iterator.
"""
return _xapian.Database_spellings_begin(*args)
def spellings_end(*args):
"""
Corresponding end iterator to spellings_begin().
Xapian::TermIterator Xapian::Database::spellings_end() const
"""
return _xapian.Database_spellings_end(*args)
def synonyms_begin(*args):
"""
An iterator which returns all the synonyms for a given term.
Xapian::TermIterator Xapian::Database::synonyms_begin(const
std::string &term) const
Parameters:
-----------
term: The term to return synonyms for.
"""
return _xapian.Database_synonyms_begin(*args)
def synonyms_end(*args):
"""
Corresponding end iterator to synonyms_begin(term).
Xapian::TermIterator Xapian::Database::synonyms_end(const std::string
&) const
"""
return _xapian.Database_synonyms_end(*args)
def synonym_keys_begin(*args):
"""
An iterator which returns all terms which have synonyms.
Xapian::TermIterator Xapian::Database::synonym_keys_begin(const
std::string &prefix="") const
Parameters:
-----------
prefix: If non-empty, only terms with this prefix are returned.
"""
return _xapian.Database_synonym_keys_begin(*args)
def synonym_keys_end(*args):
"""
Corresponding end iterator to synonym_keys_begin(prefix).
Xapian::TermIterator Xapian::Database::synonym_keys_end(const
std::string &="") const
"""
return _xapian.Database_synonym_keys_end(*args)
def get_metadata(*args):
"""
Get the user-specified metadata associated with a given key.
std::string Xapian::Database::get_metadata(const std::string &key)
const
User-specified metadata allows you to store arbitrary information in
the form of (key,tag) pairs. See WritableDatabase::set_metadata() for
more information.
When invoked on a Xapian::Database object representing multiple
databases, currently only the metadata for the first is considered but
this behaviour may change in the future.
If there is no piece of metadata associated with the specified key, an
empty string is returned (this applies even for backends which don't
support metadata).
Empty keys are not valid, and specifying one will cause an exception.
Parameters:
-----------
key: The key of the metadata item to access.
The retrieved metadata item's value.
Parameters:
-----------
Xapian::InvalidArgumentError: will be thrown if the key supplied is
empty.
Xapian::UnimplementedError: will be thrown if the database backend in
use doesn't support user- specified metadata.
"""
return _xapian.Database_get_metadata(*args)
def get_description(*args):
"""
Return a string describing this object.
virtual std::string Xapian::Database::get_description() const
"""
return _xapian.Database_get_description(*args)
Database.add_database = new_instancemethod(_xapian.Database_add_database,None,Database)
Database.reopen = new_instancemethod(_xapian.Database_reopen,None,Database)
Database.__str__ = new_instancemethod(_xapian.Database___str__,None,Database)
Database.postlist_begin = new_instancemethod(_xapian.Database_postlist_begin,None,Database)
Database.postlist_end = new_instancemethod(_xapian.Database_postlist_end,None,Database)
Database.termlist_begin = new_instancemethod(_xapian.Database_termlist_begin,None,Database)
Database.termlist_end = new_instancemethod(_xapian.Database_termlist_end,None,Database)
Database.positionlist_begin = new_instancemethod(_xapian.Database_positionlist_begin,None,Database)
Database.positionlist_end = new_instancemethod(_xapian.Database_positionlist_end,None,Database)
Database.allterms_begin = new_instancemethod(_xapian.Database_allterms_begin,None,Database)
Database.allterms_end = new_instancemethod(_xapian.Database_allterms_end,None,Database)
Database.get_doccount = new_instancemethod(_xapian.Database_get_doccount,None,Database)
Database.get_lastdocid = new_instancemethod(_xapian.Database_get_lastdocid,None,Database)
Database.get_avlength = new_instancemethod(_xapian.Database_get_avlength,None,Database)
Database.get_termfreq = new_instancemethod(_xapian.Database_get_termfreq,None,Database)
Database.term_exists = new_instancemethod(_xapian.Database_term_exists,None,Database)
Database.get_collection_freq = new_instancemethod(_xapian.Database_get_collection_freq,None,Database)
Database.get_doclength = new_instancemethod(_xapian.Database_get_doclength,None,Database)
Database.keep_alive = new_instancemethod(_xapian.Database_keep_alive,None,Database)
Database.get_document = new_instancemethod(_xapian.Database_get_document,None,Database)
Database.get_spelling_suggestion = new_instancemethod(_xapian.Database_get_spelling_suggestion,None,Database)
Database.spellings_begin = new_instancemethod(_xapian.Database_spellings_begin,None,Database)
Database.spellings_end = new_instancemethod(_xapian.Database_spellings_end,None,Database)
Database.synonyms_begin = new_instancemethod(_xapian.Database_synonyms_begin,None,Database)
Database.synonyms_end = new_instancemethod(_xapian.Database_synonyms_end,None,Database)
Database.synonym_keys_begin = new_instancemethod(_xapian.Database_synonym_keys_begin,None,Database)
Database.synonym_keys_end = new_instancemethod(_xapian.Database_synonym_keys_end,None,Database)
Database.get_metadata = new_instancemethod(_xapian.Database_get_metadata,None,Database)
Database.get_description = new_instancemethod(_xapian.Database_get_description,None,Database)
Database_swigregister = _xapian.Database_swigregister
Database_swigregister(Database)
class WritableDatabase(Database):
"""
This class provides read/write access to a database.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_WritableDatabase
def __init__(self, *args):
"""
Copying is allowed.
Xapian::WritableDatabase::WritableDatabase(const WritableDatabase
&other)
The internals are reference counted, so copying is cheap.
"""
_xapian.WritableDatabase_swiginit(self,_xapian.new_WritableDatabase(*args))
def flush(*args):
"""
Flush to disk any modifications made to the database.
void Xapian::WritableDatabase::flush()
For efficiency reasons, when performing multiple updates to a database
it is best (indeed, almost essential) to make as many modifications as
memory will permit in a single pass through the database. To ensure
this, Xapian batches up modifications.
Flush may be called at any time to ensure that the modifications which
have been made are written to disk: if the flush succeeds, all the
preceding modifications will have been written to disk.
If any of the modifications fail, an exception will be thrown and the
database will be left in a state in which each separate addition,
replacement or deletion operation has either been fully performed or
not performed at all: it is then up to the application to work out
which operations need to be repeated.
It's not valid to call flush within a transaction.
Beware of calling flush too frequently: this will have a severe
performance cost.
Note that flush need not be called explicitly: it will be called
automatically when the database is closed, or when a sufficient number
of modifications have been made.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
modifying the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
Xapian::DatabaseLockError: will be thrown if a lock couldn't be
acquired on the database.
"""
return _xapian.WritableDatabase_flush(*args)
def begin_transaction(*args):
"""
Begin a transaction.
void Xapian::WritableDatabase::begin_transaction(bool flushed=true)
In Xapian a transaction is a group of modifications to the database
which are linked such that either all will be applied simultaneously
or none will be applied at all. Even in the case of a power failure,
this characteristic should be preserved (as long as the filesystem
isn't corrupted, etc).
A transaction is started with begin_transaction() and can either be
committed by calling commit_transaction() or aborted by calling
cancel_transaction().
By default, a transaction implicitly calls flush before and after so
that the modifications stand and fall without affecting modifications
before or after.
The downside of this flushing is that small transactions cause
modifications to be frequently flushed which can harm indexing
performance in the same way that explicitly calling flush frequently
can.
If you're applying atomic groups of changes and only wish to ensure
that each group is either applied or not applied, then you can prevent
the automatic flush before and after the transaction by starting the
transaction with begin_transaction(false). However, if
cancel_transaction is called (or if commit_transaction isn't called
before the WritableDatabase object is destroyed) then any changes
which were pending before the transaction began will also be
discarded.
Transactions aren't currently supported by the InMemory backend.
Parameters:
-----------
Xapian::UnimplementedError: will be thrown if transactions are not
available for this database type.
Xapian::InvalidOperationError: will be thrown if this is called at an
invalid time, such as when a transaction is already in progress.
"""
return _xapian.WritableDatabase_begin_transaction(*args)
def commit_transaction(*args):
"""
Complete the transaction currently in progress.
void Xapian::WritableDatabase::commit_transaction()
If this method completes successfully and this is a flushed
transaction, all the database modifications made during the
transaction will have been committed to the database.
If an error occurs, an exception will be thrown, and none of the
modifications made to the database during the transaction will have
been applied to the database.
In all cases the transaction will no longer be in progress.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
modifying the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
Xapian::InvalidOperationError: will be thrown if a transaction is not
currently in progress.
Xapian::UnimplementedError: will be thrown if transactions are not
available for this database type.
"""
return _xapian.WritableDatabase_commit_transaction(*args)
def cancel_transaction(*args):
"""
Abort the transaction currently in progress, discarding the potential
modifications made to the database.
void Xapian::WritableDatabase::cancel_transaction()
If an error occurs in this method, an exception will be thrown, but
the transaction will be cancelled anyway.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
modifying the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
Xapian::InvalidOperationError: will be thrown if a transaction is not
currently in progress.
Xapian::UnimplementedError: will be thrown if transactions are not
available for this database type.
"""
return _xapian.WritableDatabase_cancel_transaction(*args)
def add_document(*args):
"""
Add a new document to the database.
Xapian::docid Xapian::WritableDatabase::add_document(const
Xapian::Document &document)
This method adds the specified document to the database, returning a
newly allocated document ID. Automatically allocated document IDs come
from a per-database monotonically increasing counter, so IDs from
deleted documents won't be reused.
If you want to specify the document ID to be used, you should call
replace_document() instead.
Note that changes to the database won't be immediately committed to
disk; see flush() for more details.
As with all database modification operations, the effect is atomic:
the document will either be fully added, or the document fails to be
added and an exception is thrown (possibly at a later time when flush
is called or the database is closed).
Parameters:
-----------
document: The new document to be added.
The document ID of the newly added document.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
writing to the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
"""
return _xapian.WritableDatabase_add_document(*args)
def delete_document(*args):
"""
Delete any documents indexed by a term from the database.
void Xapian::WritableDatabase::delete_document(const std::string
&unique_term)
This method removes any documents indexed by the specified term from
the database.
A major use is for convenience when UIDs from another system are
mapped to terms in Xapian, although this method has other uses (for
example, you could add a "deletion date" term to documents at index
time and use this method to delete all documents due for deletion on a
particular date).
Parameters:
-----------
unique_term: The term to remove references to.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
writing to the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
"""
return _xapian.WritableDatabase_delete_document(*args)
def replace_document(*args):
"""
Replace any documents matching a term.
Xapian::docid Xapian::WritableDatabase::replace_document(const
std::string &unique_term, const Xapian::Document &document)
This method replaces any documents indexed by the specified term with
the specified document. If any documents are indexed by the term, the
lowest document ID will be used for the document, otherwise a new
document ID will be generated as for add_document.
The intended use is to allow UIDs from another system to easily be
mapped to terms in Xapian, although this method probably has other
uses.
Note that changes to the database won't be immediately committed to
disk; see flush() for more details.
As with all database modification operations, the effect is atomic:
the document(s) will either be fully replaced, or the document(s) fail
to be replaced and an exception is thrown (possibly at a later time
when flush is called or the database is closed).
Parameters:
-----------
unique_term: The "unique" term.
document: The new document.
The document ID that document was given.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
writing to the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
"""
return _xapian.WritableDatabase_replace_document(*args)
def add_spelling(*args):
"""
Add a word to the spelling dictionary.
void Xapian::WritableDatabase::add_spelling(const std::string &word,
Xapian::termcount freqinc=1) const
If the word is already present, its frequency is increased.
Parameters:
-----------
word: The word to add.
freqinc: How much to increase its frequency by (default 1).
"""
return _xapian.WritableDatabase_add_spelling(*args)
def remove_spelling(*args):
"""
Remove a word from the spelling dictionary.
void Xapian::WritableDatabase::remove_spelling(const std::string
&word, Xapian::termcount freqdec=1) const
The word's frequency is decreased, and if would become zero or less
then the word is removed completely.
Parameters:
-----------
word: The word to remove.
freqdec: How much to decrease its frequency by (default 1).
"""
return _xapian.WritableDatabase_remove_spelling(*args)
def add_synonym(*args):
"""
Add a synonym for a term.
void Xapian::WritableDatabase::add_synonym(const std::string &term,
const std::string &synonym) const
If synonym is already a synonym for term, then no action is taken.
"""
return _xapian.WritableDatabase_add_synonym(*args)
def remove_synonym(*args):
"""
Remove a synonym for a term.
void Xapian::WritableDatabase::remove_synonym(const std::string &term,
const std::string &synonym) const
If synonym isn't a synonym for term, then no action is taken.
"""
return _xapian.WritableDatabase_remove_synonym(*args)
def clear_synonyms(*args):
"""
Remove all synonyms for a term.
void Xapian::WritableDatabase::clear_synonyms(const std::string &term)
const
If term has no synonyms, no action is taken.
"""
return _xapian.WritableDatabase_clear_synonyms(*args)
def set_metadata(*args):
"""
Set the user-specified metadata associated with a given key.
void Xapian::WritableDatabase::set_metadata(const std::string &key,
const std::string &value)
This method sets the metadata value associated with a given key. If
there is already a metadata value stored in the database with the same
key, the old value is replaced. If you want to delete an existing item
of metadata, just set its value to the empty string.
User-specified metadata allows you to store arbitrary information in
the form of (key,tag) pairs.
There's no hard limit on the number of metadata items, or the size of
the metadata values. Metadata keys have a limited length, which
depends on the backend. We recommend limiting them to 200 bytes. Empty
keys are not valid, and specifying one will cause an exception.
Metadata modifications are committed to disk in the same way as
modifications to the documents in the database are: i.e.,
modifications are atomic, and won't be committed to disk immediately
(see flush() for more details). This allows metadata to be used to
link databases with versioned external resources by storing the
appropriate version number in a metadata item.
You can also use the metadata to store arbitrary extra information
associated with terms, documents, or postings by encoding the termname
and/or document id into the metadata key.
Parameters:
-----------
key: The key of the metadata item to set.
value: The value of the metadata item to set.
Parameters:
-----------
Xapian::DatabaseError: will be thrown if a problem occurs while
writing to the database.
Xapian::DatabaseCorruptError: will be thrown if the database is in a
corrupt state.
Xapian::InvalidArgumentError: will be thrown if the key supplied is
empty.
"""
return _xapian.WritableDatabase_set_metadata(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::WritableDatabase::get_description() const
"""
return _xapian.WritableDatabase___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::WritableDatabase::get_description() const
"""
return _xapian.WritableDatabase_get_description(*args)
WritableDatabase.flush = new_instancemethod(_xapian.WritableDatabase_flush,None,WritableDatabase)
WritableDatabase.begin_transaction = new_instancemethod(_xapian.WritableDatabase_begin_transaction,None,WritableDatabase)
WritableDatabase.commit_transaction = new_instancemethod(_xapian.WritableDatabase_commit_transaction,None,WritableDatabase)
WritableDatabase.cancel_transaction = new_instancemethod(_xapian.WritableDatabase_cancel_transaction,None,WritableDatabase)
WritableDatabase.add_document = new_instancemethod(_xapian.WritableDatabase_add_document,None,WritableDatabase)
WritableDatabase.delete_document = new_instancemethod(_xapian.WritableDatabase_delete_document,None,WritableDatabase)
WritableDatabase.replace_document = new_instancemethod(_xapian.WritableDatabase_replace_document,None,WritableDatabase)
WritableDatabase.add_spelling = new_instancemethod(_xapian.WritableDatabase_add_spelling,None,WritableDatabase)
WritableDatabase.remove_spelling = new_instancemethod(_xapian.WritableDatabase_remove_spelling,None,WritableDatabase)
WritableDatabase.add_synonym = new_instancemethod(_xapian.WritableDatabase_add_synonym,None,WritableDatabase)
WritableDatabase.remove_synonym = new_instancemethod(_xapian.WritableDatabase_remove_synonym,None,WritableDatabase)
WritableDatabase.clear_synonyms = new_instancemethod(_xapian.WritableDatabase_clear_synonyms,None,WritableDatabase)
WritableDatabase.set_metadata = new_instancemethod(_xapian.WritableDatabase_set_metadata,None,WritableDatabase)
WritableDatabase.__str__ = new_instancemethod(_xapian.WritableDatabase___str__,None,WritableDatabase)
WritableDatabase.get_description = new_instancemethod(_xapian.WritableDatabase_get_description,None,WritableDatabase)
WritableDatabase_swigregister = _xapian.WritableDatabase_swigregister
WritableDatabase_swigregister(WritableDatabase)
DB_CREATE_OR_OPEN = _xapian.DB_CREATE_OR_OPEN
DB_CREATE = _xapian.DB_CREATE
DB_CREATE_OR_OVERWRITE = _xapian.DB_CREATE_OR_OVERWRITE
DB_OPEN = _xapian.DB_OPEN
def open_stub(*args):
"""
Construct a Database object for a stub database file.
XAPIAN_VISIBILITY_DEFAULT Database Xapian::Auto::open_stub(const
std::string &file)
The stub database file contains serialised parameters for one or more
databases.
Parameters:
-----------
file: pathname of the stub database file.
"""
return _xapian.open_stub(*args)
def inmemory_open(*args):
"""
Construct a Database object for update access to an InMemory database.
XAPIAN_VISIBILITY_DEFAULT WritableDatabase Xapian::InMemory::open()
A new, empty database is created for each call.
"""
return _xapian.inmemory_open(*args)
class Query(object):
"""
Class representing a query.
Queries are represented as a tree of objects.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
OP_AND = _xapian.Query_OP_AND
OP_OR = _xapian.Query_OP_OR
OP_AND_NOT = _xapian.Query_OP_AND_NOT
OP_XOR = _xapian.Query_OP_XOR
OP_AND_MAYBE = _xapian.Query_OP_AND_MAYBE
OP_FILTER = _xapian.Query_OP_FILTER
OP_NEAR = _xapian.Query_OP_NEAR
OP_PHRASE = _xapian.Query_OP_PHRASE
OP_VALUE_RANGE = _xapian.Query_OP_VALUE_RANGE
OP_SCALE_WEIGHT = _xapian.Query_OP_SCALE_WEIGHT
OP_ELITE_SET = _xapian.Query_OP_ELITE_SET
OP_VALUE_GE = _xapian.Query_OP_VALUE_GE
OP_VALUE_LE = _xapian.Query_OP_VALUE_LE
def __init__(self, *args):
"""
Construct a value comparison query on a document value.
Xapian::Query::Query(Query::op op_, Xapian::valueno valno, const
std::string &value)
This query matches those documents which have a value stored in the
slot given by valno which compares, as specified by the operator, to
value.
Parameters:
-----------
op_: The operator to use for the query. Currently, must be
OP_VALUE_GE or OP_VALUE_LE.
valno: The slot number to get the value from.
value: The value to compare.
"""
_xapian.Query_swiginit(self,_xapian.new_Query(*args))
__swig_destroy__ = _xapian.delete_Query
def get_length(*args):
"""
Get the length of the query, used by some ranking formulae.
Xapian::termcount Xapian::Query::get_length() const
This value is calculated automatically - if you want to override it
you can pass a different value to Enquire::set_query().
"""
return _xapian.Query_get_length(*args)
def get_terms_begin(*args):
"""
Return a Xapian::TermIterator returning all the terms in the query, in
order of termpos.
TermIterator Xapian::Query::get_terms_begin() const
If multiple terms have the same term position, their order is
unspecified. Duplicates (same term and termpos) will be removed.
"""
return _xapian.Query_get_terms_begin(*args)
def get_terms_end(*args):
"""
Return a Xapian::TermIterator to the end of the list of terms in the
query.
TermIterator Xapian::Query::get_terms_end() const
"""
return _xapian.Query_get_terms_end(*args)
def empty(*args):
"""
Test if the query is empty (i.e.
bool Xapian::Query::empty() const
was constructed using the default ctor or with an empty iterator
ctor).
"""
return _xapian.Query_empty(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::Query::get_description() const
"""
return _xapian.Query___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::Query::get_description() const
"""
return _xapian.Query_get_description(*args)
Query.get_length = new_instancemethod(_xapian.Query_get_length,None,Query)
Query.get_terms_begin = new_instancemethod(_xapian.Query_get_terms_begin,None,Query)
Query.get_terms_end = new_instancemethod(_xapian.Query_get_terms_end,None,Query)
Query.empty = new_instancemethod(_xapian.Query_empty,None,Query)
Query.__str__ = new_instancemethod(_xapian.Query___str__,None,Query)
Query.get_description = new_instancemethod(_xapian.Query_get_description,None,Query)
Query_swigregister = _xapian.Query_swigregister
Query_swigregister(Query)
quartz_open = _xapian.quartz_open
def flint_open(*args):
"""
Construct a Database object for update access to a Flint database.
XAPIAN_VISIBILITY_DEFAULT WritableDatabase Xapian::Flint::open(const
std::string &dir, int action, int block_size=8192)
Parameters:
-----------
dir: pathname of the directory containing the database.
action: determines handling of existing/non-existing database:
Xapian::DB_CREATE fail if database already exist, otherwise create new
database.
Xapian::DB_CREATE_OR_OPEN open existing database, or create new
database if none exists.
Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or create
new database if none exists.
Xapian::DB_OPEN open existing database, failing if none exists.
block_size: the Btree blocksize to use (in bytes), which must be a
power of two between 2048 and 65536 (inclusive). The default (also
used if an invalid value if passed) is 8192 bytes. This parameter is
ignored when opening an existing database.
"""
return _xapian.flint_open(*args)
def remote_open(*args):
"""
Construct a Database object for read-only access to a remote database
accessed via a program.
XAPIAN_VISIBILITY_DEFAULT Database Xapian::Remote::open(const
std::string &program, const std::string &args, Xapian::timeout
timeout=10000)
Access to the remote database is done by running an external program
and communicating with it on stdin/stdout.
Parameters:
-----------
program: the external program to run.
args: space-separated list of arguments to pass to program.
timeout: timeout in milliseconds. If this timeout is exceeded for any
individual operation on the remote database then
Xapian::NetworkTimeoutError is thrown. A timeout of 0 means don't
timeout. (Default is 10000ms, which is 10 seconds).
"""
return _xapian.remote_open(*args)
def remote_open_writable(*args):
"""
Construct a WritableDatabase object for update access to a remote
database accessed via a program.
XAPIAN_VISIBILITY_DEFAULT WritableDatabase
Xapian::Remote::open_writable(const std::string &program, const
std::string &args, Xapian::timeout timeout=0)
Access to the remote database is done by running an external program
and communicating with it on stdin/stdout.
Parameters:
-----------
program: the external program to run.
args: space-separated list of arguments to pass to program.
timeout: timeout in milliseconds. If this timeout is exceeded for any
individual operation on the remote database then
Xapian::NetworkTimeoutError is thrown. (Default is 0, which means
don't timeout).
"""
return _xapian.remote_open_writable(*args)
class Stopper(object):
"""
Base class for stop-word decision functor.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_Stopper
def __str__(*args):
"""
Return a string describing this object.
virtual std::string Xapian::Stopper::get_description() const
"""
return _xapian.Stopper___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
virtual std::string Xapian::Stopper::get_description() const
"""
return _xapian.Stopper_get_description(*args)
def __init__(self, *args):
if self.__class__ == Stopper:
args = (None,) + args
else:
args = (self,) + args
_xapian.Stopper_swiginit(self,_xapian.new_Stopper(*args))
def __disown__(self):
self.this.disown()
_xapian.disown_Stopper(self)
return weakref_proxy(self)
Stopper.__call__ = new_instancemethod(_xapian.Stopper___call__,None,Stopper)
Stopper.__str__ = new_instancemethod(_xapian.Stopper___str__,None,Stopper)
Stopper.get_description = new_instancemethod(_xapian.Stopper_get_description,None,Stopper)
Stopper_swigregister = _xapian.Stopper_swigregister
Stopper_swigregister(Stopper)
class SimpleStopper(Stopper):
"""
Simple implementation of Stopper class - this will suit most users.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Initialise from a pair of iterators.
Xapian::SimpleStopper::SimpleStopper(Iterator begin, Iterator end)
"""
_xapian.SimpleStopper_swiginit(self,_xapian.new_SimpleStopper(*args))
def add(*args):
"""
Add a single stop word.
void Xapian::SimpleStopper::add(const std::string &word)
"""
return _xapian.SimpleStopper_add(*args)
__swig_destroy__ = _xapian.delete_SimpleStopper
SimpleStopper.add = new_instancemethod(_xapian.SimpleStopper_add,None,SimpleStopper)
SimpleStopper_swigregister = _xapian.SimpleStopper_swigregister
SimpleStopper_swigregister(SimpleStopper)
class ValueRangeProcessor(object):
"""
Base class for value range processors.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_ValueRangeProcessor
def __init__(self, *args):
if self.__class__ == ValueRangeProcessor:
args = (None,) + args
else:
args = (self,) + args
_xapian.ValueRangeProcessor_swiginit(self,_xapian.new_ValueRangeProcessor(*args))
def __disown__(self):
self.this.disown()
_xapian.disown_ValueRangeProcessor(self)
return weakref_proxy(self)
ValueRangeProcessor.__call__ = new_instancemethod(_xapian.ValueRangeProcessor___call__,None,ValueRangeProcessor)
ValueRangeProcessor.__call = new_instancemethod(_xapian.ValueRangeProcessor___call,None,ValueRangeProcessor)
ValueRangeProcessor_swigregister = _xapian.ValueRangeProcessor_swigregister
ValueRangeProcessor_swigregister(ValueRangeProcessor)
class StringValueRangeProcessor(ValueRangeProcessor):
"""
Handle a string range.
The end points can be any strings.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Constructor.
Xapian::StringValueRangeProcessor::StringValueRangeProcessor(Xapian::v
alueno valno_)
Parameters:
-----------
valno_: The value number to return from operator().
"""
_xapian.StringValueRangeProcessor_swiginit(self,_xapian.new_StringValueRangeProcessor(*args))
__swig_destroy__ = _xapian.delete_StringValueRangeProcessor
StringValueRangeProcessor_swigregister = _xapian.StringValueRangeProcessor_swigregister
StringValueRangeProcessor_swigregister(StringValueRangeProcessor)
class DateValueRangeProcessor(ValueRangeProcessor):
"""
Handle a date range.
Begin and end must be dates in a recognised format.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Constructor.
Xapian::DateValueRangeProcessor::DateValueRangeProcessor(Xapian::value
no valno_, bool prefer_mdy_=false, int epoch_year_=1970)
Parameters:
-----------
valno_: The value number to return from operator().
prefer_mdy_: Should ambiguous dates be interpreted as month/day/year
rather than day/month/year? (default: false)
epoch_year_: Year to use as the epoch for dates with 2 digit years
(default: 1970, so 1/1/69 is 2069 while 1/1/70 is 1970).
"""
_xapian.DateValueRangeProcessor_swiginit(self,_xapian.new_DateValueRangeProcessor(*args))
__swig_destroy__ = _xapian.delete_DateValueRangeProcessor
DateValueRangeProcessor_swigregister = _xapian.DateValueRangeProcessor_swigregister
DateValueRangeProcessor_swigregister(DateValueRangeProcessor)
class NumberValueRangeProcessor(ValueRangeProcessor):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
_xapian.NumberValueRangeProcessor_swiginit(self,_xapian.new_NumberValueRangeProcessor(*args))
__swig_destroy__ = _xapian.delete_NumberValueRangeProcessor
NumberValueRangeProcessor_swigregister = _xapian.NumberValueRangeProcessor_swigregister
NumberValueRangeProcessor_swigregister(NumberValueRangeProcessor)
class QueryParser(object):
"""
Build a Xapian::Query object from a user query string.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
FLAG_BOOLEAN = _xapian.QueryParser_FLAG_BOOLEAN
FLAG_PHRASE = _xapian.QueryParser_FLAG_PHRASE
FLAG_LOVEHATE = _xapian.QueryParser_FLAG_LOVEHATE
FLAG_BOOLEAN_ANY_CASE = _xapian.QueryParser_FLAG_BOOLEAN_ANY_CASE
FLAG_WILDCARD = _xapian.QueryParser_FLAG_WILDCARD
FLAG_PURE_NOT = _xapian.QueryParser_FLAG_PURE_NOT
FLAG_PARTIAL = _xapian.QueryParser_FLAG_PARTIAL
FLAG_SPELLING_CORRECTION = _xapian.QueryParser_FLAG_SPELLING_CORRECTION
FLAG_SYNONYM = _xapian.QueryParser_FLAG_SYNONYM
FLAG_AUTO_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_SYNONYMS
FLAG_AUTO_MULTIWORD_SYNONYMS = _xapian.QueryParser_FLAG_AUTO_MULTIWORD_SYNONYMS
STEM_NONE = _xapian.QueryParser_STEM_NONE
STEM_SOME = _xapian.QueryParser_STEM_SOME
STEM_ALL = _xapian.QueryParser_STEM_ALL
def __init__(self, *args):
"""
Default constructor.
Xapian::QueryParser::QueryParser()
"""
_xapian.QueryParser_swiginit(self,_xapian.new_QueryParser(*args))
__swig_destroy__ = _xapian.delete_QueryParser
def set_stemmer(*args):
"""
Set the stemmer.
void Xapian::QueryParser::set_stemmer(const Xapian::Stem &stemmer)
This sets the stemming algorithm which will be used by the query
parser. Note that the stemming algorithm will only be used according
to the stemming strategy set by set_stemming_strategy(), which
defaults to STEM_NONE. Therefore, to use a stemming algorithm, you
will also need to call set_stemming_strategy() with a value other than
STEM_NONE.
"""
return _xapian.QueryParser_set_stemmer(*args)
def set_stemming_strategy(*args):
"""
Set the stemming strategy.
void Xapian::QueryParser::set_stemming_strategy(stem_strategy
strategy)
This controls how the query parser will apply the stemming algorithm.
The default value is STEM_NONE. The possible values are:
STEM_NONE: Don't perform any stemming.
STEM_SOME: Search for stemmed forms of terms except for those which
start with a capital letter, or are followed by certain characters
(currently: (/@<>=*[{" ), or are used with operators which need
positional information. Stemmed terms are prefixed with 'Z'.
STEM_ALL: Search for stemmed forms of all words (note: no 'Z' prefix
is added).
Note that the stemming algorithm is only applied to words in
probabilistic fields - boolean filter terms are never stemmed.
"""
return _xapian.QueryParser_set_stemming_strategy(*args)
def set_stopper(*args):
"""
Set the stopper.
void Xapian::QueryParser::set_stopper(const Stopper *stop=NULL)
"""
return _xapian.QueryParser_set_stopper(*args)
def set_default_op(*args):
"""
Set the default boolean operator.
void Xapian::QueryParser::set_default_op(Query::op default_op)
"""
return _xapian.QueryParser_set_default_op(*args)
def get_default_op(*args):
"""
Get the default boolean operator.
Query::op Xapian::QueryParser::get_default_op() const
"""
return _xapian.QueryParser_get_default_op(*args)
def set_database(*args):
"""
Specify the database being searched.
void Xapian::QueryParser::set_database(const Database &db)
"""
return _xapian.QueryParser_set_database(*args)
def parse_query(*args):
"""
Parse a query.
Query Xapian::QueryParser::parse_query(const std::string
&query_string, unsigned flags=FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE,
const std::string &default_prefix="")
Parameters:
-----------
query_string: A free-text query as entered by a user
flags: Zero or more Query::feature_flag specifying what features the
QueryParser should support. Combine multiple values with bitwise-or
(|).
default_prefix: The default term prefix to use (default none). For
example, you can pass "A" when parsing an "Author" field.
"""
return _xapian.QueryParser_parse_query(*args)
def add_prefix(*args):
"""
Add a probabilistic term prefix.
void Xapian::QueryParser::add_prefix(const std::string &field, const
std::string &prefix)
For example:
This allows the user to search for author:Orwell which will be
converted to a search for the term "Aorwell".
Multiple fields can be mapped to the same prefix. For example, you can
make title: and subject: aliases for each other.
As of 1.0.4, you can call this method multiple times with the same
value of field to allow a single field to be mapped to multiple
prefixes. Multiple terms being generated for such a field, and
combined with Xapian::Query::OP_OR.
If any prefixes are specified for the empty field name (i.e. you call
this method with an empty string as the first parameter) these
prefixes will be used as the default prefix. If you do this and also
specify the default_prefix parameter to parse_query(), then the
default_prefix parameter will override.
If you call add_prefix() and add_boolean_prefix() for the same value
of field, a Xapian::InvalidOperationError exception will be thrown.
In 1.0.3 and earlier, subsequent calls to this method with the same
value of field had no effect.
Parameters:
-----------
field: The user visible field name
prefix: The term prefix to map this to
"""
return _xapian.QueryParser_add_prefix(*args)
def add_boolean_prefix(*args):
"""
Add a boolean term prefix allowing the user to restrict a search with
a boolean filter specified in the free text query.
void Xapian::QueryParser::add_boolean_prefix(const std::string &field,
const std::string &prefix)
For example:
This allows the user to restrict a search with site:xapian.org which
will be converted to Hxapian.org combined with any probabilistic query
with Xapian::Query::OP_FILTER.
If multiple boolean filters are specified in a query for the same
prefix, they will be combined with the Xapian::Query::OP_OR operator.
Then, if there are boolean filters for different prefixes, they will
be combined with the Xapian::Query::OP_AND operator.
Multiple fields can be mapped to the same prefix (so for example you
can make site: and domain: aliases for each other). Instances of
fields with different aliases but the same prefix will still be
combined with the OR operator.
For example, if "site" and "domain" map to "H", but author maps
to "A", a search for "site:foo domain:bar author:Fred" will map to
"(Hfoo OR Hbar) AND Afred".
As of 1.0.4, you can call this method multiple times with the same
value of field to allow a single field to be mapped to multiple
prefixes. Multiple terms being generated for such a field, and
combined with Xapian::Query::OP_OR.
Calling this method with an empty string for field will cause a
Xapian::InvalidArgumentError.
If you call add_prefix() and add_boolean_prefix() for the same value
of field, a Xapian::InvalidOperationError exception will be thrown.
In 1.0.3 and earlier, subsequent calls to this method with the same
value of field had no effect.
Parameters:
-----------
field: The user visible field name
prefix: The term prefix to map this to
"""
return _xapian.QueryParser_add_boolean_prefix(*args)
def stoplist_begin(*args):
"""
Iterate over terms omitted from the query as stopwords.
TermIterator Xapian::QueryParser::stoplist_begin() const
"""
return _xapian.QueryParser_stoplist_begin(*args)
def stoplist_end(*args):
"""TermIterator Xapian::QueryParser::stoplist_end() const """
return _xapian.QueryParser_stoplist_end(*args)
def unstem_begin(*args):
"""
Iterate over unstemmed forms of the given (stemmed) term used in the
query.
TermIterator Xapian::QueryParser::unstem_begin(const std::string
&term) const
"""
return _xapian.QueryParser_unstem_begin(*args)
def unstem_end(*args):
"""
TermIterator
Xapian::QueryParser::unstem_end(const std::string &) const
"""
return _xapian.QueryParser_unstem_end(*args)
def add_valuerangeprocessor(*args):
"""
Register a ValueRangeProcessor.
void Xapian::QueryParser::add_valuerangeprocessor(Xapian::ValueRangePr
ocessor *vrproc)
"""
return _xapian.QueryParser_add_valuerangeprocessor(*args)
def get_corrected_query_string(*args):
"""
Get the spelling-corrected query string.
std::string Xapian::QueryParser::get_corrected_query_string() const
This will only be set if FLAG_SPELLING_CORRECTION is specified when
QueryParser::parse_query() was last called.
If there were no corrections, an empty string is returned.
"""
return _xapian.QueryParser_get_corrected_query_string(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::QueryParser::get_description() const
"""
return _xapian.QueryParser___str__(*args)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::QueryParser::get_description() const
"""
return _xapian.QueryParser_get_description(*args)
QueryParser.set_stemmer = new_instancemethod(_xapian.QueryParser_set_stemmer,None,QueryParser)
QueryParser.set_stemming_strategy = new_instancemethod(_xapian.QueryParser_set_stemming_strategy,None,QueryParser)
QueryParser.set_stopper = new_instancemethod(_xapian.QueryParser_set_stopper,None,QueryParser)
QueryParser.set_default_op = new_instancemethod(_xapian.QueryParser_set_default_op,None,QueryParser)
QueryParser.get_default_op = new_instancemethod(_xapian.QueryParser_get_default_op,None,QueryParser)
QueryParser.set_database = new_instancemethod(_xapian.QueryParser_set_database,None,QueryParser)
QueryParser.parse_query = new_instancemethod(_xapian.QueryParser_parse_query,None,QueryParser)
QueryParser.add_prefix = new_instancemethod(_xapian.QueryParser_add_prefix,None,QueryParser)
QueryParser.add_boolean_prefix = new_instancemethod(_xapian.QueryParser_add_boolean_prefix,None,QueryParser)
QueryParser.stoplist_begin = new_instancemethod(_xapian.QueryParser_stoplist_begin,None,QueryParser)
QueryParser.stoplist_end = new_instancemethod(_xapian.QueryParser_stoplist_end,None,QueryParser)
QueryParser.unstem_begin = new_instancemethod(_xapian.QueryParser_unstem_begin,None,QueryParser)
QueryParser.unstem_end = new_instancemethod(_xapian.QueryParser_unstem_end,None,QueryParser)
QueryParser.add_valuerangeprocessor = new_instancemethod(_xapian.QueryParser_add_valuerangeprocessor,None,QueryParser)
QueryParser.get_corrected_query_string = new_instancemethod(_xapian.QueryParser_get_corrected_query_string,None,QueryParser)
QueryParser.__str__ = new_instancemethod(_xapian.QueryParser___str__,None,QueryParser)
QueryParser.get_description = new_instancemethod(_xapian.QueryParser_get_description,None,QueryParser)
QueryParser_swigregister = _xapian.QueryParser_swigregister
QueryParser_swigregister(QueryParser)
sortable_serialise = _xapian.sortable_serialise
sortable_unserialise = _xapian.sortable_unserialise
class Stem(object):
"""
Class representing a stemming algorithm.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Construct a Xapian::Stem object for a particular language.
Xapian::Stem::Stem(const std::string &language)
Parameters:
-----------
language: Either the English name for the language or the two letter
ISO639 code.
The following language names are understood (aliases follow the name):
none - don't stem terms
danish (da)
dutch (nl)
english (en) - Martin Porter's 2002 revision of his stemmer
english_lovins (lovins) - Lovin's stemmer
english_porter (porter) - Porter's stemmer as described in his 1980
paper
finnish (fi)
french (fr)
german (de)
italian (it)
norwegian (no)
portuguese (pt)
russian (ru)
spanish (es)
swedish (sv)
Parameters:
-----------
Xapian::InvalidArgumentError: is thrown if language isn't recognised.
"""
_xapian.Stem_swiginit(self,_xapian.new_Stem(*args))
__swig_destroy__ = _xapian.delete_Stem
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::Stem::get_description() const
"""
return _xapian.Stem___str__(*args)
get_available_languages = staticmethod(_xapian.Stem_get_available_languages)
def get_description(*args):
"""
Return a string describing this object.
std::string Xapian::Stem::get_description() const
"""
return _xapian.Stem_get_description(*args)
Stem.__call__ = new_instancemethod(_xapian.Stem___call__,None,Stem)
Stem.__str__ = new_instancemethod(_xapian.Stem___str__,None,Stem)
Stem.get_description = new_instancemethod(_xapian.Stem_get_description,None,Stem)
Stem_swigregister = _xapian.Stem_swigregister
Stem_swigregister(Stem)
Stem_get_available_languages = _xapian.Stem_get_available_languages
class TermGenerator(object):
"""
Parses a piece of text and generate terms.
This module takes a piece of text and parses it to produce words which
are then used to generate suitable terms for indexing. The terms
generated are suitable for use with Query objects produced by the
QueryParser class.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Default constructor.
Xapian::TermGenerator::TermGenerator()
"""
_xapian.TermGenerator_swiginit(self,_xapian.new_TermGenerator(*args))
__swig_destroy__ = _xapian.delete_TermGenerator
def set_stemmer(*args):
"""
Set the Xapian::Stem object to be used for generating stemmed terms.
void Xapian::TermGenerator::set_stemmer(const Xapian::Stem &stemmer)
"""
return _xapian.TermGenerator_set_stemmer(*args)
def set_stopper(*args):
"""
Set the Xapian::Stopper object to be used for identifying stopwords.
void Xapian::TermGenerator::set_stopper(const Xapian::Stopper
*stop=NULL)
"""
return _xapian.TermGenerator_set_stopper(*args)
def set_document(*args):
"""
Set the current document.
void Xapian::TermGenerator::set_document(const Xapian::Document &doc)
"""
return _xapian.TermGenerator_set_document(*args)
def get_document(*args):
"""
Get the current document.
const Xapian::Document& Xapian::TermGenerator::get_document() const
"""
return _xapian.TermGenerator_get_document(*args)
def set_database(*args):
"""
Set the database to index spelling data to.
void Xapian::TermGenerator::set_database(const
Xapian::WritableDatabase &db)
"""
return _xapian.TermGenerator_set_database(*args)
FLAG_SPELLING = _xapian.TermGenerator_FLAG_SPELLING
def set_flags(*args):
"""
Set flags.
flags Xapian::TermGenerator::set_flags(flags toggle, flags
mask=flags(0))
The new value of flags is: (flags & mask) ^ toggle
To just set the flags, pass the new flags in toggle and the default
value for mask.
Parameters:
-----------
toggle: Flags to XOR.
mask: Flags to AND with first.
The old flags setting.
"""
return _xapian.TermGenerator_set_flags(*args)
def index_text(*args):
"""
Index some text in a std::string.
void Xapian::TermGenerator::index_text(const std::string &text,
Xapian::termcount weight=1, const std::string &prefix="")
Parameters:
-----------
weight: The wdf increment (default 1).
prefix: The term prefix to use (default is no prefix).
"""
return _xapian.TermGenerator_index_text(*args)
def index_text_without_positions(*args):
"""
Index some text in a std::string without positional information.
void Xapian::TermGenerator::index_text_without_positions(const
std::string &text, Xapian::termcount weight=1, const std::string
&prefix="")
Just like index_text, but no positional information is generated. This
means that the database will be significantly smaller, but that phrase
searching and NEAR won't be supported.
"""
return _xapian.TermGenerator_index_text_without_positions(*args)
def increase_termpos(*args):
"""
Increase the termpos used by index_text by delta.
void Xapian::TermGenerator::increase_termpos(Xapian::termcount
delta=100)
This can be used to prevent phrase searches from spanning two
unconnected blocks of text (e.g. the title and body text).
"""
return _xapian.TermGenerator_increase_termpos(*args)
def get_termpos(*args):
"""
Get the current term position.
Xapian::termcount Xapian::TermGenerator::get_termpos() const
"""
return _xapian.TermGenerator_get_termpos(*args)
def set_termpos(*args):
"""
Set the current term position.
void Xapian::TermGenerator::set_termpos(Xapian::termcount termpos)
"""
return _xapian.TermGenerator_set_termpos(*args)
def __str__(*args):
"""
Return a string describing this object.
std::string Xapian::TermGenerator::get_description() const
"""
return _xapian.TermGenerator___str__(*args)
TermGenerator.set_stemmer = new_instancemethod(_xapian.TermGenerator_set_stemmer,None,TermGenerator)
TermGenerator.set_stopper = new_instancemethod(_xapian.TermGenerator_set_stopper,None,TermGenerator)
TermGenerator.set_document = new_instancemethod(_xapian.TermGenerator_set_document,None,TermGenerator)
TermGenerator.get_document = new_instancemethod(_xapian.TermGenerator_get_document,None,TermGenerator)
TermGenerator.set_database = new_instancemethod(_xapian.TermGenerator_set_database,None,TermGenerator)
TermGenerator.set_flags = new_instancemethod(_xapian.TermGenerator_set_flags,None,TermGenerator)
TermGenerator.index_text = new_instancemethod(_xapian.TermGenerator_index_text,None,TermGenerator)
TermGenerator.index_text_without_positions = new_instancemethod(_xapian.TermGenerator_index_text_without_positions,None,TermGenerator)
TermGenerator.increase_termpos = new_instancemethod(_xapian.TermGenerator_increase_termpos,None,TermGenerator)
TermGenerator.get_termpos = new_instancemethod(_xapian.TermGenerator_get_termpos,None,TermGenerator)
TermGenerator.set_termpos = new_instancemethod(_xapian.TermGenerator_set_termpos,None,TermGenerator)
TermGenerator.__str__ = new_instancemethod(_xapian.TermGenerator___str__,None,TermGenerator)
TermGenerator_swigregister = _xapian.TermGenerator_swigregister
TermGenerator_swigregister(TermGenerator)
class Sorter(object):
"""
Virtual base class for sorter functor.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
__swig_destroy__ = _xapian.delete_Sorter
def __init__(self, *args):
if self.__class__ == Sorter:
args = (None,) + args
else:
args = (self,) + args
_xapian.Sorter_swiginit(self,_xapian.new_Sorter(*args))
def __disown__(self):
self.this.disown()
_xapian.disown_Sorter(self)
return weakref_proxy(self)
Sorter.__call__ = new_instancemethod(_xapian.Sorter___call__,None,Sorter)
Sorter_swigregister = _xapian.Sorter_swigregister
Sorter_swigregister(Sorter)
class MultiValueSorter(Sorter):
"""
Sorter subclass which sorts by a several values.
Results are ordered by the first value. In the event of a tie, the
second is used. If this is the same for both, the third is used, and
so on.
"""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args):
"""
Xapian::MultiValueSorter::MultiValueSorter(Iterator begin, Iterator
end)
"""
_xapian.MultiValueSorter_swiginit(self,_xapian.new_MultiValueSorter(*args))
def add(*args):
"""
void
Xapian::MultiValueSorter::add(Xapian::valueno valno, bool
forward=true)
"""
return _xapian.MultiValueSorter_add(*args)
__swig_destroy__ = _xapian.delete_MultiValueSorter
MultiValueSorter.add = new_instancemethod(_xapian.MultiValueSorter_add,None,MultiValueSorter)
MultiValueSorter_swigregister = _xapian.MultiValueSorter_swigregister
MultiValueSorter_swigregister(MultiValueSorter)
# Set the documentation format - this is used by tools like "epydoc" to decide
# how to format the documentation strings.
__docformat__ = "restructuredtext en"
class _SequenceMixIn(object):
"""Simple mixin class which provides a sequence API to a class.
This is used to support the legacy API to iterators used for releases of
Xapian earlier than 1.0. It will be removed once this legacy API is
removed in release 1.1.
"""
__slots__ = ('_sequence_items', )
def __init__(self, *args):
"""Initialise the sequence.
*args holds the list of properties or property names to be returned, in
the order they are returned by the sequence API.
If an item in the list is a string, it is considered to be a property
name; otherwise, it is considered to be a property value, and is
returned without doing an attribute lookup. (Yes, this is a nasty
hack. No, I don't care, because this is only a temporary piece of
internal code.)
"""
self._sequence_items = args
def __len__(self):
"""Get the length of the sequence.
Doesn't evaluate any of the lazily evaluated properties.
"""
return len(self._sequence_items)
def _get_single_item(self, index):
"""Get a single item.
Used by __getitem__ to get individual items.
"""
if not isinstance(index, basestring):
return index
return getattr(self, index)
def __getitem__(self, key):
"""Get an item, or a slice of items, from the sequence.
If any of the items are lazily evaluated properties, they will be
evaluated here.
"""
if isinstance(key, slice):
return [self._get_single_item(i) for i in self._sequence_items[key]]
return self._get_single_item(self._sequence_items[key])
def __iter__(self):
"""Make an iterator for over the sequence.
This simply copies the items into a list, and returns an iterator over
it. Any lazily evaluated properties will be evaluated here.
"""
return iter(self[:])
##################################
# Support for iteration of MSets #
##################################
class MSetItem(_SequenceMixIn):
"""An item returned from iteration of the MSet.
The item supports access to the following attributes and properties:
- `docid`: The Xapian document ID corresponding to this MSet item.
- `weight`: The weight corresponding to this MSet item.
- `rank`: The rank of this MSet item. The rank is the position in the
total set of matching documents of this item. The highest document is
given a rank of 0. If the MSet did not start at the highest matching
document, because a non-zero 'start' parameter was supplied to
get_mset(), the first document in the MSet will have a rank greater than
0 (in fact, it will be equal to the value of 'start' supplied to
get_mset()).
- `percent`: The percentage score assigned to this MSet item.
- `document`: The document for this MSet item. This can be used to access
the document data, or any other information stored in the document (such
as term lists). It is lazily evaluated.
- `collapse_key`: The value of the key which was used for collapsing.
- `collapse_count`: An estimate of the number of documents that have been
collapsed into this one.
The collapse count estimate will always be less than or equal to the actual
number of other documents satisfying the match criteria with the same
collapse key as this document. If may be 0 even though there are other
documents with the same collapse key which satisfying the match criteria.
However if this method returns non-zero, there definitely are other such
documents. So this method may be used to inform the user that there are
"at least N other matches in this group", or to control whether to offer a
"show other documents in this group" feature (but note that it may not
offer it in every case where it would show other documents).
"""
__slots__ = ('_mset', '_firstitem', 'docid', 'weight', 'rank',
'percent', 'collapse_key', 'collapse_count', '_document', )
def __init__(self, iter, mset):
self._mset = mset
self._firstitem = self._mset.get_firstitem()
self.docid = iter.get_docid()
self.weight = iter.get_weight()
self.rank = iter.get_rank()
self.percent = iter.get_percent()
self.collapse_key = iter.get_collapse_key()
self.collapse_count = iter.get_collapse_count()
self._document = None
_SequenceMixIn.__init__(self, 'docid', 'weight', 'rank', 'percent', 'document')
def _get_document(self):
if self._document is None:
self._document = self._mset._get_hit_internal(self.rank - self._firstitem).get_document()
return self._document
# Deprecated methods: to be removed in 1.1.0
def get_docid(self):
"Deprecated method: use the `docid` property instead."
return self.docid
def get_weight(self):
"Deprecated method: use the `weight` property instead."
return self.weight
def get_rank(self):
"Deprecated method: use the `rank` property instead."
return self.rank
def get_percent(self):
"Deprecated method: use the `percent` property instead."
return self.percent
def get_collapse_key(self):
"Deprecated method: use the `collapse_key` property instead."
return self.collapse_key
def get_collapse_count(self):
"Deprecated method: use the `collapse_count` property instead."
return self.collapse_count
def get_document(self):
"Deprecated method: use the `document` property instead."
return self.document
document = property(_get_document, doc="The document object corresponding to this MSet item.")
class MSetIter(object):
"""An iterator over the items in an MSet.
The iterator will return MSetItem objects, which will be evaluated lazily
where appropriate.
"""
__slots__ = ('_iter', '_end', '_mset')
def __init__(self, mset):
self._iter = mset.begin()
self._end = mset.end()
self._mset = mset
def __iter__(self):
return self
def next(self):
if self._iter == self._end:
raise StopIteration
else:
r = MSetItem(self._iter, self._mset)
self._iter.next()
return r
# Modify the MSet to allow access to the python iterators, and have other
# convenience methods.
def _mset_gen_iter(self):
"""Return an iterator over the MSet.
The iterator will return MSetItem objects, which will be evaluated lazily
where appropriate.
"""
return MSetIter(self)
MSet.__iter__ = _mset_gen_iter
MSet.__len__ = MSet.size
# We replace the get_hit() method with one which returns an MSetItem. We first
# have to copy the internal method, so that we can call it.
MSet._get_hit_internal = MSet.get_hit
def _mset_getitem(self, index):
"""Get an item from the MSet.
The supplied index is relative to the start of the MSet, not the absolute
rank of the item.
Returns an MSetItem.
"""
if index < 0:
index += len(self)
if index < 0 or index >= len(self):
raise IndexError("Mset index out of range")
return MSetItem(self._get_hit_internal(index), self)
MSet.__getitem__ = _mset_getitem
MSet.get_hit = _mset_getitem
def _mset_contains(self, index):
"""Check if the Mset contains an item at the given index
The supplied index is relative to the start of the MSet, not the absolute
rank of the item.
"""
return key >= 0 and key < len(self)
MSet.__contains__ = _mset_contains
##################################
# Support for iteration of ESets #
##################################
class ESetItem(_SequenceMixIn):
"""An item returned from iteration of the ESet.
The item supports access to the following attributes:
- `term`: The term corresponding to this ESet item.
- `weight`: The weight corresponding to this ESet item.
"""
__slots__ = ('term', 'weight')
def __init__(self, iter):
self.term = iter.get_term()
self.weight = iter.get_weight()
_SequenceMixIn.__init__(self, 'term', 'weight')
class ESetIter(object):
"""An iterator over the items in an ESet.
The iterator will return ESetItem objects.
"""
__slots__ = ('_iter', '_end')
def __init__(self, eset):
self._iter = eset.begin()
self._end = eset.end()
def __iter__(self):
return self
def next(self):
if self._iter == self._end:
raise StopIteration
else:
r = ESetItem(self._iter)
self._iter.next()
return r
# Modify the ESet to allow access to the python iterators, and have other
# convenience methods.
def _eset_gen_iter(self):
"""Return an iterator over the ESet.
The iterator will return ESetItem objects.
"""
return ESetIter(self)
ESet.__iter__ = _eset_gen_iter
ESet.__len__ = ESet.size
#######################################
# Support for iteration of term lists #
#######################################
class TermListItem(_SequenceMixIn):
"""An item returned from iteration of a term list.
The item supports access to the following attributes and properties:
- `term`: The term corresponding to this TermListItem.
- `wdf`: The within document frequency of this term.
- `termfreq`: The number of documents in the collection which are indexed
by the term
- `positer`: An iterator over the positions which the term appears at in
the document. This is only available until the iterator which returned
this item next moves.
"""
__slots__ = ('_iter', 'term', '_wdf', '_termfreq')
def __init__(self, iter, term):
self._iter = iter
self.term = term
self._wdf = None
self._termfreq = None
if iter._has_wdf == TermIter.EAGER:
self._wdf = iter._iter.get_wdf()
if iter._has_termfreq == TermIter.EAGER:
self._termfreq = iter._iter.get_termfreq()
# Support for sequence API
sequence = ['term', 'wdf', 'termfreq', 'positer']
if iter._has_wdf == TermIter.INVALID:
sequence[1] = 0
if iter._has_termfreq == TermIter.INVALID:
sequence[2] = 0
if iter._has_positions == TermIter.INVALID:
sequence[3] = PositionIter()
_SequenceMixIn.__init__(self, *sequence)
def _get_wdf(self):
"""Get the within-document-frequency of the current term.
This will raise a InvalidOperationError exception if the iterator this
item came from doesn't support within-document-frequencies.
"""
if self._wdf is None:
if self._iter._has_wdf == TermIter.INVALID:
raise InvalidOperationError("Iterator does not support wdfs")
if self.term is not self._iter._lastterm:
raise InvalidOperationError("Iterator has moved, and does not support random access")
self._wdf = self._iter._iter.get_wdf()
return self._wdf
wdf = property(_get_wdf, doc=
"""The within-document-frequency of the current term (if meaningful).
This will raise a InvalidOperationError exception if the iterator
this item came from doesn't support within-document-frequencies.
""")
def _get_termfreq(self):
"""Get the term frequency.
This is the number of documents in the collection which are indexed by
the term.
This will raise a InvalidOperationError exception if the iterator this
item came from doesn't support term frequencies.
"""
if self._termfreq is None:
if self._iter._has_termfreq == TermIter.INVALID:
raise InvalidOperationError("Iterator does not support term frequencies")
if self.term is not self._iter._lastterm:
raise InvalidOperationError("Iterator has moved, and does not support random access")
self._termfreq = self._iter._iter.get_termfreq()
return self._termfreq
termfreq = property(_get_termfreq, doc=
"""The term frequency of the current term (if meaningful).
This is the number of documents in the collection which are indexed by the
term.
This will raise a InvalidOperationError exception if the iterator
this item came from doesn't support term frequencies.
""")
def _get_positer(self):
"""Get a position list iterator.
The iterator will return integers representing the positions that the
term occurs at.
This will raise a InvalidOperationError exception if the iterator this
item came from doesn't support position lists, or if the iterator has
moved on since the item was returned from it.
"""
if self._iter._has_positions == TermIter.INVALID:
raise InvalidOperationError("Iterator does not support position lists")
# Access to position lists is always lazy, so we don't need to check
# _has_positions.
if self.term is not self._iter._lastterm:
raise InvalidOperationError("Iterator has moved, and does not support random access")
return PositionIter(self._iter._iter.positionlist_begin(),
self._iter._iter.positionlist_end())
positer = property(_get_positer, doc=
"""A position iterator for the current term (if meaningful).
The iterator will return integers representing the positions that the term
occurs at.
This will raise a InvalidOperationError exception if the iterator this item
came from doesn't support position lists, or if the iterator has moved on
since the item was returned from it.
""")
class TermIter(object):
"""An iterator over a term list.
The iterator will return TermListItem objects, which will be evaluated
lazily where appropriate.
"""
__slots__ = ('_iter', '_end', '_has_termfreq', '_has_wdf',
'_has_positions', '_return_strings', '_lastterm', '_moved')
INVALID = 0
LAZY = 1
EAGER = 2
def __init__(self, start, end, has_termfreq=INVALID,
has_wdf=INVALID, has_positions=INVALID,
return_strings=False):
self._iter = start
self._end = end
self._has_termfreq = has_termfreq
self._has_wdf = has_wdf
self._has_positions = has_positions
assert(has_positions != TermIter.EAGER) # Can't do eager access to position lists
self._return_strings = return_strings
self._lastterm = None # Used to test if the iterator has moved
# _moved is True if we've moved onto the next item. This is needed so
# that the iterator doesn't have to move on until just before next() is
# called: since the iterator starts by pointing at a valid item, we
# can't just call self._iter.next() unconditionally at the start of our
# next() method.
self._moved = True
def __iter__(self):
return self
def next(self):
if not self._moved:
self._iter.next()
self._moved = True
if self._iter == self._end:
self._lastterm = None
raise StopIteration
else:
self._lastterm = self._iter.get_term()
self._moved = False
if self._return_strings:
return self._lastterm
return TermListItem(self, self._lastterm)
def skip_to(self, term):
"""Skip the iterator forward.
The iterator is advanced to the first term at or after the current
position which is greater than or equal to the supplied term.
If there are no such items, this will raise StopIteration.
This returns the item which the iterator is moved to. The subsequent
item will be returned the next time that next() is called (unless
skip_to() is called again first).
"""
if self._iter != self._end:
self._iter.skip_to(term)
if self._iter == self._end:
self._lastterm = None
self._moved = True
raise StopIteration
# Update self._lastterm if the iterator has moved.
# TermListItems compare a saved value of lastterm with self._lastterm
# with the object identity comparator, so it is important to ensure
# that it does not get modified if the new term compares equal.
newterm = self._iter.get_term()
if newterm != self._lastterm:
self._lastterm = newterm
self._moved = False
if self._return_strings:
return self._lastterm
return TermListItem(self, self._lastterm)
# Modify Enquire to add a "matching_terms()" method.
def _enquire_gen_iter(self, which):
"""Get an iterator over the terms which match a given match set item.
The match set item to consider is specified by the `which` parameter, which
may be a document ID, or an MSetItem object.
The iterator will return string objects.
"""
if isinstance(which, MSetItem):
which = which.docid
return TermIter(self.get_matching_terms_begin(which),
self.get_matching_terms_end(which),
return_strings=True)
Enquire.matching_terms = _enquire_gen_iter
# get_matching_terms() is deprecated, but does just the same as
# matching_terms()
Enquire.get_matching_terms = _enquire_gen_iter
# Modify Query to add an "__iter__()" method.
def _query_gen_iter(self):
"""Get an iterator over the terms in a query.
The iterator will return string objects.
"""
return TermIter(self.get_terms_begin(),
self.get_terms_end(),
return_strings=True)
Query.__iter__ = _query_gen_iter
# Modify Database to add an "__iter__()" method and an "allterms()" method.
def _database_gen_allterms_iter(self, prefix=None):
"""Get an iterator over all the terms in the database.
The iterator will return TermListItem objects, but these will not support
access to wdf, or position information.
Access to term frequency information is only available until the iterator
has moved on.
If prefix is supplied, only terms which start with that prefix will be
returned.
"""
if prefix is None:
return TermIter(self.allterms_begin(), self.allterms_end(),
has_termfreq=TermIter.LAZY)
else:
return TermIter(self.allterms_begin(prefix), self.allterms_end(prefix),
has_termfreq=TermIter.LAZY)
Database.__iter__ = _database_gen_allterms_iter
Database.allterms = _database_gen_allterms_iter
# Modify Database to add a "termlist()" method.
def _database_gen_termlist_iter(self, docid):
"""Get an iterator over all the terms which index a given document ID.
The iterator will return TermListItem objects.
Access to term frequency and position information is only available until
the iterator has moved on.
"""
# Note: has_termfreq is set to LAZY because most databases don't store term
# frequencies in the termlist (because this would require updating many termlist
# entries for every document update), so access to the term frequency requires a
# separate lookup.
return TermIter(self.termlist_begin(docid), self.termlist_end(docid),
has_termfreq=TermIter.LAZY,
has_wdf=TermIter.EAGER,
has_positions=TermIter.LAZY)
Database.termlist = _database_gen_termlist_iter
# Modify Database to add a "spellings()" method.
def _database_gen_spellings_iter(self):
"""Get an iterator which returns all the spelling correction targets
The iterator will return TermListItem objects. Only the term frequency is
available; wdf and positions are not meaningful.
"""
return TermIter(self.spellings_begin(), self.spellings_end(),
has_termfreq=TermIter.EAGER,
has_wdf=TermIter.INVALID,
has_positions=TermIter.INVALID)
Database.spellings = _database_gen_spellings_iter
# Modify Database to add a "synonyms()" method.
def _database_gen_synonyms_iter(self, term):
"""Get an iterator which returns all the synonyms for a given term.
The term to return synonyms for is specified by the `term` parameter.
The iterator will return string objects.
"""
return TermIter(self.synonyms_begin(term),
self.synonyms_end(term),
return_strings=True)
Database.synonyms = _database_gen_synonyms_iter
# Modify Database to add a "synonym_keys()" method.
def _database_gen_synonym_keys_iter(self, prefix=""):
"""Get an iterator which returns all the terms which have synonyms.
The iterator will return string objects.
If `prefix` is non-empty, only terms with this prefix are returned.
"""
return TermIter(self.synonym_keys_begin(prefix),
self.synonym_keys_end(prefix),
return_strings=True)
Database.synonym_keys = _database_gen_synonym_keys_iter
# Modify Document to add an "__iter__()" method and a "termlist()" method.
def _document_gen_termlist_iter(self):
"""Get an iterator over all the terms in a document.
The iterator will return TermListItem objects.
Access to term frequency and position information is only available until
the iterator has moved on.
Note that term frequency information is only meaningful for a document
retrieved from a database. If term frequency information is requested for
a document which was freshly created, an InvalidOperationError will be
raised.
"""
# Note: document termlist iterators may be implemented entirely in-memory
# (in which case access to all items could be allowed eagerly), but may
# also be implemented by returning a database termlist (for documents which
# are stored in a database, rather than freshly created). We choose the
# most conservative settings, to avoid doing eager access when lazy access
# would be more appropriate.
return TermIter(self.termlist_begin(), self.termlist_end(),
has_termfreq=TermIter.LAZY,
has_wdf=TermIter.EAGER,
has_positions=TermIter.LAZY)
Document.__iter__ = _document_gen_termlist_iter
Document.termlist = _document_gen_termlist_iter
# Modify QueryParser to add a "stoplist()" method.
def _queryparser_gen_stoplist_iter(self):
"""Get an iterator over all the stopped terms from the previous query.
This returns an iterator over all the terms which were omitted from the
previously parsed query due to being considered to be stopwords. Each
instance of a word omitted from the query is represented in the returned
list, in the order in which the
The iterator will return string objects.
"""
return TermIter(self.stoplist_begin(), self.stoplist_end(),
return_strings=True)
QueryParser.stoplist = _queryparser_gen_stoplist_iter
# Modify QueryParser to add an "unstemlist()" method.
def _queryparser_gen_unstemlist_iter(self, tname):
"""Get an iterator over all the unstemmed forms of a stemmed term.
This returns an iterator which returns all the unstemmed words which were
stemmed to the stemmed form specifed by `tname` when parsing the previous
query. Each instance of a word which stems to `tname` is returned by the
iterator in the order in which the words appeared in the query - an
individual unstemmed word may thus occur multiple times.
The iterator will return string objects.
"""
return TermIter(self.unstem_begin(tname), self.unstem_end(tname),
return_strings=True)
QueryParser.unstemlist = _queryparser_gen_unstemlist_iter
##########################################
# Support for iteration of posting lists #
##########################################
class PostingItem(_SequenceMixIn):
"""An item returned from iteration of a posting list.
The item supports access to the following attributes and properties:
- `docid`: The document ID corresponding to this PostingItem.
- `doclength`: The length of the document corresponding to this
PostingItem.
- `wdf`: The within document frequency of the term which the posting list
is for in the document corresponding to this PostingItem.
- `positer`: An iterator over the positions which the term corresponing to
this posting list occurs at in the document corresponding to this
PostingItem. This is only available until the iterator which returned
this item next moves.
"""
__slots__ = ('_iter', 'docid', 'doclength', 'wdf',)
def __init__(self, iter):
self._iter = iter
self.docid = iter._iter.get_docid()
self.doclength = iter._iter.get_doclength()
self.wdf = iter._iter.get_wdf()
# Support for sequence API
sequence = ['docid', 'doclength', 'wdf', 'positer']
if not iter._has_positions:
sequence[3] = PositionIter()
_SequenceMixIn.__init__(self, *sequence)
def _get_positer(self):
"""Get a position list iterator.
The iterator will return integers representing the positions that the
term occurs at in the document corresponding to this PostingItem.
This will raise a InvalidOperationError exception if the iterator this
item came from doesn't support position lists, or if the iterator has
moved on since the item was returned from it.
"""
if not self._iter._has_positions:
raise InvalidOperationError("Iterator does not support position lists")
if self._iter._iter == self._iter._end or \
self.docid != self._iter._iter.get_docid():
raise InvalidOperationError("Iterator has moved, and does not support random access")
return PositionIter(self._iter._iter.positionlist_begin(),
self._iter._iter.positionlist_end())
positer = property(_get_positer, doc=
"""A position iterator for the current posting (if meaningful).
The iterator will return integers representing the positions that the term
occurs at.
This will raise a InvalidOperationError exception if the iterator this item
came from doesn't support position lists, or if the iterator has moved on
since the item was returned from it.
""")
class PostingIter(object):
"""An iterator over a posting list.
The iterator will return PostingItem objects, which will be evaluated
lazily where appropriate.
"""
__slots__ = ('_iter', '_end', '_has_positions', '_moved')
def __init__(self, start, end, has_positions=False):
self._iter = start
self._end = end
self._has_positions = has_positions
# _moved is True if we've moved onto the next item. This is needed so
# that the iterator doesn't have to move on until just before next() is
# called: since the iterator starts by pointing at a valid item, we
# can't just call self._iter.next() unconditionally at the start of our
# next() method.
self._moved = True
def __iter__(self):
return self
def next(self):
if not self._moved:
self._iter.next()
self._moved = True
if self._iter == self._end:
raise StopIteration
else:
self._moved = False
return PostingItem(self)
def skip_to(self, docid):
"""Skip the iterator forward.
The iterator is advanced to the first document with a document ID
which is greater than or equal to the supplied document ID.
If there are no such items, this will raise StopIteration.
This returns the item which the iterator is moved to. The subsequent
item will be returned the next time that next() is called (unless
skip_to() is called again first).
"""
if self._iter != self._end:
self._iter.skip_to(docid)
if self._iter == self._end:
self._moved = True
raise StopIteration
self._moved = False
return PostingItem(self)
def _database_gen_postlist_iter(self, tname):
"""Get an iterator over the postings which are indexed by a given term.
If `tname` is empty, an iterator over all the documents will be returned
(this will contain one entry for each document, will always return a wdf of
1, and will not allow access to a position iterator).
"""
if len(tname) != 0:
return PostingIter(self.postlist_begin(tname), self.postlist_end(tname),
has_positions=True)
else:
return PostingIter(self.postlist_begin(tname), self.postlist_end(tname))
Database.postlist = _database_gen_postlist_iter
###########################################
# Support for iteration of position lists #
###########################################
class PositionIter(object):
"""An iterator over a position list.
The iterator will return integers, in ascending order.
"""
def __init__(self, start = 0, end = 0):
self.iter = start
self.end = end
def __iter__(self):
return self
def next(self):
if self.iter==self.end:
raise StopIteration
else:
r = self.iter.get_termpos()
self.iter.next()
return r
# Modify Database to add a "positionlist()" method.
def _database_gen_positionlist_iter(self, docid, tname):
"""Get an iterator over all the positions in a given document of a term.
The iterator will return integers, in ascending order.
"""
return PositionIter(self.positionlist_begin(docid, tname), self.positionlist_end(docid, tname))
Database.positionlist = _database_gen_positionlist_iter
########################################
# Support for iteration of value lists #
########################################
class ValueItem(_SequenceMixIn):
"""An item returned from iteration of the values in a document.
The item supports access to the following attributes:
- `num`: The number of the value.
- `value`: The contents of the value.
"""
__slots__ = ('num', 'value', )
def __init__(self, num, value):
self.num = num
self.value = value
_SequenceMixIn.__init__(self, 'num', 'value')
class ValueIter(object):
"""An iterator over all the values stored in a document.
The iterator will return ValueItem objects, in ascending order of value number.
"""
def __init__(self, start, end):
self.iter = start
self.end = end
def __iter__(self):
return self
def next(self):
if self.iter==self.end:
raise StopIteration
else:
r = ValueItem(self.iter.get_valueno(), self.iter.get_value())
self.iter.next()
return r
# Modify Document to add a "values()" method.
def _document_gen_values_iter(self):
"""Get an iterator over all the values stored in a document.
The iterator will return ValueItem objects, in ascending order of value number.
"""
return ValueIter(self.values_begin(), self.values_end())
Document.values = _document_gen_values_iter
# Set the list of names which should be public.
# Note that this needs to happen at the end of xapian.py.
__all__ = []
for item in dir():
if item.startswith('_') or item.endswith('_swigregister') or item.endswith('Iterator'):
continue
__all__.append(item)
__all__ = tuple(__all__)
# Fix up ValueRangeProcessor by replacing its __call__ method (which doesn't
# work) with its __call() method (which we define with an %extend in util.i)
ValueRangeProcessor.__call__ = ValueRangeProcessor.__call
|