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 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405
|
# coding: utf-8
# (C) Copyright IBM Corp. 2019, 2024.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029
"""
IBM Watson® Discovery is a cognitive search and content analytics engine that you can
add to applications to identify patterns, trends and actionable insights to drive better
decision-making. Securely unify structured and unstructured data with pre-enriched
content, and use a simplified query language to eliminate the need for manual filtering of
results.
API Version: 2.0
See: https://cloud.ibm.com/docs/discovery-data
"""
from datetime import datetime
from enum import Enum
from os.path import basename
from typing import BinaryIO, Dict, List, Optional
import json
import sys
from ibm_cloud_sdk_core import BaseService, DetailedResponse
from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment
from ibm_cloud_sdk_core.utils import convert_list, convert_model, datetime_to_string, string_to_datetime
from .common import get_sdk_headers
##############################################################################
# Service
##############################################################################
class DiscoveryV2(BaseService):
"""The Discovery V2 service."""
DEFAULT_SERVICE_URL = 'https://api.us-south.discovery.watson.cloud.ibm.com'
DEFAULT_SERVICE_NAME = 'discovery'
def __init__(
self,
version: str,
authenticator: Authenticator = None,
service_name: str = DEFAULT_SERVICE_NAME,
) -> None:
"""
Construct a new client for the Discovery service.
:param str version: Release date of the version of the API you want to use.
Specify dates in YYYY-MM-DD format. The current version is `2023-03-31`.
:param Authenticator authenticator: The authenticator specifies the authentication mechanism.
Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
about initializing the authenticator of your choice.
"""
if version is None:
raise ValueError('version must be provided')
if not authenticator:
authenticator = get_authenticator_from_environment(service_name)
BaseService.__init__(self,
service_url=self.DEFAULT_SERVICE_URL,
authenticator=authenticator)
self.version = version
self.configure_service(service_name)
#########################
# Projects
#########################
def list_projects(
self,
**kwargs,
) -> DetailedResponse:
"""
List projects.
Lists existing projects for this instance.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListProjectsResponse` object
"""
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_projects',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
url = '/v2/projects'
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_project(
self,
name: str,
type: str,
*,
default_query_parameters: Optional['DefaultQueryParams'] = None,
**kwargs,
) -> DetailedResponse:
"""
Create a project.
Create a new project for this instance.
:param str name: The human readable name of this project.
:param str type: The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts*
project and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with
Premium plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from
IBM Cloud-managed instances only.
:param DefaultQueryParams default_query_parameters: (optional) Default
query parameters for this project.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ProjectDetails` object
"""
if name is None:
raise ValueError('name must be provided')
if type is None:
raise ValueError('type must be provided')
if default_query_parameters is not None:
default_query_parameters = convert_model(default_query_parameters)
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_project',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
'type': type,
'default_query_parameters': default_query_parameters,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
url = '/v2/projects'
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def get_project(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get project.
Get details on the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ProjectDetails` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_project',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}'.format(**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_project(
self,
project_id: str,
*,
name: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Update a project.
Update the specified project's name.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str name: (optional) The new name to give this project.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ProjectDetails` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_project',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}'.format(**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_project(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete a project.
Deletes the specified project.
**Important:** Deleting a project deletes everything that is part of the specified
project, including all collections.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_project',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}'.format(**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def list_fields(
self,
project_id: str,
*,
collection_ids: Optional[List[str]] = None,
**kwargs,
) -> DetailedResponse:
"""
List fields.
Gets a list of the unique fields (and their types) stored in the specified
collections.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param List[str] collection_ids: (optional) Comma separated list of the
collection IDs. If this parameter is not specified, all collections in the
project are used.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListFieldsResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_fields',
)
headers.update(sdk_headers)
params = {
'version': self.version,
'collection_ids': convert_list(collection_ids),
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/fields'.format(**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Collections
#########################
def list_collections(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
List collections.
Lists existing collections for the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListCollectionsResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_collections',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections'.format(**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_collection(
self,
project_id: str,
name: str,
*,
description: Optional[str] = None,
language: Optional[str] = None,
ocr_enabled: Optional[bool] = None,
enrichments: Optional[List['CollectionEnrichment']] = None,
**kwargs,
) -> DetailedResponse:
"""
Create a collection.
Create a new collection in the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str name: The name of the collection.
:param str description: (optional) A description of the collection.
:param str language: (optional) The language of the collection. For a list
of supported languages, see the [product
documentation](/docs/discovery-data?topic=discovery-data-language-support).
:param bool ocr_enabled: (optional) If set to `true`, optical character
recognition (OCR) is enabled. For more information, see [Optical character
recognition](/docs/discovery-data?topic=discovery-data-collections#ocr).
:param List[CollectionEnrichment] enrichments: (optional) An array of
enrichments that are applied to this collection. To get a list of
enrichments that are available for a project, use the [List
enrichments](#listenrichments) method.
If no enrichments are specified when the collection is created, the default
enrichments for the project type are applied. For more information about
project default settings, see the [product
documentation](/docs/discovery-data?topic=discovery-data-project-defaults).
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `CollectionDetails` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if name is None:
raise ValueError('name must be provided')
if enrichments is not None:
enrichments = [convert_model(x) for x in enrichments]
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_collection',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
'description': description,
'language': language,
'ocr_enabled': ocr_enabled,
'enrichments': enrichments,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections'.format(**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def get_collection(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get collection details.
Get details about the specified collection.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `CollectionDetails` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_collection',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_collection(
self,
project_id: str,
collection_id: str,
*,
name: Optional[str] = None,
description: Optional[str] = None,
ocr_enabled: Optional[bool] = None,
enrichments: Optional[List['CollectionEnrichment']] = None,
**kwargs,
) -> DetailedResponse:
"""
Update a collection.
Updates the specified collection's name, description, enrichments, and
configuration.
If you apply normalization rules to data in an existing collection, you must
initiate reprocessing of the collection. To do so, from the *Manage fields* page
in the product user interface, temporarily change the data type of a field to
enable the reprocess button. Change the data type of the field back to its
original value, and then click **Apply changes and reprocess**.
To remove a configuration that applies JSON normalization operations as part of
the conversion phase of ingestion, specify an empty `json_normalizations` object
(`[]`) in the request.
To remove a configuration that applies JSON normalization operations after
enrichments are applied, specify an empty `normalizations` object (`[]`) in the
request.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str name: (optional) The new name of the collection.
:param str description: (optional) The new description of the collection.
:param bool ocr_enabled: (optional) If set to `true`, optical character
recognition (OCR) is enabled. For more information, see [Optical character
recognition](/docs/discovery-data?topic=discovery-data-collections#ocr).
:param List[CollectionEnrichment] enrichments: (optional) An array of
enrichments that are applied to this collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `CollectionDetails` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if enrichments is not None:
enrichments = [convert_model(x) for x in enrichments]
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_collection',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
'description': description,
'ocr_enabled': ocr_enabled,
'enrichments': enrichments,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_collection(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete a collection.
Deletes the specified collection from the project. All documents stored in the
specified collection and not shared is also deleted.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_collection',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Documents
#########################
def list_documents(
self,
project_id: str,
collection_id: str,
*,
count: Optional[int] = None,
status: Optional[str] = None,
has_notices: Optional[bool] = None,
is_parent: Optional[bool] = None,
parent_document_id: Optional[str] = None,
sha256: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
List documents.
Lists the documents in the specified collection. The list includes only the
document ID of each document and returns information for up to 10,000 documents.
**Note**: This method is available only from Cloud Pak for Data version 4.0.9 and
later installed instances, and from IBM Cloud-managed instances.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param int count: (optional) The maximum number of documents to return. Up
to 1,000 documents are returned by default. The maximum number allowed is
10,000.
:param str status: (optional) Filters the documents to include only
documents with the specified ingestion status. The options include:
* `available`: Ingestion is finished and the document is indexed.
* `failed`: Ingestion is finished, but the document is not indexed because
of an error.
* `pending`: The document is uploaded, but the ingestion process is not
started.
* `processing`: Ingestion is in progress.
You can specify one status value or add a comma-separated list of more than
one status value. For example, `available,failed`.
:param bool has_notices: (optional) If set to `true`, only documents that
have notices, meaning documents for which warnings or errors were generated
during the ingestion, are returned. If set to `false`, only documents that
don't have notices are returned. If unspecified, no filter based on notices
is applied.
Notice details are not available in the result, but you can use the [Query
collection notices](#querycollectionnotices) method to find details by
adding the parameter `query=notices.document_id:{document-id}`.
:param bool is_parent: (optional) If set to `true`, only parent documents,
meaning documents that were split during the ingestion process and resulted
in two or more child documents, are returned. If set to `false`, only child
documents are returned. If unspecified, no filter based on the parent or
child relationship is applied.
CSV files, for example, are split into separate documents per line and JSON
files are split into separate documents per object.
:param str parent_document_id: (optional) Filters the documents to include
only child documents that were generated when the specified parent document
was processed.
:param str sha256: (optional) Filters the documents to include only
documents with the specified SHA-256 hash. Format the hash as a hexadecimal
string.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListDocumentsResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_documents',
)
headers.update(sdk_headers)
params = {
'version': self.version,
'count': count,
'status': status,
'has_notices': has_notices,
'is_parent': is_parent,
'parent_document_id': parent_document_id,
'sha256': sha256,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/documents'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def add_document(
self,
project_id: str,
collection_id: str,
*,
file: Optional[BinaryIO] = None,
filename: Optional[str] = None,
file_content_type: Optional[str] = None,
metadata: Optional[str] = None,
x_watson_discovery_force: Optional[bool] = None,
**kwargs,
) -> DetailedResponse:
"""
Add a document.
Add a document to a collection with optional metadata.
Returns immediately after the system has accepted the document for processing.
Use this method to upload a file to the collection. You cannot use this method to
crawl an external data source.
* For a list of supported file types, see the [product
documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes).
* You must provide document content, metadata, or both. If the request is missing
both document content and metadata, it is rejected.
* You can set the **Content-Type** parameter on the **file** part to indicate
the media type of the document. If the **Content-Type** parameter is missing or is
one of the generic media types (for example, `application/octet-stream`), then the
service attempts to automatically detect the document's media type.
* If the document is uploaded to a collection that shares its data with another
collection, the **X-Watson-Discovery-Force** header must be set to `true`.
* In curl requests only, you can assign an ID to a document that you add by
appending the ID to the endpoint
(`/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}`).
If a document already exists with the specified ID, it is replaced.
For more information about how certain file types and field names are handled when
a file is added to a collection, see the [product
documentation](/docs/discovery-data?topic=discovery-data-index-overview#field-name-limits).
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param BinaryIO file: (optional) **Add a document**: The content of the
document to ingest. For the supported file types and maximum supported file
size limits when adding a document, see [the
documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes).
**Analyze a document**: The content of the document to analyze but not
ingest. Only the `application/json` content type is supported by the
Analyze API. For maximum supported file size limits, see [the product
documentation](/docs/discovery-data?topic=discovery-data-analyzeapi#analyzeapi-limits).
:param str filename: (optional) The filename for file.
:param str file_content_type: (optional) The content type of file.
:param str metadata: (optional) Add information about the file that you
want to include in the response.
The maximum supported metadata file size is 1 MB. Metadata parts larger
than 1 MB are rejected.
Example:
```
{
"filename": "favorites2.json",
"file_type": "json"
}.
:param bool x_watson_discovery_force: (optional) When `true`, the uploaded
document is added to the collection even if the data for that collection is
shared with other collections.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentAccepted` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {
'X-Watson-Discovery-Force': x_watson_discovery_force,
}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='add_document',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
if file:
if not filename and hasattr(file, 'name'):
filename = basename(file.name)
if not filename:
raise ValueError('filename must be provided')
form_data.append(('file', (filename, file, file_content_type or
'application/octet-stream')))
if metadata:
form_data.append(('metadata', (None, metadata, 'text/plain')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/documents'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
def get_document(
self,
project_id: str,
collection_id: str,
document_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get document details.
Get details about a specific document, whether the document is added by uploading
a file or by crawling an external data source.
**Note**: This method is available only from Cloud Pak for Data version 4.0.9 and
later installed instances, and from IBM Cloud-managed instances.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str document_id: The ID of the document.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentDetails` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if not document_id:
raise ValueError('document_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_document',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id', 'document_id']
path_param_values = self.encode_path_vars(project_id, collection_id,
document_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_document(
self,
project_id: str,
collection_id: str,
document_id: str,
*,
file: Optional[BinaryIO] = None,
filename: Optional[str] = None,
file_content_type: Optional[str] = None,
metadata: Optional[str] = None,
x_watson_discovery_force: Optional[bool] = None,
**kwargs,
) -> DetailedResponse:
"""
Update a document.
Replace an existing document or add a document with a specified document ID.
Starts ingesting a document with optional metadata.
Use this method to upload a file to a collection. You cannot use this method to
crawl an external data source.
If the document is uploaded to a collection that shares its data with another
collection, the **X-Watson-Discovery-Force** header must be set to `true`.
**Notes:**
* Uploading a new document with this method automatically replaces any existing
document stored with the same document ID.
* If an uploaded document is split into child documents during ingestion, all
existing child documents are overwritten, even if the updated version of the
document has fewer child documents.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str document_id: The ID of the document.
:param BinaryIO file: (optional) **Add a document**: The content of the
document to ingest. For the supported file types and maximum supported file
size limits when adding a document, see [the
documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes).
**Analyze a document**: The content of the document to analyze but not
ingest. Only the `application/json` content type is supported by the
Analyze API. For maximum supported file size limits, see [the product
documentation](/docs/discovery-data?topic=discovery-data-analyzeapi#analyzeapi-limits).
:param str filename: (optional) The filename for file.
:param str file_content_type: (optional) The content type of file.
:param str metadata: (optional) Add information about the file that you
want to include in the response.
The maximum supported metadata file size is 1 MB. Metadata parts larger
than 1 MB are rejected.
Example:
```
{
"filename": "favorites2.json",
"file_type": "json"
}.
:param bool x_watson_discovery_force: (optional) When `true`, the uploaded
document is added to the collection even if the data for that collection is
shared with other collections.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentAccepted` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if not document_id:
raise ValueError('document_id must be provided')
headers = {
'X-Watson-Discovery-Force': x_watson_discovery_force,
}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_document',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
if file:
if not filename and hasattr(file, 'name'):
filename = basename(file.name)
if not filename:
raise ValueError('filename must be provided')
form_data.append(('file', (filename, file, file_content_type or
'application/octet-stream')))
if metadata:
form_data.append(('metadata', (None, metadata, 'text/plain')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id', 'document_id']
path_param_values = self.encode_path_vars(project_id, collection_id,
document_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
def delete_document(
self,
project_id: str,
collection_id: str,
document_id: str,
*,
x_watson_discovery_force: Optional[bool] = None,
**kwargs,
) -> DetailedResponse:
"""
Delete a document.
Deletes the document with the document ID that you specify from the collection.
Removes uploaded documents from the collection permanently. If you delete a
document that was added by crawling an external data source, the document will be
added again with the next scheduled crawl of the data source. The delete function
removes the document from the collection, not from the external data source.
**Note:** Files such as CSV or JSON files generate subdocuments when they are
added to a collection. If you delete a subdocument, and then repeat the action
that created it, the deleted document is added back in to your collection. To
remove subdocuments that are generated by an uploaded file, delete the original
document instead. You can get the document ID of the original document from the
`parent_document_id` of the subdocument result.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str document_id: The ID of the document.
:param bool x_watson_discovery_force: (optional) When `true`, the uploaded
document is added to the collection even if the data for that collection is
shared with other collections.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DeleteDocumentResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if not document_id:
raise ValueError('document_id must be provided')
headers = {
'X-Watson-Discovery-Force': x_watson_discovery_force,
}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_document',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id', 'document_id']
path_param_values = self.encode_path_vars(project_id, collection_id,
document_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Queries
#########################
def query(
self,
project_id: str,
*,
collection_ids: Optional[List[str]] = None,
filter: Optional[str] = None,
query: Optional[str] = None,
natural_language_query: Optional[str] = None,
aggregation: Optional[str] = None,
count: Optional[int] = None,
return_: Optional[List[str]] = None,
offset: Optional[int] = None,
sort: Optional[str] = None,
highlight: Optional[bool] = None,
spelling_suggestions: Optional[bool] = None,
table_results: Optional['QueryLargeTableResults'] = None,
suggested_refinements: Optional[
'QueryLargeSuggestedRefinements'] = None,
passages: Optional['QueryLargePassages'] = None,
similar: Optional['QueryLargeSimilar'] = None,
**kwargs,
) -> DetailedResponse:
"""
Query a project.
Search your data by submitting queries that are written in natural language or
formatted in the Discovery Query Language. For more information, see the
[Discovery
documentation](/docs/discovery-data?topic=discovery-data-query-concepts). The
default query parameters differ by project type. For more information about the
project default settings, see the [Discovery
documentation](/docs/discovery-data?topic=discovery-data-query-defaults). See [the
Projects API documentation](#create-project) for details about how to set custom
default query settings.
The length of the UTF-8 encoding of the POST body cannot exceed 10,000 bytes,
which is roughly equivalent to 10,000 characters in English.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param List[str] collection_ids: (optional) A comma-separated list of
collection IDs to be queried against.
:param str filter: (optional) Searches for documents that match the
Discovery Query Language criteria that is specified as input. Filter calls
are cached and are faster than query calls because the results are not
ordered by relevance. When used with the **aggregation**, **query**, or
**natural_language_query** parameters, the **filter** parameter runs first.
This parameter is useful for limiting results to those that contain
specific metadata values.
:param str query: (optional) A query search that is written in the
Discovery Query Language and returns all matching documents in your data
set with full enrichments and full text, and with the most relevant
documents listed first. Use a query search when you want to find the most
relevant search results. You can use this parameter or the
**natural_language_query** parameter to specify the query input, but not
both.
:param str natural_language_query: (optional) A natural language query that
returns relevant documents by using training data and natural language
understanding. You can use this parameter or the **query** parameter to
specify the query input, but not both. To filter the results based on
criteria you specify, include the **filter** parameter in the request.
:param str aggregation: (optional) An aggregation search that returns an
exact answer by combining query search with filters. Useful for
applications to build lists, tables, and time series. For more information
about the supported types of aggregations, see the [Discovery
documentation](/docs/discovery-data?topic=discovery-data-query-aggregations).
:param int count: (optional) Number of results to return.
:param List[str] return_: (optional) A list of the fields in the document
hierarchy to return. You can specify both root-level (`text`) and nested
(`extracted_metadata.filename`) fields. If this parameter is an empty list,
then all fields are returned.
:param int offset: (optional) The number of query results to skip at the
beginning. Consider that the `count` is set to 10 (the default value) and
the total number of results that are returned is 100. In this case, the
following examples show the returned results for different `offset` values:
* If `offset` is set to 95, it returns the last 5 results.
* If `offset` is set to 10, it returns the second batch of 10 results.
* If `offset` is set to 100 or more, it returns empty results.
:param str sort: (optional) A comma-separated list of fields in the
document to sort on. You can optionally specify a sort direction by
prefixing the field with `-` for descending or `+` for ascending. Ascending
is the default sort direction if no prefix is specified.
:param bool highlight: (optional) When `true`, a highlight field is
returned for each result that contains fields that match the query. The
matching query terms are emphasized with surrounding `<em></em>` tags. This
parameter is ignored if **passages.enabled** and **passages.per_document**
are `true`, in which case passages are returned for each document instead
of highlights.
:param bool spelling_suggestions: (optional) When `true` and the
**natural_language_query** parameter is used, the
**natural_language_query** parameter is spell checked. The most likely
correction is returned in the **suggested_query** field of the response (if
one exists).
:param QueryLargeTableResults table_results: (optional) Configuration for
table retrieval.
:param QueryLargeSuggestedRefinements suggested_refinements: (optional)
Configuration for suggested refinements.
**Note**: The **suggested_refinements** parameter that identified dynamic
facets from the data is deprecated.
:param QueryLargePassages passages: (optional) Configuration for passage
retrieval.
:param QueryLargeSimilar similar: (optional) Finds results from documents
that are similar to documents of interest. Use this parameter to add a
*More like these* function to your search. You can include this parameter
with or without a **query**, **filter** or **natural_language_query**
parameter.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `QueryResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if table_results is not None:
table_results = convert_model(table_results)
if suggested_refinements is not None:
suggested_refinements = convert_model(suggested_refinements)
if passages is not None:
passages = convert_model(passages)
if similar is not None:
similar = convert_model(similar)
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='query',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'collection_ids': collection_ids,
'filter': filter,
'query': query,
'natural_language_query': natural_language_query,
'aggregation': aggregation,
'count': count,
'return': return_,
'offset': offset,
'sort': sort,
'highlight': highlight,
'spelling_suggestions': spelling_suggestions,
'table_results': table_results,
'suggested_refinements': suggested_refinements,
'passages': passages,
'similar': similar,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/query'.format(**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def get_autocompletion(
self,
project_id: str,
prefix: str,
*,
collection_ids: Optional[List[str]] = None,
field: Optional[str] = None,
count: Optional[int] = None,
**kwargs,
) -> DetailedResponse:
"""
Get Autocomplete Suggestions.
Returns completion query suggestions for the specified prefix.
Suggested words are based on terms from the project documents. Suggestions are not
based on terms from the project's search history, and the project does not learn
from previous user choices.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str prefix: The prefix to use for autocompletion. For example, the
prefix `Ho` could autocomplete to `hot`, `housing`, or `how`.
:param List[str] collection_ids: (optional) Comma separated list of the
collection IDs. If this parameter is not specified, all collections in the
project are used.
:param str field: (optional) The field in the result documents that
autocompletion suggestions are identified from.
:param int count: (optional) The number of autocompletion suggestions to
return.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Completions` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not prefix:
raise ValueError('prefix must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_autocompletion',
)
headers.update(sdk_headers)
params = {
'version': self.version,
'prefix': prefix,
'collection_ids': convert_list(collection_ids),
'field': field,
'count': count,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/autocompletion'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def query_collection_notices(
self,
project_id: str,
collection_id: str,
*,
filter: Optional[str] = None,
query: Optional[str] = None,
natural_language_query: Optional[str] = None,
count: Optional[int] = None,
offset: Optional[int] = None,
**kwargs,
) -> DetailedResponse:
"""
Query collection notices.
Finds collection-level notices (errors and warnings) that are generated when
documents are ingested.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str filter: (optional) Searches for documents that match the
Discovery Query Language criteria that is specified as input. Filter calls
are cached and are faster than query calls because the results are not
ordered by relevance. When used with the `aggregation`, `query`, or
`natural_language_query` parameters, the `filter` parameter runs first.
This parameter is useful for limiting results to those that contain
specific metadata values.
:param str query: (optional) A query search that is written in the
Discovery Query Language and returns all matching documents in your data
set with full enrichments and full text, and with the most relevant
documents listed first. You can use this parameter or the
**natural_language_query** parameter to specify the query input, but not
both.
:param str natural_language_query: (optional) A natural language query that
returns relevant documents by using natural language understanding. You can
use this parameter or the **query** parameter to specify the query input,
but not both. To filter the results based on criteria you specify, include
the **filter** parameter in the request.
:param int count: (optional) Number of results to return. The maximum for
the **count** and **offset** values together in any one query is
**10,000**.
:param int offset: (optional) The number of query results to skip at the
beginning. For example, if the total number of results that are returned is
10 and the offset is 8, it returns the last two results. The maximum for
the **count** and **offset** values together in any one query is **10000**.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `QueryNoticesResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='query_collection_notices',
)
headers.update(sdk_headers)
params = {
'version': self.version,
'filter': filter,
'query': query,
'natural_language_query': natural_language_query,
'count': count,
'offset': offset,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/notices'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def query_notices(
self,
project_id: str,
*,
filter: Optional[str] = None,
query: Optional[str] = None,
natural_language_query: Optional[str] = None,
count: Optional[int] = None,
offset: Optional[int] = None,
**kwargs,
) -> DetailedResponse:
"""
Query project notices.
Finds project-level notices (errors and warnings). Currently, project-level
notices are generated by relevancy training.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str filter: (optional) Searches for documents that match the
Discovery Query Language criteria that is specified as input. Filter calls
are cached and are faster than query calls because the results are not
ordered by relevance. When used with the `aggregation`, `query`, or
`natural_language_query` parameters, the `filter` parameter runs first.
This parameter is useful for limiting results to those that contain
specific metadata values.
:param str query: (optional) A query search that is written in the
Discovery Query Language and returns all matching documents in your data
set with full enrichments and full text, and with the most relevant
documents listed first. You can use this parameter or the
**natural_language_query** parameter to specify the query input, but not
both.
:param str natural_language_query: (optional) A natural language query that
returns relevant documents by using natural language understanding. You can
use this parameter or the **query** parameter to specify the query input,
but not both. To filter the results based on criteria you specify, include
the **filter** parameter in the request.
:param int count: (optional) Number of results to return. The maximum for
the **count** and **offset** values together in any one query is
**10,000**.
:param int offset: (optional) The number of query results to skip at the
beginning. For example, if the total number of results that are returned is
10 and the offset is 8, it returns the last two results. The maximum for
the **count** and **offset** values together in any one query is **10000**.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `QueryNoticesResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='query_notices',
)
headers.update(sdk_headers)
params = {
'version': self.version,
'filter': filter,
'query': query,
'natural_language_query': natural_language_query,
'count': count,
'offset': offset,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/notices'.format(**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Query modifications
#########################
def get_stopword_list(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get a custom stop words list.
Returns the custom stop words list that is used by the collection. For information
about the default stop words lists that are applied to queries, see [the product
documentation](/docs/discovery-data?topic=discovery-data-stopwords).
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `StopWordList` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_stopword_list',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/stopwords'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_stopword_list(
self,
project_id: str,
collection_id: str,
*,
stopwords: Optional[List[str]] = None,
**kwargs,
) -> DetailedResponse:
"""
Create a custom stop words list.
Adds a list of custom stop words. Stop words are words that you want the service
to ignore when they occur in a query because they're not useful in distinguishing
the semantic meaning of the query. The stop words list cannot contain more than 1
million characters.
A default stop words list is used by all collections. The default list is applied
both at indexing time and at query time. A custom stop words list that you add is
used at query time only.
The custom stop words list augments the default stop words list; you cannot remove
stop words. For information about the default stop words lists per language, see
[the product documentation](/docs/discovery-data?topic=discovery-data-stopwords).
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param List[str] stopwords: (optional) List of stop words.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `StopWordList` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_stopword_list',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'stopwords': stopwords,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/stopwords'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_stopword_list(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete a custom stop words list.
Deletes a custom stop words list to stop using it in queries against the
collection. After a custom stop words list is deleted, the default stop words list
is used.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_stopword_list',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/stopwords'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def list_expansions(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get the expansion list.
Returns the current expansion list for the specified collection. If an expansion
list is not specified, an empty expansions array is returned.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Expansions` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_expansions',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/expansions'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_expansions(
self,
project_id: str,
collection_id: str,
expansions: List['Expansion'],
**kwargs,
) -> DetailedResponse:
"""
Create or update an expansion list.
Creates or replaces the expansion list for this collection. An expansion list
introduces alternative wording for key terms that are mentioned in your
collection. By identifying synonyms or common misspellings, you expand the scope
of a query beyond exact matches. The maximum number of expanded terms allowed per
collection is 5,000.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param List[Expansion] expansions: An array of query expansion definitions.
Each object in the **expansions** array represents a term or set of terms
that will be expanded into other terms. Each expansion object can be
configured as `bidirectional` or `unidirectional`.
* **Bidirectional**: Each entry in the `expanded_terms` list expands to
include all expanded terms. For example, a query for `ibm` expands to `ibm
OR international business machines OR big blue`.
* **Unidirectional**: The terms in `input_terms` in the query are replaced
by the terms in `expanded_terms`. For example, a query for the often
misused term `on premise` is converted to `on premises OR on-premises` and
does not contain the original term. If you want an input term to be
included in the query, then repeat the input term in the expanded terms
list.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Expansions` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if expansions is None:
raise ValueError('expansions must be provided')
expansions = [convert_model(x) for x in expansions]
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_expansions',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'expansions': expansions,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/expansions'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_expansions(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete the expansion list.
Removes the expansion information for this collection. To disable query expansion
for a collection, delete the expansion list.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_expansions',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/expansions'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Component settings
#########################
def get_component_settings(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
List component settings.
Returns default configuration settings for components.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ComponentSettingsResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_component_settings',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/component_settings'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Training data
#########################
def list_training_queries(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
List training queries.
List the training queries for the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `TrainingQuerySet` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_training_queries',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/training_data/queries'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def delete_training_queries(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete training queries.
Removes all training queries for the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_training_queries',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/training_data/queries'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_training_query(
self,
project_id: str,
natural_language_query: str,
examples: List['TrainingExample'],
*,
filter: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Create a training query.
Add a query to the training data for this project. The query can contain a filter
and natural language query.
**Note**: You cannot apply relevancy training to a `content_mining` project type.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str natural_language_query: The natural text query that is used as
the training query.
:param List[TrainingExample] examples: Array of training examples.
:param str filter: (optional) The filter used on the collection before the
**natural_language_query** is applied. Only specify a filter if the
documents that you consider to be most relevant are not included in the top
100 results when you submit test queries. If you specify a filter during
training, apply the same filter to queries that are submitted at runtime
for optimal ranking results.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `TrainingQuery` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if natural_language_query is None:
raise ValueError('natural_language_query must be provided')
if examples is None:
raise ValueError('examples must be provided')
examples = [convert_model(x) for x in examples]
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_training_query',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'natural_language_query': natural_language_query,
'examples': examples,
'filter': filter,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/training_data/queries'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def get_training_query(
self,
project_id: str,
query_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get a training data query.
Get details for a specific training data query, including the query string and all
examples.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str query_id: The ID of the query used for training.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `TrainingQuery` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not query_id:
raise ValueError('query_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_training_query',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'query_id']
path_param_values = self.encode_path_vars(project_id, query_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/training_data/queries/{query_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_training_query(
self,
project_id: str,
query_id: str,
natural_language_query: str,
examples: List['TrainingExample'],
*,
filter: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Update a training query.
Updates an existing training query and its examples. You must resubmit all of the
examples with the update request.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str query_id: The ID of the query used for training.
:param str natural_language_query: The natural text query that is used as
the training query.
:param List[TrainingExample] examples: Array of training examples.
:param str filter: (optional) The filter used on the collection before the
**natural_language_query** is applied. Only specify a filter if the
documents that you consider to be most relevant are not included in the top
100 results when you submit test queries. If you specify a filter during
training, apply the same filter to queries that are submitted at runtime
for optimal ranking results.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `TrainingQuery` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not query_id:
raise ValueError('query_id must be provided')
if natural_language_query is None:
raise ValueError('natural_language_query must be provided')
if examples is None:
raise ValueError('examples must be provided')
examples = [convert_model(x) for x in examples]
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_training_query',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'natural_language_query': natural_language_query,
'examples': examples,
'filter': filter,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'query_id']
path_param_values = self.encode_path_vars(project_id, query_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/training_data/queries/{query_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_training_query(
self,
project_id: str,
query_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete a training data query.
Removes details from a training data query, including the query string and all
examples.
To delete an example, use the *Update a training query* method and omit the
example that you want to delete from the example set.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str query_id: The ID of the query used for training.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not query_id:
raise ValueError('query_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_training_query',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'query_id']
path_param_values = self.encode_path_vars(project_id, query_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/training_data/queries/{query_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Enrichments
#########################
def list_enrichments(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
List enrichments.
Lists the enrichments available to this project. The *Part of Speech* and
*Sentiment of Phrases* enrichments might be listed, but are reserved for internal
use only.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Enrichments` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_enrichments',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/enrichments'.format(**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_enrichment(
self,
project_id: str,
enrichment: 'CreateEnrichment',
*,
file: Optional[BinaryIO] = None,
**kwargs,
) -> DetailedResponse:
"""
Create an enrichment.
Create an enrichment for use with the specified project. To apply the enrichment
to a collection in the project, use the [Collections
API](/apidocs/discovery-data#createcollection).
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param CreateEnrichment enrichment: Information about a specific
enrichment.
:param BinaryIO file: (optional) The enrichment file to upload. Expected
file types per enrichment are as follows:
* CSV for `dictionary` and `sentence_classifier` (the training data CSV
file to upload).
* PEAR for `uima_annotator` and `rule_based` (Explorer)
* ZIP for `watson_knowledge_studio_model` and `rule_based` (Studio Advanced
Rule Editor).
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Enrichment` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if enrichment is None:
raise ValueError('enrichment must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_enrichment',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
form_data.append(
('enrichment', (None, json.dumps(enrichment), 'application/json')))
if file:
form_data.append(('file', (None, file, 'application/octet-stream')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/enrichments'.format(**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
def get_enrichment(
self,
project_id: str,
enrichment_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get enrichment.
Get details about a specific enrichment.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str enrichment_id: The Universally Unique Identifier (UUID) of the
enrichment.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Enrichment` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not enrichment_id:
raise ValueError('enrichment_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_enrichment',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'enrichment_id']
path_param_values = self.encode_path_vars(project_id, enrichment_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/enrichments/{enrichment_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_enrichment(
self,
project_id: str,
enrichment_id: str,
name: str,
*,
description: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Update an enrichment.
Updates an existing enrichment's name and description.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str enrichment_id: The Universally Unique Identifier (UUID) of the
enrichment.
:param str name: A new name for the enrichment.
:param str description: (optional) A new description for the enrichment.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `Enrichment` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not enrichment_id:
raise ValueError('enrichment_id must be provided')
if name is None:
raise ValueError('name must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_enrichment',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
'description': description,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'enrichment_id']
path_param_values = self.encode_path_vars(project_id, enrichment_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/enrichments/{enrichment_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_enrichment(
self,
project_id: str,
enrichment_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete an enrichment.
Deletes an existing enrichment from the specified project.
**Note:** Only enrichments that have been manually created can be deleted.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str enrichment_id: The Universally Unique Identifier (UUID) of the
enrichment.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not enrichment_id:
raise ValueError('enrichment_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_enrichment',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'enrichment_id']
path_param_values = self.encode_path_vars(project_id, enrichment_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/enrichments/{enrichment_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Batches
#########################
def list_batches(
self,
project_id: str,
collection_id: str,
**kwargs,
) -> DetailedResponse:
"""
List batches.
A batch is a set of documents that are ready for enrichment by an external
application. After you apply a webhook enrichment to a collection, and then
process or upload documents to the collection, Discovery creates a batch with a
unique **batch_id**.
To start, you must register your external application as a **webhook** type by
using the [Create enrichment API](/apidocs/discovery-data#createenrichment)
method.
Use the List batches API to get the following:
* Notified batches that are not yet pulled by the external enrichment
application.
* Batches that are pulled, but not yet pushed to Discovery by the external
enrichment application.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ListBatchesResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_batches',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/batches'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def pull_batches(
self,
project_id: str,
collection_id: str,
batch_id: str,
**kwargs,
) -> DetailedResponse:
"""
Pull batches.
Pull a batch of documents from Discovery for enrichment by an external
application. Ensure to include the `Accept-Encoding: gzip` header in this method
to get the file. You can also implement retry logic when calling this method to
avoid any network errors.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str batch_id: The Universally Unique Identifier (UUID) of the
document batch that is being requested from Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `PullBatchesResponse` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if not batch_id:
raise ValueError('batch_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='pull_batches',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id', 'batch_id']
path_param_values = self.encode_path_vars(project_id, collection_id,
batch_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/batches/{batch_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def push_batches(
self,
project_id: str,
collection_id: str,
batch_id: str,
*,
file: Optional[BinaryIO] = None,
filename: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Push batches.
Push a batch of documents to Discovery after annotation by an external
application. You can implement retry logic when calling this method to avoid any
network errors.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param str batch_id: The Universally Unique Identifier (UUID) of the
document batch that is being requested from Discovery.
:param BinaryIO file: (optional) A compressed newline-delimited JSON
(NDJSON), which is a JSON file with one row of data per line. For example,
`{batch_id}.ndjson.gz`. For more information, see [Binary attachment in the
push batches
method](/docs/discovery-data?topic=discovery-data-external-enrichment#binary-attachment-push-batches).
There is no limitation on the name of the file because Discovery does not
use the name for processing. The list of features in the document is
specified in the `features` object.
:param str filename: (optional) The filename for file.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `bool` result
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
if not batch_id:
raise ValueError('batch_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='push_batches',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
if file:
if not filename and hasattr(file, 'name'):
filename = basename(file.name)
if not filename:
raise ValueError('filename must be provided')
form_data.append(
('file', (filename, file, 'application/octet-stream')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id', 'batch_id']
path_param_values = self.encode_path_vars(project_id, collection_id,
batch_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/batches/{batch_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
#########################
# Document classifiers
#########################
def list_document_classifiers(
self,
project_id: str,
**kwargs,
) -> DetailedResponse:
"""
List document classifiers.
Get a list of the document classifiers in a project. Returns only the name and
classifier ID of each document classifier.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifiers` object
"""
if not project_id:
raise ValueError('project_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_document_classifiers',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_document_classifier(
self,
project_id: str,
training_data: BinaryIO,
classifier: 'CreateDocumentClassifier',
*,
test_data: Optional[BinaryIO] = None,
**kwargs,
) -> DetailedResponse:
"""
Create a document classifier.
Create a document classifier. You can use the API to create a document classifier
in any project type. After you create a document classifier, you can use the
Enrichments API to create a classifier enrichment, and then the Collections API to
apply the enrichment to a collection in the project.
**Note:** This method is supported on installed instances (IBM Cloud Pak for Data)
or IBM Cloud-managed Premium or Enterprise plan instances.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param BinaryIO training_data: The training data CSV file to upload. The
CSV file must have headers. The file must include a field that contains the
text you want to classify and a field that contains the classification
labels that you want to use to classify your data. If you want to specify
multiple values in a single field, use a semicolon as the value separator.
For a sample file, see [the product
documentation](/docs/discovery-data?topic=discovery-data-cm-doc-classifier).
:param CreateDocumentClassifier classifier: An object that manages the
settings and data that is required to train a document classification
model.
:param BinaryIO test_data: (optional) The CSV with test data to upload. The
column values in the test file must be the same as the column values in the
training data file. If no test data is provided, the training data is split
into two separate groups of training and test data.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifier` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if training_data is None:
raise ValueError('training_data must be provided')
if classifier is None:
raise ValueError('classifier must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_document_classifier',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
form_data.append(('training_data', (None, training_data, 'text/csv')))
form_data.append(
('classifier', (None, json.dumps(classifier), 'application/json')))
if test_data:
form_data.append(('test_data', (None, test_data, 'text/csv')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id']
path_param_values = self.encode_path_vars(project_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
def get_document_classifier(
self,
project_id: str,
classifier_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get a document classifier.
Get details about a specific document classifier.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifier` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_document_classifier',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'classifier_id']
path_param_values = self.encode_path_vars(project_id, classifier_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_document_classifier(
self,
project_id: str,
classifier_id: str,
classifier: 'UpdateDocumentClassifier',
*,
training_data: Optional[BinaryIO] = None,
test_data: Optional[BinaryIO] = None,
**kwargs,
) -> DetailedResponse:
"""
Update a document classifier.
Update the document classifier name or description, update the training data, or
add or update the test data.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param UpdateDocumentClassifier classifier: An object that contains a new
name or description for a document classifier, updated training data, or
new or updated test data.
:param BinaryIO training_data: (optional) The training data CSV file to
upload. The CSV file must have headers. The file must include a field that
contains the text you want to classify and a field that contains the
classification labels that you want to use to classify your data. If you
want to specify multiple values in a single column, use a semicolon as the
value separator. For a sample file, see [the product
documentation](/docs/discovery-data?topic=discovery-data-cm-doc-classifier).
:param BinaryIO test_data: (optional) The CSV with test data to upload. The
column values in the test file must be the same as the column values in the
training data file. If no test data is provided, the training data is split
into two separate groups of training and test data.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifier` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
if classifier is None:
raise ValueError('classifier must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_document_classifier',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
form_data.append(
('classifier', (None, json.dumps(classifier), 'application/json')))
if training_data:
form_data.append(
('training_data', (None, training_data, 'text/csv')))
if test_data:
form_data.append(('test_data', (None, test_data, 'text/csv')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'classifier_id']
path_param_values = self.encode_path_vars(project_id, classifier_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
def delete_document_classifier(
self,
project_id: str,
classifier_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete a document classifier.
Deletes an existing document classifier from the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_document_classifier',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'classifier_id']
path_param_values = self.encode_path_vars(project_id, classifier_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Document classifier models
#########################
def list_document_classifier_models(
self,
project_id: str,
classifier_id: str,
**kwargs,
) -> DetailedResponse:
"""
List document classifier models.
Get a list of the document classifier models in a project. Returns only the name
and model ID of each document classifier model.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifierModels` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='list_document_classifier_models',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'classifier_id']
path_param_values = self.encode_path_vars(project_id, classifier_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}/models'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def create_document_classifier_model(
self,
project_id: str,
classifier_id: str,
name: str,
*,
description: Optional[str] = None,
learning_rate: Optional[float] = None,
l1_regularization_strengths: Optional[List[float]] = None,
l2_regularization_strengths: Optional[List[float]] = None,
training_max_steps: Optional[int] = None,
improvement_ratio: Optional[float] = None,
**kwargs,
) -> DetailedResponse:
"""
Create a document classifier model.
Create a document classifier model by training a model that uses the data and
classifier settings defined in the specified document classifier.
**Note:** This method is supported on installed intances (IBM Cloud Pak for Data)
or IBM Cloud-managed Premium or Enterprise plan instances.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param str name: The name of the document classifier model.
:param str description: (optional) A description of the document classifier
model.
:param float learning_rate: (optional) A tuning parameter in an
optimization algorithm that determines the step size at each iteration of
the training process. It influences how much of any newly acquired
information overrides the existing information, and therefore is said to
represent the speed at which a machine learning model learns. The default
value is `0.1`.
:param List[float] l1_regularization_strengths: (optional) Avoids
overfitting by shrinking the coefficient of less important features to
zero, which removes some features altogether. You can specify many values
for hyper-parameter optimization. The default value is `[0.000001]`.
:param List[float] l2_regularization_strengths: (optional) A method you can
apply to avoid overfitting your model on the training data. You can specify
many values for hyper-parameter optimization. The default value is
`[0.000001]`.
:param int training_max_steps: (optional) Maximum number of training steps
to complete. This setting is useful if you need the training process to
finish in a specific time frame to fit into an automated process. The
default value is ten million.
:param float improvement_ratio: (optional) Stops the training run early if
the improvement ratio is not met by the time the process reaches a certain
point. The default value is `0.00001`.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifierModel` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
if name is None:
raise ValueError('name must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='create_document_classifier_model',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
'description': description,
'learning_rate': learning_rate,
'l1_regularization_strengths': l1_regularization_strengths,
'l2_regularization_strengths': l2_regularization_strengths,
'training_max_steps': training_max_steps,
'improvement_ratio': improvement_ratio,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'classifier_id']
path_param_values = self.encode_path_vars(project_id, classifier_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}/models'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def get_document_classifier_model(
self,
project_id: str,
classifier_id: str,
model_id: str,
**kwargs,
) -> DetailedResponse:
"""
Get a document classifier model.
Get details about a specific document classifier model.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param str model_id: The Universally Unique Identifier (UUID) of the
classifier model.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifierModel` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
if not model_id:
raise ValueError('model_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='get_document_classifier_model',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'classifier_id', 'model_id']
path_param_values = self.encode_path_vars(project_id, classifier_id,
model_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}/models/{model_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='GET',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
def update_document_classifier_model(
self,
project_id: str,
classifier_id: str,
model_id: str,
*,
name: Optional[str] = None,
description: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Update a document classifier model.
Update the document classifier model name or description.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param str model_id: The Universally Unique Identifier (UUID) of the
classifier model.
:param str name: (optional) A new name for the enrichment.
:param str description: (optional) A new description for the enrichment.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `DocumentClassifierModel` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
if not model_id:
raise ValueError('model_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='update_document_classifier_model',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
data = {
'name': name,
'description': description,
}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'classifier_id', 'model_id']
path_param_values = self.encode_path_vars(project_id, classifier_id,
model_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}/models/{model_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
data=data,
)
response = self.send(request, **kwargs)
return response
def delete_document_classifier_model(
self,
project_id: str,
classifier_id: str,
model_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete a document classifier model.
Deletes an existing document classifier model from the specified project.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str classifier_id: The Universally Unique Identifier (UUID) of the
classifier.
:param str model_id: The Universally Unique Identifier (UUID) of the
classifier model.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not project_id:
raise ValueError('project_id must be provided')
if not classifier_id:
raise ValueError('classifier_id must be provided')
if not model_id:
raise ValueError('model_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_document_classifier_model',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
path_param_keys = ['project_id', 'classifier_id', 'model_id']
path_param_values = self.encode_path_vars(project_id, classifier_id,
model_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/document_classifiers/{classifier_id}/models/{model_id}'.format(
**path_param_dict)
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
#########################
# Analyze
#########################
def analyze_document(
self,
project_id: str,
collection_id: str,
*,
file: Optional[BinaryIO] = None,
filename: Optional[str] = None,
file_content_type: Optional[str] = None,
metadata: Optional[str] = None,
**kwargs,
) -> DetailedResponse:
"""
Analyze a document.
Process a document and return it for realtime use. Supports JSON files only.
The file is not stored in the collection, but is processed according to the
collection's configuration settings. To get results, enrichments must be applied
to a field in the collection that also exists in the file that you want to
analyze. For example, to analyze text in a `Quote` field, you must apply
enrichments to the `Quote` field in the collection configuration. Then, when you
analyze the file, the text in the `Quote` field is analyzed and results are
written to a field named `enriched_Quote`.
Submit a request against only one collection at a time. Remember, the documents in
the collection are not significant. It is the enrichments that are defined for the
collection that matter. If you submit requests to several collections, then
several models are initiated at the same time, which can cause request failures.
**Note:** This method is supported with Enterprise plan deployments and installed
deployments only.
:param str project_id: The Universally Unique Identifier (UUID) of the
project. This information can be found from the *Integrate and Deploy* page
in Discovery.
:param str collection_id: The Universally Unique Identifier (UUID) of the
collection.
:param BinaryIO file: (optional) **Add a document**: The content of the
document to ingest. For the supported file types and maximum supported file
size limits when adding a document, see [the
documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes).
**Analyze a document**: The content of the document to analyze but not
ingest. Only the `application/json` content type is supported by the
Analyze API. For maximum supported file size limits, see [the product
documentation](/docs/discovery-data?topic=discovery-data-analyzeapi#analyzeapi-limits).
:param str filename: (optional) The filename for file.
:param str file_content_type: (optional) The content type of file.
:param str metadata: (optional) Add information about the file that you
want to include in the response.
The maximum supported metadata file size is 1 MB. Metadata parts larger
than 1 MB are rejected.
Example:
```
{
"filename": "favorites2.json",
"file_type": "json"
}.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `AnalyzedDocument` object
"""
if not project_id:
raise ValueError('project_id must be provided')
if not collection_id:
raise ValueError('collection_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='analyze_document',
)
headers.update(sdk_headers)
params = {
'version': self.version,
}
form_data = []
if file:
if not filename and hasattr(file, 'name'):
filename = basename(file.name)
if not filename:
raise ValueError('filename must be provided')
form_data.append(('file', (filename, file, file_content_type or
'application/octet-stream')))
if metadata:
form_data.append(('metadata', (None, metadata, 'text/plain')))
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
headers['Accept'] = 'application/json'
path_param_keys = ['project_id', 'collection_id']
path_param_values = self.encode_path_vars(project_id, collection_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v2/projects/{project_id}/collections/{collection_id}/analyze'.format(
**path_param_dict)
request = self.prepare_request(
method='POST',
url=url,
headers=headers,
params=params,
files=form_data,
)
response = self.send(request, **kwargs)
return response
#########################
# User data
#########################
def delete_user_data(
self,
customer_id: str,
**kwargs,
) -> DetailedResponse:
"""
Delete labeled data.
Deletes all data associated with a specified customer ID. The method has no effect
if no data is associated with the customer ID.
You associate a customer ID with data by passing the **X-Watson-Metadata** header
with a request that passes data. For more information about personal data and
customer IDs, see [Information
security](/docs/discovery-data?topic=discovery-data-information-security#information-security).
**Note:** This method is only supported on IBM Cloud instances of Discovery.
:param str customer_id: The customer ID for which all data is to be
deleted.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse
"""
if not customer_id:
raise ValueError('customer_id must be provided')
headers = {}
sdk_headers = get_sdk_headers(
service_name=self.DEFAULT_SERVICE_NAME,
service_version='V2',
operation_id='delete_user_data',
)
headers.update(sdk_headers)
params = {
'version': self.version,
'customer_id': customer_id,
}
if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
del kwargs['headers']
url = '/v2/user_data'
request = self.prepare_request(
method='DELETE',
url=url,
headers=headers,
params=params,
)
response = self.send(request, **kwargs)
return response
class AddDocumentEnums:
"""
Enums for add_document parameters.
"""
class FileContentType(str, Enum):
"""
The content type of file.
"""
APPLICATION_JSON = 'application/json'
APPLICATION_MSWORD = 'application/msword'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
APPLICATION_PDF = 'application/pdf'
TEXT_HTML = 'text/html'
APPLICATION_XHTML_XML = 'application/xhtml+xml'
class UpdateDocumentEnums:
"""
Enums for update_document parameters.
"""
class FileContentType(str, Enum):
"""
The content type of file.
"""
APPLICATION_JSON = 'application/json'
APPLICATION_MSWORD = 'application/msword'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
APPLICATION_PDF = 'application/pdf'
TEXT_HTML = 'text/html'
APPLICATION_XHTML_XML = 'application/xhtml+xml'
class AnalyzeDocumentEnums:
"""
Enums for analyze_document parameters.
"""
class FileContentType(str, Enum):
"""
The content type of file.
"""
APPLICATION_JSON = 'application/json'
APPLICATION_MSWORD = 'application/msword'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
APPLICATION_PDF = 'application/pdf'
TEXT_HTML = 'text/html'
APPLICATION_XHTML_XML = 'application/xhtml+xml'
##############################################################################
# Models
##############################################################################
class AnalyzedDocument:
"""
An object that contains the converted document and any identified enrichments.
Root-level fields from the original file are returned also.
:param List[Notice] notices: (optional) Array of notices that are triggered when
the files are processed.
:param AnalyzedResult result: (optional) Result of the document analysis.
"""
def __init__(
self,
*,
notices: Optional[List['Notice']] = None,
result: Optional['AnalyzedResult'] = None,
) -> None:
"""
Initialize a AnalyzedDocument object.
:param List[Notice] notices: (optional) Array of notices that are triggered
when the files are processed.
:param AnalyzedResult result: (optional) Result of the document analysis.
"""
self.notices = notices
self.result = result
@classmethod
def from_dict(cls, _dict: Dict) -> 'AnalyzedDocument':
"""Initialize a AnalyzedDocument object from a json dictionary."""
args = {}
if (notices := _dict.get('notices')) is not None:
args['notices'] = [Notice.from_dict(v) for v in notices]
if (result := _dict.get('result')) is not None:
args['result'] = AnalyzedResult.from_dict(result)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a AnalyzedDocument object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'notices') and self.notices is not None:
notices_list = []
for v in self.notices:
if isinstance(v, dict):
notices_list.append(v)
else:
notices_list.append(v.to_dict())
_dict['notices'] = notices_list
if hasattr(self, 'result') and self.result is not None:
if isinstance(self.result, dict):
_dict['result'] = self.result
else:
_dict['result'] = self.result.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this AnalyzedDocument object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'AnalyzedDocument') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'AnalyzedDocument') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class AnalyzedResult:
"""
Result of the document analysis.
:param dict metadata: (optional) Metadata that was specified with the request.
This type supports additional properties of type object. The remaining key-value
pairs.
"""
# The set of defined properties for the class
_properties = frozenset(['metadata'])
def __init__(
self,
*,
metadata: Optional[dict] = None,
**kwargs: Optional[object],
) -> None:
"""
Initialize a AnalyzedResult object.
:param dict metadata: (optional) Metadata that was specified with the
request.
:param object **kwargs: (optional) The remaining key-value pairs.
"""
self.metadata = metadata
for k, v in kwargs.items():
if k not in AnalyzedResult._properties:
if not isinstance(v, object):
raise ValueError(
'Value for additional property {} must be of type object'
.format(k))
setattr(self, k, v)
else:
raise ValueError(
'Property {} cannot be specified as an additional property'.
format(k))
@classmethod
def from_dict(cls, _dict: Dict) -> 'AnalyzedResult':
"""Initialize a AnalyzedResult object from a json dictionary."""
args = {}
if (metadata := _dict.get('metadata')) is not None:
args['metadata'] = metadata
for k, v in _dict.items():
if k not in cls._properties:
if not isinstance(v, object):
raise ValueError(
'Value for additional property {} must be of type object'
.format(k))
args[k] = v
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a AnalyzedResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'metadata') and self.metadata is not None:
_dict['metadata'] = self.metadata
for k in [
_k for _k in vars(self).keys()
if _k not in AnalyzedResult._properties
]:
_dict[k] = getattr(self, k)
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def get_properties(self) -> Dict:
"""Return the additional properties from this instance of AnalyzedResult in the form of a dict."""
_dict = {}
for k in [
_k for _k in vars(self).keys()
if _k not in AnalyzedResult._properties
]:
_dict[k] = getattr(self, k)
return _dict
def set_properties(self, _dict: dict):
"""Set a dictionary of additional properties in this instance of AnalyzedResult"""
for k in [
_k for _k in vars(self).keys()
if _k not in AnalyzedResult._properties
]:
delattr(self, k)
for k, v in _dict.items():
if k not in AnalyzedResult._properties:
if not isinstance(v, object):
raise ValueError(
'Value for additional property {} must be of type object'
.format(k))
setattr(self, k, v)
else:
raise ValueError(
'Property {} cannot be specified as an additional property'.
format(k))
def __str__(self) -> str:
"""Return a `str` version of this AnalyzedResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'AnalyzedResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'AnalyzedResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class BatchDetails:
"""
A batch is a set of documents that are ready for enrichment by an external
application. After you apply a webhook enrichment to a collection, and then process or
upload documents to the collection, Discovery creates a batch with a unique
**batch_id**.
:param str batch_id: (optional) The Universally Unique Identifier (UUID) for a
batch of documents.
:param datetime created: (optional) The date and time (RFC3339) that the batch
was created.
:param str enrichment_id: (optional) The Universally Unique Identifier (UUID)
for the external enrichment.
"""
def __init__(
self,
*,
batch_id: Optional[str] = None,
created: Optional[datetime] = None,
enrichment_id: Optional[str] = None,
) -> None:
"""
Initialize a BatchDetails object.
:param str enrichment_id: (optional) The Universally Unique Identifier
(UUID) for the external enrichment.
"""
self.batch_id = batch_id
self.created = created
self.enrichment_id = enrichment_id
@classmethod
def from_dict(cls, _dict: Dict) -> 'BatchDetails':
"""Initialize a BatchDetails object from a json dictionary."""
args = {}
if (batch_id := _dict.get('batch_id')) is not None:
args['batch_id'] = batch_id
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (enrichment_id := _dict.get('enrichment_id')) is not None:
args['enrichment_id'] = enrichment_id
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a BatchDetails object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'batch_id') and getattr(self, 'batch_id') is not None:
_dict['batch_id'] = getattr(self, 'batch_id')
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'enrichment_id') and self.enrichment_id is not None:
_dict['enrichment_id'] = self.enrichment_id
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this BatchDetails object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'BatchDetails') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'BatchDetails') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ClassifierFederatedModel:
"""
An object with details for creating federated document classifier models.
:param str field: Name of the field that contains the values from which multiple
classifier models are defined. For example, you can specify a field that lists
product lines to create a separate model per product line.
"""
def __init__(
self,
field: str,
) -> None:
"""
Initialize a ClassifierFederatedModel object.
:param str field: Name of the field that contains the values from which
multiple classifier models are defined. For example, you can specify a
field that lists product lines to create a separate model per product line.
"""
self.field = field
@classmethod
def from_dict(cls, _dict: Dict) -> 'ClassifierFederatedModel':
"""Initialize a ClassifierFederatedModel object from a json dictionary."""
args = {}
if (field := _dict.get('field')) is not None:
args['field'] = field
else:
raise ValueError(
'Required property \'field\' not present in ClassifierFederatedModel JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ClassifierFederatedModel object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ClassifierFederatedModel object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ClassifierFederatedModel') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ClassifierFederatedModel') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ClassifierModelEvaluation:
"""
An object that contains information about a trained document classifier model.
:param ModelEvaluationMicroAverage micro_average: A micro-average aggregates the
contributions of all classes to compute the average metric. Classes refers to
the classification labels that are specified in the **answer_field**.
:param ModelEvaluationMacroAverage macro_average: A macro-average computes
metric independently for each class and then takes the average. Class refers to
the classification label that is specified in the **answer_field**.
:param List[PerClassModelEvaluation] per_class: An array of evaluation metrics,
one set of metrics for each class, where class refers to the classification
label that is specified in the **answer_field**.
"""
def __init__(
self,
micro_average: 'ModelEvaluationMicroAverage',
macro_average: 'ModelEvaluationMacroAverage',
per_class: List['PerClassModelEvaluation'],
) -> None:
"""
Initialize a ClassifierModelEvaluation object.
:param ModelEvaluationMicroAverage micro_average: A micro-average
aggregates the contributions of all classes to compute the average metric.
Classes refers to the classification labels that are specified in the
**answer_field**.
:param ModelEvaluationMacroAverage macro_average: A macro-average computes
metric independently for each class and then takes the average. Class
refers to the classification label that is specified in the
**answer_field**.
:param List[PerClassModelEvaluation] per_class: An array of evaluation
metrics, one set of metrics for each class, where class refers to the
classification label that is specified in the **answer_field**.
"""
self.micro_average = micro_average
self.macro_average = macro_average
self.per_class = per_class
@classmethod
def from_dict(cls, _dict: Dict) -> 'ClassifierModelEvaluation':
"""Initialize a ClassifierModelEvaluation object from a json dictionary."""
args = {}
if (micro_average := _dict.get('micro_average')) is not None:
args['micro_average'] = ModelEvaluationMicroAverage.from_dict(
micro_average)
else:
raise ValueError(
'Required property \'micro_average\' not present in ClassifierModelEvaluation JSON'
)
if (macro_average := _dict.get('macro_average')) is not None:
args['macro_average'] = ModelEvaluationMacroAverage.from_dict(
macro_average)
else:
raise ValueError(
'Required property \'macro_average\' not present in ClassifierModelEvaluation JSON'
)
if (per_class := _dict.get('per_class')) is not None:
args['per_class'] = [
PerClassModelEvaluation.from_dict(v) for v in per_class
]
else:
raise ValueError(
'Required property \'per_class\' not present in ClassifierModelEvaluation JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ClassifierModelEvaluation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'micro_average') and self.micro_average is not None:
if isinstance(self.micro_average, dict):
_dict['micro_average'] = self.micro_average
else:
_dict['micro_average'] = self.micro_average.to_dict()
if hasattr(self, 'macro_average') and self.macro_average is not None:
if isinstance(self.macro_average, dict):
_dict['macro_average'] = self.macro_average
else:
_dict['macro_average'] = self.macro_average.to_dict()
if hasattr(self, 'per_class') and self.per_class is not None:
per_class_list = []
for v in self.per_class:
if isinstance(v, dict):
per_class_list.append(v)
else:
per_class_list.append(v.to_dict())
_dict['per_class'] = per_class_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ClassifierModelEvaluation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ClassifierModelEvaluation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ClassifierModelEvaluation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Collection:
"""
A collection for storing documents.
:param str collection_id: (optional) The Universally Unique Identifier (UUID) of
the collection.
:param str name: (optional) The name of the collection.
"""
def __init__(
self,
*,
collection_id: Optional[str] = None,
name: Optional[str] = None,
) -> None:
"""
Initialize a Collection object.
:param str name: (optional) The name of the collection.
"""
self.collection_id = collection_id
self.name = name
@classmethod
def from_dict(cls, _dict: Dict) -> 'Collection':
"""Initialize a Collection object from a json dictionary."""
args = {}
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
if (name := _dict.get('name')) is not None:
args['name'] = name
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Collection object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'collection_id') and getattr(
self, 'collection_id') is not None:
_dict['collection_id'] = getattr(self, 'collection_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Collection object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Collection') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Collection') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class CollectionDetails:
"""
A collection for storing documents.
:param str collection_id: (optional) The Universally Unique Identifier (UUID) of
the collection.
:param str name: The name of the collection.
:param str description: (optional) A description of the collection.
:param datetime created: (optional) The date that the collection was created.
:param str language: (optional) The language of the collection. For a list of
supported languages, see the [product
documentation](/docs/discovery-data?topic=discovery-data-language-support).
:param bool ocr_enabled: (optional) If set to `true`, optical character
recognition (OCR) is enabled. For more information, see [Optical character
recognition](/docs/discovery-data?topic=discovery-data-collections#ocr).
:param List[CollectionEnrichment] enrichments: (optional) An array of
enrichments that are applied to this collection. To get a list of enrichments
that are available for a project, use the [List enrichments](#listenrichments)
method.
If no enrichments are specified when the collection is created, the default
enrichments for the project type are applied. For more information about project
default settings, see the [product
documentation](/docs/discovery-data?topic=discovery-data-project-defaults).
:param CollectionDetailsSmartDocumentUnderstanding smart_document_understanding:
(optional) An object that describes the Smart Document Understanding model for a
collection.
"""
def __init__(
self,
name: str,
*,
collection_id: Optional[str] = None,
description: Optional[str] = None,
created: Optional[datetime] = None,
language: Optional[str] = None,
ocr_enabled: Optional[bool] = None,
enrichments: Optional[List['CollectionEnrichment']] = None,
smart_document_understanding: Optional[
'CollectionDetailsSmartDocumentUnderstanding'] = None,
) -> None:
"""
Initialize a CollectionDetails object.
:param str name: The name of the collection.
:param str description: (optional) A description of the collection.
:param str language: (optional) The language of the collection. For a list
of supported languages, see the [product
documentation](/docs/discovery-data?topic=discovery-data-language-support).
:param bool ocr_enabled: (optional) If set to `true`, optical character
recognition (OCR) is enabled. For more information, see [Optical character
recognition](/docs/discovery-data?topic=discovery-data-collections#ocr).
:param List[CollectionEnrichment] enrichments: (optional) An array of
enrichments that are applied to this collection. To get a list of
enrichments that are available for a project, use the [List
enrichments](#listenrichments) method.
If no enrichments are specified when the collection is created, the default
enrichments for the project type are applied. For more information about
project default settings, see the [product
documentation](/docs/discovery-data?topic=discovery-data-project-defaults).
"""
self.collection_id = collection_id
self.name = name
self.description = description
self.created = created
self.language = language
self.ocr_enabled = ocr_enabled
self.enrichments = enrichments
self.smart_document_understanding = smart_document_understanding
@classmethod
def from_dict(cls, _dict: Dict) -> 'CollectionDetails':
"""Initialize a CollectionDetails object from a json dictionary."""
args = {}
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
if (name := _dict.get('name')) is not None:
args['name'] = name
else:
raise ValueError(
'Required property \'name\' not present in CollectionDetails JSON'
)
if (description := _dict.get('description')) is not None:
args['description'] = description
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (language := _dict.get('language')) is not None:
args['language'] = language
if (ocr_enabled := _dict.get('ocr_enabled')) is not None:
args['ocr_enabled'] = ocr_enabled
if (enrichments := _dict.get('enrichments')) is not None:
args['enrichments'] = [
CollectionEnrichment.from_dict(v) for v in enrichments
]
if (smart_document_understanding :=
_dict.get('smart_document_understanding')) is not None:
args[
'smart_document_understanding'] = CollectionDetailsSmartDocumentUnderstanding.from_dict(
smart_document_understanding)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a CollectionDetails object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'collection_id') and getattr(
self, 'collection_id') is not None:
_dict['collection_id'] = getattr(self, 'collection_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'language') and self.language is not None:
_dict['language'] = self.language
if hasattr(self, 'ocr_enabled') and self.ocr_enabled is not None:
_dict['ocr_enabled'] = self.ocr_enabled
if hasattr(self, 'enrichments') and self.enrichments is not None:
enrichments_list = []
for v in self.enrichments:
if isinstance(v, dict):
enrichments_list.append(v)
else:
enrichments_list.append(v.to_dict())
_dict['enrichments'] = enrichments_list
if hasattr(self, 'smart_document_understanding') and getattr(
self, 'smart_document_understanding') is not None:
if isinstance(getattr(self, 'smart_document_understanding'), dict):
_dict['smart_document_understanding'] = getattr(
self, 'smart_document_understanding')
else:
_dict['smart_document_understanding'] = getattr(
self, 'smart_document_understanding').to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this CollectionDetails object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'CollectionDetails') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'CollectionDetails') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class CollectionDetailsSmartDocumentUnderstanding:
"""
An object that describes the Smart Document Understanding model for a collection.
:param bool enabled: (optional) When `true`, smart document understanding
conversion is enabled for the collection.
:param str model: (optional) Specifies the type of Smart Document Understanding
(SDU) model that is enabled for the collection. The following types of models
are supported:
* `custom`: A user-trained model is applied.
* `pre_trained`: A pretrained model is applied. This type of model is applied
automatically to *Document Retrieval for Contracts* projects.
* `text_extraction`: An SDU model that extracts text and metadata from the
content. This model is enabled in collections by default regardless of the types
of documents in the collection (as long as the service plan supports SDU
models).
You can apply user-trained or pretrained models to collections from the
*Identify fields* page of the product user interface. For more information, see
[the product
documentation](/docs/discovery-data?topic=discovery-data-configuring-fields).
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
model: Optional[str] = None,
) -> None:
"""
Initialize a CollectionDetailsSmartDocumentUnderstanding object.
:param bool enabled: (optional) When `true`, smart document understanding
conversion is enabled for the collection.
:param str model: (optional) Specifies the type of Smart Document
Understanding (SDU) model that is enabled for the collection. The following
types of models are supported:
* `custom`: A user-trained model is applied.
* `pre_trained`: A pretrained model is applied. This type of model is
applied automatically to *Document Retrieval for Contracts* projects.
* `text_extraction`: An SDU model that extracts text and metadata from the
content. This model is enabled in collections by default regardless of the
types of documents in the collection (as long as the service plan supports
SDU models).
You can apply user-trained or pretrained models to collections from the
*Identify fields* page of the product user interface. For more information,
see [the product
documentation](/docs/discovery-data?topic=discovery-data-configuring-fields).
"""
self.enabled = enabled
self.model = model
@classmethod
def from_dict(cls,
_dict: Dict) -> 'CollectionDetailsSmartDocumentUnderstanding':
"""Initialize a CollectionDetailsSmartDocumentUnderstanding object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (model := _dict.get('model')) is not None:
args['model'] = model
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a CollectionDetailsSmartDocumentUnderstanding object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'model') and self.model is not None:
_dict['model'] = self.model
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this CollectionDetailsSmartDocumentUnderstanding object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self,
other: 'CollectionDetailsSmartDocumentUnderstanding') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self,
other: 'CollectionDetailsSmartDocumentUnderstanding') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ModelEnum(str, Enum):
"""
Specifies the type of Smart Document Understanding (SDU) model that is enabled for
the collection. The following types of models are supported:
* `custom`: A user-trained model is applied.
* `pre_trained`: A pretrained model is applied. This type of model is applied
automatically to *Document Retrieval for Contracts* projects.
* `text_extraction`: An SDU model that extracts text and metadata from the
content. This model is enabled in collections by default regardless of the types
of documents in the collection (as long as the service plan supports SDU models).
You can apply user-trained or pretrained models to collections from the *Identify
fields* page of the product user interface. For more information, see [the product
documentation](/docs/discovery-data?topic=discovery-data-configuring-fields).
"""
CUSTOM = 'custom'
PRE_TRAINED = 'pre_trained'
TEXT_EXTRACTION = 'text_extraction'
class CollectionEnrichment:
"""
An object describing an enrichment for a collection.
:param str enrichment_id: (optional) The unique identifier of this enrichment.
For more information about how to determine the ID of an enrichment, see [the
product
documentation](/docs/discovery-data?topic=discovery-data-manage-enrichments#enrichments-ids).
:param List[str] fields: (optional) An array of field names that the enrichment
is applied to.
If you apply an enrichment to a field from a JSON file, the data is converted to
an array automatically, even if the field contains a single value.
"""
def __init__(
self,
*,
enrichment_id: Optional[str] = None,
fields: Optional[List[str]] = None,
) -> None:
"""
Initialize a CollectionEnrichment object.
:param str enrichment_id: (optional) The unique identifier of this
enrichment. For more information about how to determine the ID of an
enrichment, see [the product
documentation](/docs/discovery-data?topic=discovery-data-manage-enrichments#enrichments-ids).
:param List[str] fields: (optional) An array of field names that the
enrichment is applied to.
If you apply an enrichment to a field from a JSON file, the data is
converted to an array automatically, even if the field contains a single
value.
"""
self.enrichment_id = enrichment_id
self.fields = fields
@classmethod
def from_dict(cls, _dict: Dict) -> 'CollectionEnrichment':
"""Initialize a CollectionEnrichment object from a json dictionary."""
args = {}
if (enrichment_id := _dict.get('enrichment_id')) is not None:
args['enrichment_id'] = enrichment_id
if (fields := _dict.get('fields')) is not None:
args['fields'] = fields
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a CollectionEnrichment object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enrichment_id') and self.enrichment_id is not None:
_dict['enrichment_id'] = self.enrichment_id
if hasattr(self, 'fields') and self.fields is not None:
_dict['fields'] = self.fields
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this CollectionEnrichment object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'CollectionEnrichment') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'CollectionEnrichment') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Completions:
"""
An object that contains an array of autocompletion suggestions.
:param List[str] completions: (optional) Array of autocomplete suggestion based
on the provided prefix.
"""
def __init__(
self,
*,
completions: Optional[List[str]] = None,
) -> None:
"""
Initialize a Completions object.
:param List[str] completions: (optional) Array of autocomplete suggestion
based on the provided prefix.
"""
self.completions = completions
@classmethod
def from_dict(cls, _dict: Dict) -> 'Completions':
"""Initialize a Completions object from a json dictionary."""
args = {}
if (completions := _dict.get('completions')) is not None:
args['completions'] = completions
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Completions object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'completions') and self.completions is not None:
_dict['completions'] = self.completions
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Completions object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Completions') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Completions') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ComponentSettingsAggregation:
"""
Display settings for aggregations.
:param str name: (optional) Identifier used to map aggregation settings to
aggregation configuration.
:param str label: (optional) User-friendly alias for the aggregation.
:param bool multiple_selections_allowed: (optional) Whether users is allowed to
select more than one of the aggregation terms.
:param str visualization_type: (optional) Type of visualization to use when
rendering the aggregation.
"""
def __init__(
self,
*,
name: Optional[str] = None,
label: Optional[str] = None,
multiple_selections_allowed: Optional[bool] = None,
visualization_type: Optional[str] = None,
) -> None:
"""
Initialize a ComponentSettingsAggregation object.
:param str name: (optional) Identifier used to map aggregation settings to
aggregation configuration.
:param str label: (optional) User-friendly alias for the aggregation.
:param bool multiple_selections_allowed: (optional) Whether users is
allowed to select more than one of the aggregation terms.
:param str visualization_type: (optional) Type of visualization to use when
rendering the aggregation.
"""
self.name = name
self.label = label
self.multiple_selections_allowed = multiple_selections_allowed
self.visualization_type = visualization_type
@classmethod
def from_dict(cls, _dict: Dict) -> 'ComponentSettingsAggregation':
"""Initialize a ComponentSettingsAggregation object from a json dictionary."""
args = {}
if (name := _dict.get('name')) is not None:
args['name'] = name
if (label := _dict.get('label')) is not None:
args['label'] = label
if (multiple_selections_allowed :=
_dict.get('multiple_selections_allowed')) is not None:
args['multiple_selections_allowed'] = multiple_selections_allowed
if (visualization_type := _dict.get('visualization_type')) is not None:
args['visualization_type'] = visualization_type
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ComponentSettingsAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'label') and self.label is not None:
_dict['label'] = self.label
if hasattr(self, 'multiple_selections_allowed'
) and self.multiple_selections_allowed is not None:
_dict[
'multiple_selections_allowed'] = self.multiple_selections_allowed
if hasattr(
self,
'visualization_type') and self.visualization_type is not None:
_dict['visualization_type'] = self.visualization_type
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ComponentSettingsAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ComponentSettingsAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ComponentSettingsAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class VisualizationTypeEnum(str, Enum):
"""
Type of visualization to use when rendering the aggregation.
"""
AUTO = 'auto'
FACET_TABLE = 'facet_table'
WORD_CLOUD = 'word_cloud'
MAP = 'map'
class ComponentSettingsFieldsShown:
"""
Fields shown in the results section of the UI.
:param ComponentSettingsFieldsShownBody body: (optional) Body label.
:param ComponentSettingsFieldsShownTitle title: (optional) Title label.
"""
def __init__(
self,
*,
body: Optional['ComponentSettingsFieldsShownBody'] = None,
title: Optional['ComponentSettingsFieldsShownTitle'] = None,
) -> None:
"""
Initialize a ComponentSettingsFieldsShown object.
:param ComponentSettingsFieldsShownBody body: (optional) Body label.
:param ComponentSettingsFieldsShownTitle title: (optional) Title label.
"""
self.body = body
self.title = title
@classmethod
def from_dict(cls, _dict: Dict) -> 'ComponentSettingsFieldsShown':
"""Initialize a ComponentSettingsFieldsShown object from a json dictionary."""
args = {}
if (body := _dict.get('body')) is not None:
args['body'] = ComponentSettingsFieldsShownBody.from_dict(body)
if (title := _dict.get('title')) is not None:
args['title'] = ComponentSettingsFieldsShownTitle.from_dict(title)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ComponentSettingsFieldsShown object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'body') and self.body is not None:
if isinstance(self.body, dict):
_dict['body'] = self.body
else:
_dict['body'] = self.body.to_dict()
if hasattr(self, 'title') and self.title is not None:
if isinstance(self.title, dict):
_dict['title'] = self.title
else:
_dict['title'] = self.title.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ComponentSettingsFieldsShown object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ComponentSettingsFieldsShown') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ComponentSettingsFieldsShown') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ComponentSettingsFieldsShownBody:
"""
Body label.
:param bool use_passage: (optional) Use the whole passage as the body.
:param str field: (optional) Use a specific field as the title.
"""
def __init__(
self,
*,
use_passage: Optional[bool] = None,
field: Optional[str] = None,
) -> None:
"""
Initialize a ComponentSettingsFieldsShownBody object.
:param bool use_passage: (optional) Use the whole passage as the body.
:param str field: (optional) Use a specific field as the title.
"""
self.use_passage = use_passage
self.field = field
@classmethod
def from_dict(cls, _dict: Dict) -> 'ComponentSettingsFieldsShownBody':
"""Initialize a ComponentSettingsFieldsShownBody object from a json dictionary."""
args = {}
if (use_passage := _dict.get('use_passage')) is not None:
args['use_passage'] = use_passage
if (field := _dict.get('field')) is not None:
args['field'] = field
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ComponentSettingsFieldsShownBody object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'use_passage') and self.use_passage is not None:
_dict['use_passage'] = self.use_passage
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ComponentSettingsFieldsShownBody object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ComponentSettingsFieldsShownBody') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ComponentSettingsFieldsShownBody') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ComponentSettingsFieldsShownTitle:
"""
Title label.
:param str field: (optional) Use a specific field as the title.
"""
def __init__(
self,
*,
field: Optional[str] = None,
) -> None:
"""
Initialize a ComponentSettingsFieldsShownTitle object.
:param str field: (optional) Use a specific field as the title.
"""
self.field = field
@classmethod
def from_dict(cls, _dict: Dict) -> 'ComponentSettingsFieldsShownTitle':
"""Initialize a ComponentSettingsFieldsShownTitle object from a json dictionary."""
args = {}
if (field := _dict.get('field')) is not None:
args['field'] = field
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ComponentSettingsFieldsShownTitle object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ComponentSettingsFieldsShownTitle object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ComponentSettingsFieldsShownTitle') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ComponentSettingsFieldsShownTitle') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ComponentSettingsResponse:
"""
The default component settings for this project.
:param ComponentSettingsFieldsShown fields_shown: (optional) Fields shown in the
results section of the UI.
:param bool autocomplete: (optional) Whether or not autocomplete is enabled.
:param bool structured_search: (optional) Whether or not structured search is
enabled.
:param int results_per_page: (optional) Number or results shown per page.
:param List[ComponentSettingsAggregation] aggregations: (optional) a list of
component setting aggregations.
"""
def __init__(
self,
*,
fields_shown: Optional['ComponentSettingsFieldsShown'] = None,
autocomplete: Optional[bool] = None,
structured_search: Optional[bool] = None,
results_per_page: Optional[int] = None,
aggregations: Optional[List['ComponentSettingsAggregation']] = None,
) -> None:
"""
Initialize a ComponentSettingsResponse object.
:param ComponentSettingsFieldsShown fields_shown: (optional) Fields shown
in the results section of the UI.
:param bool autocomplete: (optional) Whether or not autocomplete is
enabled.
:param bool structured_search: (optional) Whether or not structured search
is enabled.
:param int results_per_page: (optional) Number or results shown per page.
:param List[ComponentSettingsAggregation] aggregations: (optional) a list
of component setting aggregations.
"""
self.fields_shown = fields_shown
self.autocomplete = autocomplete
self.structured_search = structured_search
self.results_per_page = results_per_page
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'ComponentSettingsResponse':
"""Initialize a ComponentSettingsResponse object from a json dictionary."""
args = {}
if (fields_shown := _dict.get('fields_shown')) is not None:
args['fields_shown'] = ComponentSettingsFieldsShown.from_dict(
fields_shown)
if (autocomplete := _dict.get('autocomplete')) is not None:
args['autocomplete'] = autocomplete
if (structured_search := _dict.get('structured_search')) is not None:
args['structured_search'] = structured_search
if (results_per_page := _dict.get('results_per_page')) is not None:
args['results_per_page'] = results_per_page
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = [
ComponentSettingsAggregation.from_dict(v) for v in aggregations
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ComponentSettingsResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'fields_shown') and self.fields_shown is not None:
if isinstance(self.fields_shown, dict):
_dict['fields_shown'] = self.fields_shown
else:
_dict['fields_shown'] = self.fields_shown.to_dict()
if hasattr(self, 'autocomplete') and self.autocomplete is not None:
_dict['autocomplete'] = self.autocomplete
if hasattr(self,
'structured_search') and self.structured_search is not None:
_dict['structured_search'] = self.structured_search
if hasattr(self,
'results_per_page') and self.results_per_page is not None:
_dict['results_per_page'] = self.results_per_page
if hasattr(self, 'aggregations') and self.aggregations is not None:
aggregations_list = []
for v in self.aggregations:
if isinstance(v, dict):
aggregations_list.append(v)
else:
aggregations_list.append(v.to_dict())
_dict['aggregations'] = aggregations_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ComponentSettingsResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ComponentSettingsResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ComponentSettingsResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class CreateDocumentClassifier:
"""
An object that manages the settings and data that is required to train a document
classification model.
:param str name: A human-readable name of the document classifier.
:param str description: (optional) A description of the document classifier.
:param str language: The language of the training data that is associated with
the document classifier. Language is specified by using the ISO 639-1 language
code, such as `en` for English or `ja` for Japanese.
:param str answer_field: The name of the field from the training and test data
that contains the classification labels.
:param List[DocumentClassifierEnrichment] enrichments: (optional) An array of
enrichments to apply to the data that is used to train and test the document
classifier. The output from the enrichments is used as features by the
classifier to classify the document content both during training and at run
time.
:param ClassifierFederatedModel federated_classification: (optional) An object
with details for creating federated document classifier models.
"""
def __init__(
self,
name: str,
language: str,
answer_field: str,
*,
description: Optional[str] = None,
enrichments: Optional[List['DocumentClassifierEnrichment']] = None,
federated_classification: Optional['ClassifierFederatedModel'] = None,
) -> None:
"""
Initialize a CreateDocumentClassifier object.
:param str name: A human-readable name of the document classifier.
:param str language: The language of the training data that is associated
with the document classifier. Language is specified by using the ISO 639-1
language code, such as `en` for English or `ja` for Japanese.
:param str answer_field: The name of the field from the training and test
data that contains the classification labels.
:param str description: (optional) A description of the document
classifier.
:param List[DocumentClassifierEnrichment] enrichments: (optional) An array
of enrichments to apply to the data that is used to train and test the
document classifier. The output from the enrichments is used as features by
the classifier to classify the document content both during training and at
run time.
:param ClassifierFederatedModel federated_classification: (optional) An
object with details for creating federated document classifier models.
"""
self.name = name
self.description = description
self.language = language
self.answer_field = answer_field
self.enrichments = enrichments
self.federated_classification = federated_classification
@classmethod
def from_dict(cls, _dict: Dict) -> 'CreateDocumentClassifier':
"""Initialize a CreateDocumentClassifier object from a json dictionary."""
args = {}
if (name := _dict.get('name')) is not None:
args['name'] = name
else:
raise ValueError(
'Required property \'name\' not present in CreateDocumentClassifier JSON'
)
if (description := _dict.get('description')) is not None:
args['description'] = description
if (language := _dict.get('language')) is not None:
args['language'] = language
else:
raise ValueError(
'Required property \'language\' not present in CreateDocumentClassifier JSON'
)
if (answer_field := _dict.get('answer_field')) is not None:
args['answer_field'] = answer_field
else:
raise ValueError(
'Required property \'answer_field\' not present in CreateDocumentClassifier JSON'
)
if (enrichments := _dict.get('enrichments')) is not None:
args['enrichments'] = [
DocumentClassifierEnrichment.from_dict(v) for v in enrichments
]
if (federated_classification :=
_dict.get('federated_classification')) is not None:
args[
'federated_classification'] = ClassifierFederatedModel.from_dict(
federated_classification)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a CreateDocumentClassifier object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
if hasattr(self, 'language') and self.language is not None:
_dict['language'] = self.language
if hasattr(self, 'answer_field') and self.answer_field is not None:
_dict['answer_field'] = self.answer_field
if hasattr(self, 'enrichments') and self.enrichments is not None:
enrichments_list = []
for v in self.enrichments:
if isinstance(v, dict):
enrichments_list.append(v)
else:
enrichments_list.append(v.to_dict())
_dict['enrichments'] = enrichments_list
if hasattr(self, 'federated_classification'
) and self.federated_classification is not None:
if isinstance(self.federated_classification, dict):
_dict[
'federated_classification'] = self.federated_classification
else:
_dict[
'federated_classification'] = self.federated_classification.to_dict(
)
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this CreateDocumentClassifier object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'CreateDocumentClassifier') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'CreateDocumentClassifier') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class CreateEnrichment:
"""
Information about a specific enrichment.
:param str name: (optional) The human readable name for this enrichment.
:param str description: (optional) The description of this enrichment.
:param str type: (optional) The type of this enrichment. The following types are
supported:
* `classifier`: Creates a document classifier enrichment from a document
classifier model that you create by using the [Document classifier
API](/apidocs/discovery-data#createdocumentclassifier). **Note**: A text
classifier enrichment can be created only from the product user interface.
* `dictionary`: Creates a custom dictionary enrichment that you define in a CSV
file.
* `regular_expression`: Creates a custom regular expression enrichment from
regex syntax that you specify in the request.
* `rule_based`: Creates an enrichment from an advanced rules model that is
created and exported as a ZIP file from Watson Knowledge Studio.
* `uima_annotator`: Creates an enrichment from a custom UIMA text analysis model
that is defined in a PEAR file created in one of the following ways:
* Watson Explorer Content Analytics Studio. **Note**: Supported in IBM Cloud
Pak for Data instances only.
* Rule-based model that is created in Watson Knowledge Studio.
* `watson_knowledge_studio_model`: Creates an enrichment from a Watson Knowledge
Studio machine learning model that is defined in a ZIP file.
* `webhook`: Connects to an external enrichment application by using a webhook.
* `sentence_classifier`: Use sentence classifier to classify sentences in your
documents. This feature is available in IBM Cloud-managed instances only. The
sentence classifier feature is beta functionality. Beta features are not
supported by the SDKs.
:param EnrichmentOptions options: (optional) An object that contains options for
the current enrichment. Starting with version `2020-08-30`, the enrichment
options are not included in responses from the List Enrichments method.
"""
def __init__(
self,
*,
name: Optional[str] = None,
description: Optional[str] = None,
type: Optional[str] = None,
options: Optional['EnrichmentOptions'] = None,
) -> None:
"""
Initialize a CreateEnrichment object.
:param str name: (optional) The human readable name for this enrichment.
:param str description: (optional) The description of this enrichment.
:param str type: (optional) The type of this enrichment. The following
types are supported:
* `classifier`: Creates a document classifier enrichment from a document
classifier model that you create by using the [Document classifier
API](/apidocs/discovery-data#createdocumentclassifier). **Note**: A text
classifier enrichment can be created only from the product user interface.
* `dictionary`: Creates a custom dictionary enrichment that you define in a
CSV file.
* `regular_expression`: Creates a custom regular expression enrichment from
regex syntax that you specify in the request.
* `rule_based`: Creates an enrichment from an advanced rules model that is
created and exported as a ZIP file from Watson Knowledge Studio.
* `uima_annotator`: Creates an enrichment from a custom UIMA text analysis
model that is defined in a PEAR file created in one of the following ways:
* Watson Explorer Content Analytics Studio. **Note**: Supported in IBM
Cloud Pak for Data instances only.
* Rule-based model that is created in Watson Knowledge Studio.
* `watson_knowledge_studio_model`: Creates an enrichment from a Watson
Knowledge Studio machine learning model that is defined in a ZIP file.
* `webhook`: Connects to an external enrichment application by using a
webhook.
* `sentence_classifier`: Use sentence classifier to classify sentences in
your documents. This feature is available in IBM Cloud-managed instances
only. The sentence classifier feature is beta functionality. Beta features
are not supported by the SDKs.
:param EnrichmentOptions options: (optional) An object that contains
options for the current enrichment. Starting with version `2020-08-30`, the
enrichment options are not included in responses from the List Enrichments
method.
"""
self.name = name
self.description = description
self.type = type
self.options = options
@classmethod
def from_dict(cls, _dict: Dict) -> 'CreateEnrichment':
"""Initialize a CreateEnrichment object from a json dictionary."""
args = {}
if (name := _dict.get('name')) is not None:
args['name'] = name
if (description := _dict.get('description')) is not None:
args['description'] = description
if (type := _dict.get('type')) is not None:
args['type'] = type
if (options := _dict.get('options')) is not None:
args['options'] = EnrichmentOptions.from_dict(options)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a CreateEnrichment object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'options') and self.options is not None:
if isinstance(self.options, dict):
_dict['options'] = self.options
else:
_dict['options'] = self.options.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this CreateEnrichment object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'CreateEnrichment') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'CreateEnrichment') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TypeEnum(str, Enum):
"""
The type of this enrichment. The following types are supported:
* `classifier`: Creates a document classifier enrichment from a document
classifier model that you create by using the [Document classifier
API](/apidocs/discovery-data#createdocumentclassifier). **Note**: A text
classifier enrichment can be created only from the product user interface.
* `dictionary`: Creates a custom dictionary enrichment that you define in a CSV
file.
* `regular_expression`: Creates a custom regular expression enrichment from regex
syntax that you specify in the request.
* `rule_based`: Creates an enrichment from an advanced rules model that is created
and exported as a ZIP file from Watson Knowledge Studio.
* `uima_annotator`: Creates an enrichment from a custom UIMA text analysis model
that is defined in a PEAR file created in one of the following ways:
* Watson Explorer Content Analytics Studio. **Note**: Supported in IBM Cloud
Pak for Data instances only.
* Rule-based model that is created in Watson Knowledge Studio.
* `watson_knowledge_studio_model`: Creates an enrichment from a Watson Knowledge
Studio machine learning model that is defined in a ZIP file.
* `webhook`: Connects to an external enrichment application by using a webhook.
* `sentence_classifier`: Use sentence classifier to classify sentences in your
documents. This feature is available in IBM Cloud-managed instances only. The
sentence classifier feature is beta functionality. Beta features are not supported
by the SDKs.
"""
CLASSIFIER = 'classifier'
DICTIONARY = 'dictionary'
REGULAR_EXPRESSION = 'regular_expression'
UIMA_ANNOTATOR = 'uima_annotator'
RULE_BASED = 'rule_based'
WATSON_KNOWLEDGE_STUDIO_MODEL = 'watson_knowledge_studio_model'
WEBHOOK = 'webhook'
SENTENCE_CLASSIFIER = 'sentence_classifier'
class DefaultQueryParams:
"""
Default query parameters for this project.
:param List[str] collection_ids: (optional) An array of collection identifiers
to query. If empty or omitted all collections in the project are queried.
:param DefaultQueryParamsPassages passages: (optional) Default settings
configuration for passage search options.
:param DefaultQueryParamsTableResults table_results: (optional) Default project
query settings for table results.
:param str aggregation: (optional) A string representing the default aggregation
query for the project.
:param DefaultQueryParamsSuggestedRefinements suggested_refinements: (optional)
Object that contains suggested refinement settings.
**Note**: The `suggested_refinements` parameter that identified dynamic facets
from the data is deprecated.
:param bool spelling_suggestions: (optional) When `true`, a spelling suggestions
for the query are returned by default.
:param bool highlight: (optional) When `true`, highlights for the query are
returned by default.
:param int count: (optional) The number of document results returned by default.
:param str sort: (optional) A comma separated list of document fields to sort
results by default.
:param List[str] return_: (optional) An array of field names to return in
document results if present by default.
"""
def __init__(
self,
*,
collection_ids: Optional[List[str]] = None,
passages: Optional['DefaultQueryParamsPassages'] = None,
table_results: Optional['DefaultQueryParamsTableResults'] = None,
aggregation: Optional[str] = None,
suggested_refinements: Optional[
'DefaultQueryParamsSuggestedRefinements'] = None,
spelling_suggestions: Optional[bool] = None,
highlight: Optional[bool] = None,
count: Optional[int] = None,
sort: Optional[str] = None,
return_: Optional[List[str]] = None,
) -> None:
"""
Initialize a DefaultQueryParams object.
:param List[str] collection_ids: (optional) An array of collection
identifiers to query. If empty or omitted all collections in the project
are queried.
:param DefaultQueryParamsPassages passages: (optional) Default settings
configuration for passage search options.
:param DefaultQueryParamsTableResults table_results: (optional) Default
project query settings for table results.
:param str aggregation: (optional) A string representing the default
aggregation query for the project.
:param DefaultQueryParamsSuggestedRefinements suggested_refinements:
(optional) Object that contains suggested refinement settings.
**Note**: The `suggested_refinements` parameter that identified dynamic
facets from the data is deprecated.
:param bool spelling_suggestions: (optional) When `true`, a spelling
suggestions for the query are returned by default.
:param bool highlight: (optional) When `true`, highlights for the query are
returned by default.
:param int count: (optional) The number of document results returned by
default.
:param str sort: (optional) A comma separated list of document fields to
sort results by default.
:param List[str] return_: (optional) An array of field names to return in
document results if present by default.
"""
self.collection_ids = collection_ids
self.passages = passages
self.table_results = table_results
self.aggregation = aggregation
self.suggested_refinements = suggested_refinements
self.spelling_suggestions = spelling_suggestions
self.highlight = highlight
self.count = count
self.sort = sort
self.return_ = return_
@classmethod
def from_dict(cls, _dict: Dict) -> 'DefaultQueryParams':
"""Initialize a DefaultQueryParams object from a json dictionary."""
args = {}
if (collection_ids := _dict.get('collection_ids')) is not None:
args['collection_ids'] = collection_ids
if (passages := _dict.get('passages')) is not None:
args['passages'] = DefaultQueryParamsPassages.from_dict(passages)
if (table_results := _dict.get('table_results')) is not None:
args['table_results'] = DefaultQueryParamsTableResults.from_dict(
table_results)
if (aggregation := _dict.get('aggregation')) is not None:
args['aggregation'] = aggregation
if (suggested_refinements :=
_dict.get('suggested_refinements')) is not None:
args[
'suggested_refinements'] = DefaultQueryParamsSuggestedRefinements.from_dict(
suggested_refinements)
if (spelling_suggestions :=
_dict.get('spelling_suggestions')) is not None:
args['spelling_suggestions'] = spelling_suggestions
if (highlight := _dict.get('highlight')) is not None:
args['highlight'] = highlight
if (count := _dict.get('count')) is not None:
args['count'] = count
if (sort := _dict.get('sort')) is not None:
args['sort'] = sort
if (return_ := _dict.get('return')) is not None:
args['return_'] = return_
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DefaultQueryParams object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'collection_ids') and self.collection_ids is not None:
_dict['collection_ids'] = self.collection_ids
if hasattr(self, 'passages') and self.passages is not None:
if isinstance(self.passages, dict):
_dict['passages'] = self.passages
else:
_dict['passages'] = self.passages.to_dict()
if hasattr(self, 'table_results') and self.table_results is not None:
if isinstance(self.table_results, dict):
_dict['table_results'] = self.table_results
else:
_dict['table_results'] = self.table_results.to_dict()
if hasattr(self, 'aggregation') and self.aggregation is not None:
_dict['aggregation'] = self.aggregation
if hasattr(self, 'suggested_refinements'
) and self.suggested_refinements is not None:
if isinstance(self.suggested_refinements, dict):
_dict['suggested_refinements'] = self.suggested_refinements
else:
_dict[
'suggested_refinements'] = self.suggested_refinements.to_dict(
)
if hasattr(self, 'spelling_suggestions'
) and self.spelling_suggestions is not None:
_dict['spelling_suggestions'] = self.spelling_suggestions
if hasattr(self, 'highlight') and self.highlight is not None:
_dict['highlight'] = self.highlight
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
if hasattr(self, 'sort') and self.sort is not None:
_dict['sort'] = self.sort
if hasattr(self, 'return_') and self.return_ is not None:
_dict['return'] = self.return_
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DefaultQueryParams object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DefaultQueryParams') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DefaultQueryParams') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DefaultQueryParamsPassages:
"""
Default settings configuration for passage search options.
:param bool enabled: (optional) When `true`, a passage search is performed by
default.
:param int count: (optional) The number of passages to return.
:param List[str] fields: (optional) An array of field names to perform the
passage search on.
:param int characters: (optional) The approximate number of characters that each
returned passage will contain.
:param bool per_document: (optional) When `true` the number of passages that can
be returned from a single document is restricted to the *max_per_document*
value.
:param int max_per_document: (optional) The default maximum number of passages
that can be taken from a single document as the result of a passage query.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
count: Optional[int] = None,
fields: Optional[List[str]] = None,
characters: Optional[int] = None,
per_document: Optional[bool] = None,
max_per_document: Optional[int] = None,
) -> None:
"""
Initialize a DefaultQueryParamsPassages object.
:param bool enabled: (optional) When `true`, a passage search is performed
by default.
:param int count: (optional) The number of passages to return.
:param List[str] fields: (optional) An array of field names to perform the
passage search on.
:param int characters: (optional) The approximate number of characters that
each returned passage will contain.
:param bool per_document: (optional) When `true` the number of passages
that can be returned from a single document is restricted to the
*max_per_document* value.
:param int max_per_document: (optional) The default maximum number of
passages that can be taken from a single document as the result of a
passage query.
"""
self.enabled = enabled
self.count = count
self.fields = fields
self.characters = characters
self.per_document = per_document
self.max_per_document = max_per_document
@classmethod
def from_dict(cls, _dict: Dict) -> 'DefaultQueryParamsPassages':
"""Initialize a DefaultQueryParamsPassages object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (count := _dict.get('count')) is not None:
args['count'] = count
if (fields := _dict.get('fields')) is not None:
args['fields'] = fields
if (characters := _dict.get('characters')) is not None:
args['characters'] = characters
if (per_document := _dict.get('per_document')) is not None:
args['per_document'] = per_document
if (max_per_document := _dict.get('max_per_document')) is not None:
args['max_per_document'] = max_per_document
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DefaultQueryParamsPassages object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
if hasattr(self, 'fields') and self.fields is not None:
_dict['fields'] = self.fields
if hasattr(self, 'characters') and self.characters is not None:
_dict['characters'] = self.characters
if hasattr(self, 'per_document') and self.per_document is not None:
_dict['per_document'] = self.per_document
if hasattr(self,
'max_per_document') and self.max_per_document is not None:
_dict['max_per_document'] = self.max_per_document
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DefaultQueryParamsPassages object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DefaultQueryParamsPassages') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DefaultQueryParamsPassages') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DefaultQueryParamsSuggestedRefinements:
"""
Object that contains suggested refinement settings.
**Note**: The `suggested_refinements` parameter that identified dynamic facets from
the data is deprecated.
:param bool enabled: (optional) When `true`, suggested refinements for the query
are returned by default.
:param int count: (optional) The number of suggested refinements to return by
default.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
count: Optional[int] = None,
) -> None:
"""
Initialize a DefaultQueryParamsSuggestedRefinements object.
:param bool enabled: (optional) When `true`, suggested refinements for the
query are returned by default.
:param int count: (optional) The number of suggested refinements to return
by default.
"""
self.enabled = enabled
self.count = count
@classmethod
def from_dict(cls, _dict: Dict) -> 'DefaultQueryParamsSuggestedRefinements':
"""Initialize a DefaultQueryParamsSuggestedRefinements object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (count := _dict.get('count')) is not None:
args['count'] = count
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DefaultQueryParamsSuggestedRefinements object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DefaultQueryParamsSuggestedRefinements object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DefaultQueryParamsSuggestedRefinements') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DefaultQueryParamsSuggestedRefinements') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DefaultQueryParamsTableResults:
"""
Default project query settings for table results.
:param bool enabled: (optional) When `true`, a table results for the query are
returned by default.
:param int count: (optional) The number of table results to return by default.
:param int per_document: (optional) The number of table results to include in
each result document.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
count: Optional[int] = None,
per_document: Optional[int] = None,
) -> None:
"""
Initialize a DefaultQueryParamsTableResults object.
:param bool enabled: (optional) When `true`, a table results for the query
are returned by default.
:param int count: (optional) The number of table results to return by
default.
:param int per_document: (optional) The number of table results to include
in each result document.
"""
self.enabled = enabled
self.count = count
self.per_document = per_document
@classmethod
def from_dict(cls, _dict: Dict) -> 'DefaultQueryParamsTableResults':
"""Initialize a DefaultQueryParamsTableResults object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (count := _dict.get('count')) is not None:
args['count'] = count
if (per_document := _dict.get('per_document')) is not None:
args['per_document'] = per_document
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DefaultQueryParamsTableResults object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
if hasattr(self, 'per_document') and self.per_document is not None:
_dict['per_document'] = self.per_document
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DefaultQueryParamsTableResults object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DefaultQueryParamsTableResults') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DefaultQueryParamsTableResults') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DeleteDocumentResponse:
"""
Information returned when a document is deleted.
:param str document_id: (optional) The unique identifier of the document.
:param str status: (optional) Status of the document. A deleted document has the
status deleted.
"""
def __init__(
self,
*,
document_id: Optional[str] = None,
status: Optional[str] = None,
) -> None:
"""
Initialize a DeleteDocumentResponse object.
:param str document_id: (optional) The unique identifier of the document.
:param str status: (optional) Status of the document. A deleted document
has the status deleted.
"""
self.document_id = document_id
self.status = status
@classmethod
def from_dict(cls, _dict: Dict) -> 'DeleteDocumentResponse':
"""Initialize a DeleteDocumentResponse object from a json dictionary."""
args = {}
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
if (status := _dict.get('status')) is not None:
args['status'] = status
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DeleteDocumentResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_id') and self.document_id is not None:
_dict['document_id'] = self.document_id
if hasattr(self, 'status') and self.status is not None:
_dict['status'] = self.status
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DeleteDocumentResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DeleteDocumentResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DeleteDocumentResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class StatusEnum(str, Enum):
"""
Status of the document. A deleted document has the status deleted.
"""
DELETED = 'deleted'
class DocumentAccepted:
"""
Information returned after an uploaded document is accepted.
:param str document_id: (optional) The unique identifier of the ingested
document.
:param str status: (optional) Status of the document in the ingestion process. A
status of `processing` is returned for documents that are ingested with a
*version* date before `2019-01-01`. The `pending` status is returned for all
others.
"""
def __init__(
self,
*,
document_id: Optional[str] = None,
status: Optional[str] = None,
) -> None:
"""
Initialize a DocumentAccepted object.
:param str document_id: (optional) The unique identifier of the ingested
document.
:param str status: (optional) Status of the document in the ingestion
process. A status of `processing` is returned for documents that are
ingested with a *version* date before `2019-01-01`. The `pending` status is
returned for all others.
"""
self.document_id = document_id
self.status = status
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentAccepted':
"""Initialize a DocumentAccepted object from a json dictionary."""
args = {}
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
if (status := _dict.get('status')) is not None:
args['status'] = status
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentAccepted object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_id') and self.document_id is not None:
_dict['document_id'] = self.document_id
if hasattr(self, 'status') and self.status is not None:
_dict['status'] = self.status
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentAccepted object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentAccepted') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentAccepted') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class StatusEnum(str, Enum):
"""
Status of the document in the ingestion process. A status of `processing` is
returned for documents that are ingested with a *version* date before
`2019-01-01`. The `pending` status is returned for all others.
"""
PROCESSING = 'processing'
PENDING = 'pending'
class DocumentAttribute:
"""
List of document attributes.
:param str type: (optional) The type of attribute.
:param str text: (optional) The text associated with the attribute.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
"""
def __init__(
self,
*,
type: Optional[str] = None,
text: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
) -> None:
"""
Initialize a DocumentAttribute object.
:param str type: (optional) The type of attribute.
:param str text: (optional) The text associated with the attribute.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
"""
self.type = type
self.text = text
self.location = location
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentAttribute':
"""Initialize a DocumentAttribute object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (text := _dict.get('text')) is not None:
args['text'] = text
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentAttribute object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentAttribute object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentAttribute') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentAttribute') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentClassifier:
"""
Information about a document classifier.
:param str classifier_id: (optional) The Universally Unique Identifier (UUID) of
the document classifier.
:param str name: A human-readable name of the document classifier.
:param str description: (optional) A description of the document classifier.
:param datetime created: (optional) The date that the document classifier was
created.
:param str language: (optional) The language of the training data that is
associated with the document classifier. Language is specified by using the ISO
639-1 language code, such as `en` for English or `ja` for Japanese.
:param List[DocumentClassifierEnrichment] enrichments: (optional) An array of
enrichments to apply to the data that is used to train and test the document
classifier. The output from the enrichments is used as features by the
classifier to classify the document content both during training and at run
time.
:param List[str] recognized_fields: (optional) An array of fields that are used
to train the document classifier. The same set of fields must exist in the
training data, the test data, and the documents where the resulting document
classifier enrichment is applied at run time.
:param str answer_field: (optional) The name of the field from the training and
test data that contains the classification labels.
:param str training_data_file: (optional) Name of the CSV file with training
data that is used to train the document classifier.
:param str test_data_file: (optional) Name of the CSV file with data that is
used to test the document classifier. If no test data is provided, a subset of
the training data is used for testing purposes.
:param ClassifierFederatedModel federated_classification: (optional) An object
with details for creating federated document classifier models.
"""
def __init__(
self,
name: str,
*,
classifier_id: Optional[str] = None,
description: Optional[str] = None,
created: Optional[datetime] = None,
language: Optional[str] = None,
enrichments: Optional[List['DocumentClassifierEnrichment']] = None,
recognized_fields: Optional[List[str]] = None,
answer_field: Optional[str] = None,
training_data_file: Optional[str] = None,
test_data_file: Optional[str] = None,
federated_classification: Optional['ClassifierFederatedModel'] = None,
) -> None:
"""
Initialize a DocumentClassifier object.
:param str name: A human-readable name of the document classifier.
:param str description: (optional) A description of the document
classifier.
:param str language: (optional) The language of the training data that is
associated with the document classifier. Language is specified by using the
ISO 639-1 language code, such as `en` for English or `ja` for Japanese.
:param List[DocumentClassifierEnrichment] enrichments: (optional) An array
of enrichments to apply to the data that is used to train and test the
document classifier. The output from the enrichments is used as features by
the classifier to classify the document content both during training and at
run time.
:param List[str] recognized_fields: (optional) An array of fields that are
used to train the document classifier. The same set of fields must exist in
the training data, the test data, and the documents where the resulting
document classifier enrichment is applied at run time.
:param str answer_field: (optional) The name of the field from the training
and test data that contains the classification labels.
:param str training_data_file: (optional) Name of the CSV file with
training data that is used to train the document classifier.
:param str test_data_file: (optional) Name of the CSV file with data that
is used to test the document classifier. If no test data is provided, a
subset of the training data is used for testing purposes.
:param ClassifierFederatedModel federated_classification: (optional) An
object with details for creating federated document classifier models.
"""
self.classifier_id = classifier_id
self.name = name
self.description = description
self.created = created
self.language = language
self.enrichments = enrichments
self.recognized_fields = recognized_fields
self.answer_field = answer_field
self.training_data_file = training_data_file
self.test_data_file = test_data_file
self.federated_classification = federated_classification
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentClassifier':
"""Initialize a DocumentClassifier object from a json dictionary."""
args = {}
if (classifier_id := _dict.get('classifier_id')) is not None:
args['classifier_id'] = classifier_id
if (name := _dict.get('name')) is not None:
args['name'] = name
else:
raise ValueError(
'Required property \'name\' not present in DocumentClassifier JSON'
)
if (description := _dict.get('description')) is not None:
args['description'] = description
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (language := _dict.get('language')) is not None:
args['language'] = language
if (enrichments := _dict.get('enrichments')) is not None:
args['enrichments'] = [
DocumentClassifierEnrichment.from_dict(v) for v in enrichments
]
if (recognized_fields := _dict.get('recognized_fields')) is not None:
args['recognized_fields'] = recognized_fields
if (answer_field := _dict.get('answer_field')) is not None:
args['answer_field'] = answer_field
if (training_data_file := _dict.get('training_data_file')) is not None:
args['training_data_file'] = training_data_file
if (test_data_file := _dict.get('test_data_file')) is not None:
args['test_data_file'] = test_data_file
if (federated_classification :=
_dict.get('federated_classification')) is not None:
args[
'federated_classification'] = ClassifierFederatedModel.from_dict(
federated_classification)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentClassifier object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'classifier_id') and getattr(
self, 'classifier_id') is not None:
_dict['classifier_id'] = getattr(self, 'classifier_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'language') and self.language is not None:
_dict['language'] = self.language
if hasattr(self, 'enrichments') and self.enrichments is not None:
enrichments_list = []
for v in self.enrichments:
if isinstance(v, dict):
enrichments_list.append(v)
else:
enrichments_list.append(v.to_dict())
_dict['enrichments'] = enrichments_list
if hasattr(self,
'recognized_fields') and self.recognized_fields is not None:
_dict['recognized_fields'] = self.recognized_fields
if hasattr(self, 'answer_field') and self.answer_field is not None:
_dict['answer_field'] = self.answer_field
if hasattr(
self,
'training_data_file') and self.training_data_file is not None:
_dict['training_data_file'] = self.training_data_file
if hasattr(self, 'test_data_file') and self.test_data_file is not None:
_dict['test_data_file'] = self.test_data_file
if hasattr(self, 'federated_classification'
) and self.federated_classification is not None:
if isinstance(self.federated_classification, dict):
_dict[
'federated_classification'] = self.federated_classification
else:
_dict[
'federated_classification'] = self.federated_classification.to_dict(
)
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentClassifier object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentClassifier') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentClassifier') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentClassifierEnrichment:
"""
An object that describes enrichments that are applied to the training and test data
that is used by the document classifier.
:param str enrichment_id: The Universally Unique Identifier (UUID) of the
enrichment.
:param List[str] fields: An array of field names where the enrichment is
applied.
"""
def __init__(
self,
enrichment_id: str,
fields: List[str],
) -> None:
"""
Initialize a DocumentClassifierEnrichment object.
:param str enrichment_id: The Universally Unique Identifier (UUID) of the
enrichment.
:param List[str] fields: An array of field names where the enrichment is
applied.
"""
self.enrichment_id = enrichment_id
self.fields = fields
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentClassifierEnrichment':
"""Initialize a DocumentClassifierEnrichment object from a json dictionary."""
args = {}
if (enrichment_id := _dict.get('enrichment_id')) is not None:
args['enrichment_id'] = enrichment_id
else:
raise ValueError(
'Required property \'enrichment_id\' not present in DocumentClassifierEnrichment JSON'
)
if (fields := _dict.get('fields')) is not None:
args['fields'] = fields
else:
raise ValueError(
'Required property \'fields\' not present in DocumentClassifierEnrichment JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentClassifierEnrichment object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enrichment_id') and self.enrichment_id is not None:
_dict['enrichment_id'] = self.enrichment_id
if hasattr(self, 'fields') and self.fields is not None:
_dict['fields'] = self.fields
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentClassifierEnrichment object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentClassifierEnrichment') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentClassifierEnrichment') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentClassifierModel:
"""
Information about a document classifier model.
:param str model_id: (optional) The Universally Unique Identifier (UUID) of the
document classifier model.
:param str name: A human-readable name of the document classifier model.
:param str description: (optional) A description of the document classifier
model.
:param datetime created: (optional) The date that the document classifier model
was created.
:param datetime updated: (optional) The date that the document classifier model
was last updated.
:param str training_data_file: (optional) Name of the CSV file that contains the
training data that is used to train the document classifier model.
:param str test_data_file: (optional) Name of the CSV file that contains data
that is used to test the document classifier model. If no test data is provided,
a subset of the training data is used for testing purposes.
:param str status: (optional) The status of the training run.
:param ClassifierModelEvaluation evaluation: (optional) An object that contains
information about a trained document classifier model.
:param str enrichment_id: (optional) The Universally Unique Identifier (UUID) of
the enrichment that is generated by this document classifier model.
:param datetime deployed_at: (optional) The date that the document classifier
model was deployed.
"""
def __init__(
self,
name: str,
*,
model_id: Optional[str] = None,
description: Optional[str] = None,
created: Optional[datetime] = None,
updated: Optional[datetime] = None,
training_data_file: Optional[str] = None,
test_data_file: Optional[str] = None,
status: Optional[str] = None,
evaluation: Optional['ClassifierModelEvaluation'] = None,
enrichment_id: Optional[str] = None,
deployed_at: Optional[datetime] = None,
) -> None:
"""
Initialize a DocumentClassifierModel object.
:param str name: A human-readable name of the document classifier model.
:param str description: (optional) A description of the document classifier
model.
:param str training_data_file: (optional) Name of the CSV file that
contains the training data that is used to train the document classifier
model.
:param str test_data_file: (optional) Name of the CSV file that contains
data that is used to test the document classifier model. If no test data is
provided, a subset of the training data is used for testing purposes.
:param str status: (optional) The status of the training run.
:param ClassifierModelEvaluation evaluation: (optional) An object that
contains information about a trained document classifier model.
:param str enrichment_id: (optional) The Universally Unique Identifier
(UUID) of the enrichment that is generated by this document classifier
model.
"""
self.model_id = model_id
self.name = name
self.description = description
self.created = created
self.updated = updated
self.training_data_file = training_data_file
self.test_data_file = test_data_file
self.status = status
self.evaluation = evaluation
self.enrichment_id = enrichment_id
self.deployed_at = deployed_at
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentClassifierModel':
"""Initialize a DocumentClassifierModel object from a json dictionary."""
args = {}
if (model_id := _dict.get('model_id')) is not None:
args['model_id'] = model_id
if (name := _dict.get('name')) is not None:
args['name'] = name
else:
raise ValueError(
'Required property \'name\' not present in DocumentClassifierModel JSON'
)
if (description := _dict.get('description')) is not None:
args['description'] = description
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (updated := _dict.get('updated')) is not None:
args['updated'] = string_to_datetime(updated)
if (training_data_file := _dict.get('training_data_file')) is not None:
args['training_data_file'] = training_data_file
if (test_data_file := _dict.get('test_data_file')) is not None:
args['test_data_file'] = test_data_file
if (status := _dict.get('status')) is not None:
args['status'] = status
if (evaluation := _dict.get('evaluation')) is not None:
args['evaluation'] = ClassifierModelEvaluation.from_dict(evaluation)
if (enrichment_id := _dict.get('enrichment_id')) is not None:
args['enrichment_id'] = enrichment_id
if (deployed_at := _dict.get('deployed_at')) is not None:
args['deployed_at'] = string_to_datetime(deployed_at)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentClassifierModel object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'model_id') and getattr(self, 'model_id') is not None:
_dict['model_id'] = getattr(self, 'model_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'updated') and getattr(self, 'updated') is not None:
_dict['updated'] = datetime_to_string(getattr(self, 'updated'))
if hasattr(
self,
'training_data_file') and self.training_data_file is not None:
_dict['training_data_file'] = self.training_data_file
if hasattr(self, 'test_data_file') and self.test_data_file is not None:
_dict['test_data_file'] = self.test_data_file
if hasattr(self, 'status') and self.status is not None:
_dict['status'] = self.status
if hasattr(self, 'evaluation') and self.evaluation is not None:
if isinstance(self.evaluation, dict):
_dict['evaluation'] = self.evaluation
else:
_dict['evaluation'] = self.evaluation.to_dict()
if hasattr(self, 'enrichment_id') and self.enrichment_id is not None:
_dict['enrichment_id'] = self.enrichment_id
if hasattr(self, 'deployed_at') and getattr(self,
'deployed_at') is not None:
_dict['deployed_at'] = datetime_to_string(
getattr(self, 'deployed_at'))
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentClassifierModel object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentClassifierModel') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentClassifierModel') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class StatusEnum(str, Enum):
"""
The status of the training run.
"""
TRAINING = 'training'
AVAILABLE = 'available'
FAILED = 'failed'
class DocumentClassifierModels:
"""
An object that contains a list of document classifier model definitions.
:param List[DocumentClassifierModel] models: (optional) An array of document
classifier model definitions.
"""
def __init__(
self,
*,
models: Optional[List['DocumentClassifierModel']] = None,
) -> None:
"""
Initialize a DocumentClassifierModels object.
:param List[DocumentClassifierModel] models: (optional) An array of
document classifier model definitions.
"""
self.models = models
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentClassifierModels':
"""Initialize a DocumentClassifierModels object from a json dictionary."""
args = {}
if (models := _dict.get('models')) is not None:
args['models'] = [
DocumentClassifierModel.from_dict(v) for v in models
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentClassifierModels object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'models') and self.models is not None:
models_list = []
for v in self.models:
if isinstance(v, dict):
models_list.append(v)
else:
models_list.append(v.to_dict())
_dict['models'] = models_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentClassifierModels object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentClassifierModels') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentClassifierModels') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentClassifiers:
"""
An object that contains a list of document classifier definitions.
:param List[DocumentClassifier] classifiers: (optional) An array of document
classifier definitions.
"""
def __init__(
self,
*,
classifiers: Optional[List['DocumentClassifier']] = None,
) -> None:
"""
Initialize a DocumentClassifiers object.
:param List[DocumentClassifier] classifiers: (optional) An array of
document classifier definitions.
"""
self.classifiers = classifiers
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentClassifiers':
"""Initialize a DocumentClassifiers object from a json dictionary."""
args = {}
if (classifiers := _dict.get('classifiers')) is not None:
args['classifiers'] = [
DocumentClassifier.from_dict(v) for v in classifiers
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentClassifiers object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'classifiers') and self.classifiers is not None:
classifiers_list = []
for v in self.classifiers:
if isinstance(v, dict):
classifiers_list.append(v)
else:
classifiers_list.append(v.to_dict())
_dict['classifiers'] = classifiers_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentClassifiers object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentClassifiers') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentClassifiers') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentDetails:
"""
Information about a document.
:param str document_id: (optional) The unique identifier of the document.
:param datetime created: (optional) Date and time that the document is added to
the collection. For a child document, the date and time when the process that
generates the child document runs. The date-time format is
`yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`.
:param datetime updated: (optional) Date and time that the document is finished
being processed and is indexed. This date changes whenever the document is
reprocessed, including for enrichment changes. The date-time format is
`yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`.
:param str status: (optional) The status of the ingestion of the document. The
possible values are:
* `available`: Ingestion is finished and the document is indexed.
* `failed`: Ingestion is finished, but the document is not indexed because of an
error.
* `pending`: The document is uploaded, but the ingestion process is not started.
* `processing`: Ingestion is in progress.
:param List[Notice] notices: (optional) Array of JSON objects for notices,
meaning warning or error messages, that are produced by the document ingestion
process. The array does not include notices that are produced for child
documents that are generated when a document is processed.
:param DocumentDetailsChildren children: (optional) Information about the child
documents that are generated from a single document during ingestion or other
processing.
:param str filename: (optional) Name of the original source file (if available).
:param str file_type: (optional) The type of the original source file, such as
`csv`, `excel`, `html`, `json`, `pdf`, `text`, `word`, and so on.
:param str sha256: (optional) The SHA-256 hash of the original source file. The
hash is formatted as a hexadecimal string.
"""
def __init__(
self,
*,
document_id: Optional[str] = None,
created: Optional[datetime] = None,
updated: Optional[datetime] = None,
status: Optional[str] = None,
notices: Optional[List['Notice']] = None,
children: Optional['DocumentDetailsChildren'] = None,
filename: Optional[str] = None,
file_type: Optional[str] = None,
sha256: Optional[str] = None,
) -> None:
"""
Initialize a DocumentDetails object.
:param str status: (optional) The status of the ingestion of the document.
The possible values are:
* `available`: Ingestion is finished and the document is indexed.
* `failed`: Ingestion is finished, but the document is not indexed because
of an error.
* `pending`: The document is uploaded, but the ingestion process is not
started.
* `processing`: Ingestion is in progress.
:param List[Notice] notices: (optional) Array of JSON objects for notices,
meaning warning or error messages, that are produced by the document
ingestion process. The array does not include notices that are produced for
child documents that are generated when a document is processed.
:param DocumentDetailsChildren children: (optional) Information about the
child documents that are generated from a single document during ingestion
or other processing.
:param str filename: (optional) Name of the original source file (if
available).
:param str file_type: (optional) The type of the original source file, such
as `csv`, `excel`, `html`, `json`, `pdf`, `text`, `word`, and so on.
:param str sha256: (optional) The SHA-256 hash of the original source file.
The hash is formatted as a hexadecimal string.
"""
self.document_id = document_id
self.created = created
self.updated = updated
self.status = status
self.notices = notices
self.children = children
self.filename = filename
self.file_type = file_type
self.sha256 = sha256
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentDetails':
"""Initialize a DocumentDetails object from a json dictionary."""
args = {}
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (updated := _dict.get('updated')) is not None:
args['updated'] = string_to_datetime(updated)
if (status := _dict.get('status')) is not None:
args['status'] = status
if (notices := _dict.get('notices')) is not None:
args['notices'] = [Notice.from_dict(v) for v in notices]
if (children := _dict.get('children')) is not None:
args['children'] = DocumentDetailsChildren.from_dict(children)
if (filename := _dict.get('filename')) is not None:
args['filename'] = filename
if (file_type := _dict.get('file_type')) is not None:
args['file_type'] = file_type
if (sha256 := _dict.get('sha256')) is not None:
args['sha256'] = sha256
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentDetails object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_id') and getattr(self,
'document_id') is not None:
_dict['document_id'] = getattr(self, 'document_id')
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'updated') and getattr(self, 'updated') is not None:
_dict['updated'] = datetime_to_string(getattr(self, 'updated'))
if hasattr(self, 'status') and self.status is not None:
_dict['status'] = self.status
if hasattr(self, 'notices') and self.notices is not None:
notices_list = []
for v in self.notices:
if isinstance(v, dict):
notices_list.append(v)
else:
notices_list.append(v.to_dict())
_dict['notices'] = notices_list
if hasattr(self, 'children') and self.children is not None:
if isinstance(self.children, dict):
_dict['children'] = self.children
else:
_dict['children'] = self.children.to_dict()
if hasattr(self, 'filename') and self.filename is not None:
_dict['filename'] = self.filename
if hasattr(self, 'file_type') and self.file_type is not None:
_dict['file_type'] = self.file_type
if hasattr(self, 'sha256') and self.sha256 is not None:
_dict['sha256'] = self.sha256
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentDetails object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentDetails') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentDetails') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class StatusEnum(str, Enum):
"""
The status of the ingestion of the document. The possible values are:
* `available`: Ingestion is finished and the document is indexed.
* `failed`: Ingestion is finished, but the document is not indexed because of an
error.
* `pending`: The document is uploaded, but the ingestion process is not started.
* `processing`: Ingestion is in progress.
"""
AVAILABLE = 'available'
FAILED = 'failed'
PENDING = 'pending'
PROCESSING = 'processing'
class DocumentDetailsChildren:
"""
Information about the child documents that are generated from a single document during
ingestion or other processing.
:param bool have_notices: (optional) Indicates whether the child documents have
any notices. The value is `false` if the document does not have child documents.
:param int count: (optional) Number of child documents. The value is `0` when
processing of the document doesn't generate any child documents.
"""
def __init__(
self,
*,
have_notices: Optional[bool] = None,
count: Optional[int] = None,
) -> None:
"""
Initialize a DocumentDetailsChildren object.
:param bool have_notices: (optional) Indicates whether the child documents
have any notices. The value is `false` if the document does not have child
documents.
:param int count: (optional) Number of child documents. The value is `0`
when processing of the document doesn't generate any child documents.
"""
self.have_notices = have_notices
self.count = count
@classmethod
def from_dict(cls, _dict: Dict) -> 'DocumentDetailsChildren':
"""Initialize a DocumentDetailsChildren object from a json dictionary."""
args = {}
if (have_notices := _dict.get('have_notices')) is not None:
args['have_notices'] = have_notices
if (count := _dict.get('count')) is not None:
args['count'] = count
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a DocumentDetailsChildren object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'have_notices') and self.have_notices is not None:
_dict['have_notices'] = self.have_notices
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this DocumentDetailsChildren object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'DocumentDetailsChildren') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'DocumentDetailsChildren') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Enrichment:
"""
Information about a specific enrichment.
:param str enrichment_id: (optional) The Universally Unique Identifier (UUID) of
this enrichment.
:param str name: (optional) The human readable name for this enrichment.
:param str description: (optional) The description of this enrichment.
:param str type: (optional) The type of this enrichment.
:param EnrichmentOptions options: (optional) An object that contains options for
the current enrichment. Starting with version `2020-08-30`, the enrichment
options are not included in responses from the List Enrichments method.
"""
def __init__(
self,
*,
enrichment_id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
type: Optional[str] = None,
options: Optional['EnrichmentOptions'] = None,
) -> None:
"""
Initialize a Enrichment object.
:param str name: (optional) The human readable name for this enrichment.
:param str description: (optional) The description of this enrichment.
:param str type: (optional) The type of this enrichment.
:param EnrichmentOptions options: (optional) An object that contains
options for the current enrichment. Starting with version `2020-08-30`, the
enrichment options are not included in responses from the List Enrichments
method.
"""
self.enrichment_id = enrichment_id
self.name = name
self.description = description
self.type = type
self.options = options
@classmethod
def from_dict(cls, _dict: Dict) -> 'Enrichment':
"""Initialize a Enrichment object from a json dictionary."""
args = {}
if (enrichment_id := _dict.get('enrichment_id')) is not None:
args['enrichment_id'] = enrichment_id
if (name := _dict.get('name')) is not None:
args['name'] = name
if (description := _dict.get('description')) is not None:
args['description'] = description
if (type := _dict.get('type')) is not None:
args['type'] = type
if (options := _dict.get('options')) is not None:
args['options'] = EnrichmentOptions.from_dict(options)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Enrichment object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enrichment_id') and getattr(
self, 'enrichment_id') is not None:
_dict['enrichment_id'] = getattr(self, 'enrichment_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'options') and self.options is not None:
if isinstance(self.options, dict):
_dict['options'] = self.options
else:
_dict['options'] = self.options.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Enrichment object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Enrichment') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Enrichment') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TypeEnum(str, Enum):
"""
The type of this enrichment.
"""
PART_OF_SPEECH = 'part_of_speech'
SENTIMENT = 'sentiment'
NATURAL_LANGUAGE_UNDERSTANDING = 'natural_language_understanding'
DICTIONARY = 'dictionary'
REGULAR_EXPRESSION = 'regular_expression'
UIMA_ANNOTATOR = 'uima_annotator'
RULE_BASED = 'rule_based'
WATSON_KNOWLEDGE_STUDIO_MODEL = 'watson_knowledge_studio_model'
CLASSIFIER = 'classifier'
WEBHOOK = 'webhook'
SENTENCE_CLASSIFIER = 'sentence_classifier'
class EnrichmentOptions:
"""
An object that contains options for the current enrichment. Starting with version
`2020-08-30`, the enrichment options are not included in responses from the List
Enrichments method.
:param List[str] languages: (optional) An array of supported languages for this
enrichment. When creating an enrichment, only specify a language that is used by
the model or in the dictionary. Required when **type** is `dictionary`. Optional
when **type** is `rule_based`. Not valid when creating any other type of
enrichment.
:param str entity_type: (optional) The name of the entity type. This value is
used as the field name in the index. Required when **type** is `dictionary` or
`regular_expression`. Not valid when creating any other type of enrichment.
:param str regular_expression: (optional) The regular expression to apply for
this enrichment. Required when **type** is `regular_expression`. Not valid when
creating any other type of enrichment.
:param str result_field: (optional) The name of the result document field that
this enrichment creates. Required when **type** is `rule_based` or `classifier`.
Not valid when creating any other type of enrichment.
:param str classifier_id: (optional) The Universally Unique Identifier (UUID) of
the document classifier. Required when **type** is `classifier`. Not valid when
creating any other type of enrichment.
:param str model_id: (optional) The Universally Unique Identifier (UUID) of the
document classifier model. Required when **type** is `classifier`. Not valid
when creating any other type of enrichment.
:param float confidence_threshold: (optional) Specifies a threshold. Only
classes with evaluation confidence scores that are higher than the specified
threshold are included in the output. Optional when **type** is `classifier`.
Not valid when creating any other type of enrichment.
:param int top_k: (optional) Evaluates only the classes that fall in the top set
of results when ranked by confidence. For example, if set to `5`, then the top
five classes for each document are evaluated. If set to 0, the
**confidence_threshold** is used to determine the predicted classes. Optional
when **type** is `classifier`. Not valid when creating any other type of
enrichment.
:param str url: (optional) A URL that uses the SSL protocol (begins with https)
for the webhook. Required when type is `webhook`. Not valid when creating any
other type of enrichment.
:param str version: (optional) The Discovery API version that allows to
distinguish the schema. The version is specified in the `yyyy-mm-dd` format.
Optional when `type` is `webhook`. Not valid when creating any other type of
enrichment.
:param str secret: (optional) A private key can be included in the request to
authenticate with the external service. The maximum length is 1,024 characters.
Optional when `type` is `webhook`. Not valid when creating any other type of
enrichment.
:param WebhookHeader headers_: (optional) An array of headers to pass with the
HTTP request. Optional when `type` is `webhook`. Not valid when creating any
other type of enrichment.
:param str location_encoding: (optional) Discovery calculates offsets of the
text's location with this encoding type in documents. Use the same location
encoding type in both Discovery and external enrichment for a document.
These encoding types are supported: `utf-8`, `utf-16`, and `utf-32`. Optional
when `type` is `webhook`. Not valid when creating any other type of enrichment.
"""
def __init__(
self,
*,
languages: Optional[List[str]] = None,
entity_type: Optional[str] = None,
regular_expression: Optional[str] = None,
result_field: Optional[str] = None,
classifier_id: Optional[str] = None,
model_id: Optional[str] = None,
confidence_threshold: Optional[float] = None,
top_k: Optional[int] = None,
url: Optional[str] = None,
version: Optional[str] = None,
secret: Optional[str] = None,
headers_: Optional['WebhookHeader'] = None,
location_encoding: Optional[str] = None,
) -> None:
"""
Initialize a EnrichmentOptions object.
:param List[str] languages: (optional) An array of supported languages for
this enrichment. When creating an enrichment, only specify a language that
is used by the model or in the dictionary. Required when **type** is
`dictionary`. Optional when **type** is `rule_based`. Not valid when
creating any other type of enrichment.
:param str entity_type: (optional) The name of the entity type. This value
is used as the field name in the index. Required when **type** is
`dictionary` or `regular_expression`. Not valid when creating any other
type of enrichment.
:param str regular_expression: (optional) The regular expression to apply
for this enrichment. Required when **type** is `regular_expression`. Not
valid when creating any other type of enrichment.
:param str result_field: (optional) The name of the result document field
that this enrichment creates. Required when **type** is `rule_based` or
`classifier`. Not valid when creating any other type of enrichment.
:param str classifier_id: (optional) The Universally Unique Identifier
(UUID) of the document classifier. Required when **type** is `classifier`.
Not valid when creating any other type of enrichment.
:param str model_id: (optional) The Universally Unique Identifier (UUID) of
the document classifier model. Required when **type** is `classifier`. Not
valid when creating any other type of enrichment.
:param float confidence_threshold: (optional) Specifies a threshold. Only
classes with evaluation confidence scores that are higher than the
specified threshold are included in the output. Optional when **type** is
`classifier`. Not valid when creating any other type of enrichment.
:param int top_k: (optional) Evaluates only the classes that fall in the
top set of results when ranked by confidence. For example, if set to `5`,
then the top five classes for each document are evaluated. If set to 0, the
**confidence_threshold** is used to determine the predicted classes.
Optional when **type** is `classifier`. Not valid when creating any other
type of enrichment.
:param str url: (optional) A URL that uses the SSL protocol (begins with
https) for the webhook. Required when type is `webhook`. Not valid when
creating any other type of enrichment.
:param str version: (optional) The Discovery API version that allows to
distinguish the schema. The version is specified in the `yyyy-mm-dd`
format. Optional when `type` is `webhook`. Not valid when creating any
other type of enrichment.
:param str secret: (optional) A private key can be included in the request
to authenticate with the external service. The maximum length is 1,024
characters. Optional when `type` is `webhook`. Not valid when creating any
other type of enrichment.
:param WebhookHeader headers_: (optional) An array of headers to pass with
the HTTP request. Optional when `type` is `webhook`. Not valid when
creating any other type of enrichment.
:param str location_encoding: (optional) Discovery calculates offsets of
the text's location with this encoding type in documents. Use the same
location encoding type in both Discovery and external enrichment for a
document.
These encoding types are supported: `utf-8`, `utf-16`, and `utf-32`.
Optional when `type` is `webhook`. Not valid when creating any other type
of enrichment.
"""
self.languages = languages
self.entity_type = entity_type
self.regular_expression = regular_expression
self.result_field = result_field
self.classifier_id = classifier_id
self.model_id = model_id
self.confidence_threshold = confidence_threshold
self.top_k = top_k
self.url = url
self.version = version
self.secret = secret
self.headers_ = headers_
self.location_encoding = location_encoding
@classmethod
def from_dict(cls, _dict: Dict) -> 'EnrichmentOptions':
"""Initialize a EnrichmentOptions object from a json dictionary."""
args = {}
if (languages := _dict.get('languages')) is not None:
args['languages'] = languages
if (entity_type := _dict.get('entity_type')) is not None:
args['entity_type'] = entity_type
if (regular_expression := _dict.get('regular_expression')) is not None:
args['regular_expression'] = regular_expression
if (result_field := _dict.get('result_field')) is not None:
args['result_field'] = result_field
if (classifier_id := _dict.get('classifier_id')) is not None:
args['classifier_id'] = classifier_id
if (model_id := _dict.get('model_id')) is not None:
args['model_id'] = model_id
if (confidence_threshold :=
_dict.get('confidence_threshold')) is not None:
args['confidence_threshold'] = confidence_threshold
if (top_k := _dict.get('top_k')) is not None:
args['top_k'] = top_k
if (url := _dict.get('url')) is not None:
args['url'] = url
if (version := _dict.get('version')) is not None:
args['version'] = version
if (secret := _dict.get('secret')) is not None:
args['secret'] = secret
if (headers_ := _dict.get('headers')) is not None:
args['headers_'] = WebhookHeader.from_dict(headers_)
if (location_encoding := _dict.get('location_encoding')) is not None:
args['location_encoding'] = location_encoding
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a EnrichmentOptions object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'languages') and self.languages is not None:
_dict['languages'] = self.languages
if hasattr(self, 'entity_type') and self.entity_type is not None:
_dict['entity_type'] = self.entity_type
if hasattr(
self,
'regular_expression') and self.regular_expression is not None:
_dict['regular_expression'] = self.regular_expression
if hasattr(self, 'result_field') and self.result_field is not None:
_dict['result_field'] = self.result_field
if hasattr(self, 'classifier_id') and self.classifier_id is not None:
_dict['classifier_id'] = self.classifier_id
if hasattr(self, 'model_id') and self.model_id is not None:
_dict['model_id'] = self.model_id
if hasattr(self, 'confidence_threshold'
) and self.confidence_threshold is not None:
_dict['confidence_threshold'] = self.confidence_threshold
if hasattr(self, 'top_k') and self.top_k is not None:
_dict['top_k'] = self.top_k
if hasattr(self, 'url') and self.url is not None:
_dict['url'] = self.url
if hasattr(self, 'version') and self.version is not None:
_dict['version'] = self.version
if hasattr(self, 'secret') and self.secret is not None:
_dict['secret'] = self.secret
if hasattr(self, 'headers_') and self.headers_ is not None:
if isinstance(self.headers_, dict):
_dict['headers'] = self.headers_
else:
_dict['headers'] = self.headers_.to_dict()
if hasattr(self,
'location_encoding') and self.location_encoding is not None:
_dict['location_encoding'] = self.location_encoding
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this EnrichmentOptions object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'EnrichmentOptions') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'EnrichmentOptions') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Enrichments:
"""
An object that contains an array of enrichment definitions.
:param List[Enrichment] enrichments: (optional) An array of enrichment
definitions.
"""
def __init__(
self,
*,
enrichments: Optional[List['Enrichment']] = None,
) -> None:
"""
Initialize a Enrichments object.
:param List[Enrichment] enrichments: (optional) An array of enrichment
definitions.
"""
self.enrichments = enrichments
@classmethod
def from_dict(cls, _dict: Dict) -> 'Enrichments':
"""Initialize a Enrichments object from a json dictionary."""
args = {}
if (enrichments := _dict.get('enrichments')) is not None:
args['enrichments'] = [Enrichment.from_dict(v) for v in enrichments]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Enrichments object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enrichments') and self.enrichments is not None:
enrichments_list = []
for v in self.enrichments:
if isinstance(v, dict):
enrichments_list.append(v)
else:
enrichments_list.append(v.to_dict())
_dict['enrichments'] = enrichments_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Enrichments object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Enrichments') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Enrichments') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Expansion:
"""
An expansion definition. Each object respresents one set of expandable strings. For
example, you could have expansions for the word `hot` in one object, and expansions
for the word `cold` in another. Follow these guidelines when you add terms:
* Specify the terms in lowercase. Lowercase terms expand to uppercase.
* Multiword terms are supported only in bidirectional expansions.
* Do not specify a term that is specified in the stop words list for the collection.
:param List[str] input_terms: (optional) A list of terms that will be expanded
for this expansion. If specified, only the items in this list are expanded.
:param List[str] expanded_terms: A list of terms that this expansion will be
expanded to. If specified without **input_terms**, the list also functions as
the input term list.
"""
def __init__(
self,
expanded_terms: List[str],
*,
input_terms: Optional[List[str]] = None,
) -> None:
"""
Initialize a Expansion object.
:param List[str] expanded_terms: A list of terms that this expansion will
be expanded to. If specified without **input_terms**, the list also
functions as the input term list.
:param List[str] input_terms: (optional) A list of terms that will be
expanded for this expansion. If specified, only the items in this list are
expanded.
"""
self.input_terms = input_terms
self.expanded_terms = expanded_terms
@classmethod
def from_dict(cls, _dict: Dict) -> 'Expansion':
"""Initialize a Expansion object from a json dictionary."""
args = {}
if (input_terms := _dict.get('input_terms')) is not None:
args['input_terms'] = input_terms
if (expanded_terms := _dict.get('expanded_terms')) is not None:
args['expanded_terms'] = expanded_terms
else:
raise ValueError(
'Required property \'expanded_terms\' not present in Expansion JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Expansion object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'input_terms') and self.input_terms is not None:
_dict['input_terms'] = self.input_terms
if hasattr(self, 'expanded_terms') and self.expanded_terms is not None:
_dict['expanded_terms'] = self.expanded_terms
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Expansion object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Expansion') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Expansion') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Expansions:
"""
The query expansion definitions for the specified collection.
:param List[Expansion] expansions: An array of query expansion definitions.
Each object in the **expansions** array represents a term or set of terms that
will be expanded into other terms. Each expansion object can be configured as
`bidirectional` or `unidirectional`.
* **Bidirectional**: Each entry in the `expanded_terms` list expands to include
all expanded terms. For example, a query for `ibm` expands to `ibm OR
international business machines OR big blue`.
* **Unidirectional**: The terms in `input_terms` in the query are replaced by
the terms in `expanded_terms`. For example, a query for the often misused term
`on premise` is converted to `on premises OR on-premises` and does not contain
the original term. If you want an input term to be included in the query, then
repeat the input term in the expanded terms list.
"""
def __init__(
self,
expansions: List['Expansion'],
) -> None:
"""
Initialize a Expansions object.
:param List[Expansion] expansions: An array of query expansion definitions.
Each object in the **expansions** array represents a term or set of terms
that will be expanded into other terms. Each expansion object can be
configured as `bidirectional` or `unidirectional`.
* **Bidirectional**: Each entry in the `expanded_terms` list expands to
include all expanded terms. For example, a query for `ibm` expands to `ibm
OR international business machines OR big blue`.
* **Unidirectional**: The terms in `input_terms` in the query are replaced
by the terms in `expanded_terms`. For example, a query for the often
misused term `on premise` is converted to `on premises OR on-premises` and
does not contain the original term. If you want an input term to be
included in the query, then repeat the input term in the expanded terms
list.
"""
self.expansions = expansions
@classmethod
def from_dict(cls, _dict: Dict) -> 'Expansions':
"""Initialize a Expansions object from a json dictionary."""
args = {}
if (expansions := _dict.get('expansions')) is not None:
args['expansions'] = [Expansion.from_dict(v) for v in expansions]
else:
raise ValueError(
'Required property \'expansions\' not present in Expansions JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Expansions object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'expansions') and self.expansions is not None:
expansions_list = []
for v in self.expansions:
if isinstance(v, dict):
expansions_list.append(v)
else:
expansions_list.append(v.to_dict())
_dict['expansions'] = expansions_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Expansions object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Expansions') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Expansions') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Field:
"""
Object that contains field details.
:param str field: (optional) The name of the field.
:param str type: (optional) The type of the field.
:param str collection_id: (optional) The collection Id of the collection where
the field was found.
"""
def __init__(
self,
*,
field: Optional[str] = None,
type: Optional[str] = None,
collection_id: Optional[str] = None,
) -> None:
"""
Initialize a Field object.
"""
self.field = field
self.type = type
self.collection_id = collection_id
@classmethod
def from_dict(cls, _dict: Dict) -> 'Field':
"""Initialize a Field object from a json dictionary."""
args = {}
if (field := _dict.get('field')) is not None:
args['field'] = field
if (type := _dict.get('type')) is not None:
args['type'] = type
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Field object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'field') and getattr(self, 'field') is not None:
_dict['field'] = getattr(self, 'field')
if hasattr(self, 'type') and getattr(self, 'type') is not None:
_dict['type'] = getattr(self, 'type')
if hasattr(self, 'collection_id') and getattr(
self, 'collection_id') is not None:
_dict['collection_id'] = getattr(self, 'collection_id')
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Field object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Field') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Field') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TypeEnum(str, Enum):
"""
The type of the field.
"""
NESTED = 'nested'
STRING = 'string'
DATE = 'date'
LONG = 'long'
INTEGER = 'integer'
SHORT = 'short'
BYTE = 'byte'
DOUBLE = 'double'
FLOAT = 'float'
BOOLEAN = 'boolean'
BINARY = 'binary'
class ListBatchesResponse:
"""
An object that contains a list of batches that are ready for enrichment by the
external application.
:param List[BatchDetails] batches: (optional) An array that lists the batches in
a collection.
"""
def __init__(
self,
*,
batches: Optional[List['BatchDetails']] = None,
) -> None:
"""
Initialize a ListBatchesResponse object.
:param List[BatchDetails] batches: (optional) An array that lists the
batches in a collection.
"""
self.batches = batches
@classmethod
def from_dict(cls, _dict: Dict) -> 'ListBatchesResponse':
"""Initialize a ListBatchesResponse object from a json dictionary."""
args = {}
if (batches := _dict.get('batches')) is not None:
args['batches'] = [BatchDetails.from_dict(v) for v in batches]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ListBatchesResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'batches') and self.batches is not None:
batches_list = []
for v in self.batches:
if isinstance(v, dict):
batches_list.append(v)
else:
batches_list.append(v.to_dict())
_dict['batches'] = batches_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ListBatchesResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ListBatchesResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ListBatchesResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ListCollectionsResponse:
"""
Response object that contains an array of collection details.
:param List[Collection] collections: (optional) An array that contains
information about each collection in the project.
"""
def __init__(
self,
*,
collections: Optional[List['Collection']] = None,
) -> None:
"""
Initialize a ListCollectionsResponse object.
:param List[Collection] collections: (optional) An array that contains
information about each collection in the project.
"""
self.collections = collections
@classmethod
def from_dict(cls, _dict: Dict) -> 'ListCollectionsResponse':
"""Initialize a ListCollectionsResponse object from a json dictionary."""
args = {}
if (collections := _dict.get('collections')) is not None:
args['collections'] = [Collection.from_dict(v) for v in collections]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ListCollectionsResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'collections') and self.collections is not None:
collections_list = []
for v in self.collections:
if isinstance(v, dict):
collections_list.append(v)
else:
collections_list.append(v.to_dict())
_dict['collections'] = collections_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ListCollectionsResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ListCollectionsResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ListCollectionsResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ListDocumentsResponse:
"""
Response object that contains an array of documents.
:param int matching_results: (optional) The number of matching results for the
document query.
:param List[DocumentDetails] documents: (optional) An array that lists the
documents in a collection. Only the document ID of each document is returned in
the list. You can use the [Get document](#getdocument) method to get more
information about an individual document.
"""
def __init__(
self,
*,
matching_results: Optional[int] = None,
documents: Optional[List['DocumentDetails']] = None,
) -> None:
"""
Initialize a ListDocumentsResponse object.
:param int matching_results: (optional) The number of matching results for
the document query.
:param List[DocumentDetails] documents: (optional) An array that lists the
documents in a collection. Only the document ID of each document is
returned in the list. You can use the [Get document](#getdocument) method
to get more information about an individual document.
"""
self.matching_results = matching_results
self.documents = documents
@classmethod
def from_dict(cls, _dict: Dict) -> 'ListDocumentsResponse':
"""Initialize a ListDocumentsResponse object from a json dictionary."""
args = {}
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
if (documents := _dict.get('documents')) is not None:
args['documents'] = [
DocumentDetails.from_dict(v) for v in documents
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ListDocumentsResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'documents') and self.documents is not None:
documents_list = []
for v in self.documents:
if isinstance(v, dict):
documents_list.append(v)
else:
documents_list.append(v.to_dict())
_dict['documents'] = documents_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ListDocumentsResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ListDocumentsResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ListDocumentsResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ListFieldsResponse:
"""
The list of fetched fields.
The fields are returned using a fully qualified name format, however, the format
differs slightly from that used by the query operations.
* Fields which contain nested objects are assigned a type of "nested".
* Fields which belong to a nested object are prefixed with `.properties` (for
example, `warnings.properties.severity` means that the `warnings` object has a
property called `severity`).
:param List[Field] fields: (optional) An array that contains information about
each field in the collections.
"""
def __init__(
self,
*,
fields: Optional[List['Field']] = None,
) -> None:
"""
Initialize a ListFieldsResponse object.
:param List[Field] fields: (optional) An array that contains information
about each field in the collections.
"""
self.fields = fields
@classmethod
def from_dict(cls, _dict: Dict) -> 'ListFieldsResponse':
"""Initialize a ListFieldsResponse object from a json dictionary."""
args = {}
if (fields := _dict.get('fields')) is not None:
args['fields'] = [Field.from_dict(v) for v in fields]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ListFieldsResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'fields') and self.fields is not None:
fields_list = []
for v in self.fields:
if isinstance(v, dict):
fields_list.append(v)
else:
fields_list.append(v.to_dict())
_dict['fields'] = fields_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ListFieldsResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ListFieldsResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ListFieldsResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ListProjectsResponse:
"""
A list of projects in this instance.
:param List[ProjectListDetails] projects: (optional) An array of project
details.
"""
def __init__(
self,
*,
projects: Optional[List['ProjectListDetails']] = None,
) -> None:
"""
Initialize a ListProjectsResponse object.
:param List[ProjectListDetails] projects: (optional) An array of project
details.
"""
self.projects = projects
@classmethod
def from_dict(cls, _dict: Dict) -> 'ListProjectsResponse':
"""Initialize a ListProjectsResponse object from a json dictionary."""
args = {}
if (projects := _dict.get('projects')) is not None:
args['projects'] = [
ProjectListDetails.from_dict(v) for v in projects
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ListProjectsResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'projects') and self.projects is not None:
projects_list = []
for v in self.projects:
if isinstance(v, dict):
projects_list.append(v)
else:
projects_list.append(v.to_dict())
_dict['projects'] = projects_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ListProjectsResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ListProjectsResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ListProjectsResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ModelEvaluationMacroAverage:
"""
A macro-average computes metric independently for each class and then takes the
average. Class refers to the classification label that is specified in the
**answer_field**.
:param float precision: A metric that measures how many of the overall documents
are classified correctly.
:param float recall: A metric that measures how often documents that should be
classified into certain classes are classified into those classes.
:param float f1: A metric that measures whether the optimal balance between
precision and recall is reached. The F1 score can be interpreted as a weighted
average of the precision and recall values. An F1 score reaches its best value
at 1 and worst value at 0.
"""
def __init__(
self,
precision: float,
recall: float,
f1: float,
) -> None:
"""
Initialize a ModelEvaluationMacroAverage object.
:param float precision: A metric that measures how many of the overall
documents are classified correctly.
:param float recall: A metric that measures how often documents that should
be classified into certain classes are classified into those classes.
:param float f1: A metric that measures whether the optimal balance between
precision and recall is reached. The F1 score can be interpreted as a
weighted average of the precision and recall values. An F1 score reaches
its best value at 1 and worst value at 0.
"""
self.precision = precision
self.recall = recall
self.f1 = f1
@classmethod
def from_dict(cls, _dict: Dict) -> 'ModelEvaluationMacroAverage':
"""Initialize a ModelEvaluationMacroAverage object from a json dictionary."""
args = {}
if (precision := _dict.get('precision')) is not None:
args['precision'] = precision
else:
raise ValueError(
'Required property \'precision\' not present in ModelEvaluationMacroAverage JSON'
)
if (recall := _dict.get('recall')) is not None:
args['recall'] = recall
else:
raise ValueError(
'Required property \'recall\' not present in ModelEvaluationMacroAverage JSON'
)
if (f1 := _dict.get('f1')) is not None:
args['f1'] = f1
else:
raise ValueError(
'Required property \'f1\' not present in ModelEvaluationMacroAverage JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ModelEvaluationMacroAverage object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'precision') and self.precision is not None:
_dict['precision'] = self.precision
if hasattr(self, 'recall') and self.recall is not None:
_dict['recall'] = self.recall
if hasattr(self, 'f1') and self.f1 is not None:
_dict['f1'] = self.f1
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ModelEvaluationMacroAverage object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ModelEvaluationMacroAverage') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ModelEvaluationMacroAverage') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ModelEvaluationMicroAverage:
"""
A micro-average aggregates the contributions of all classes to compute the average
metric. Classes refers to the classification labels that are specified in the
**answer_field**.
:param float precision: A metric that measures how many of the overall documents
are classified correctly.
:param float recall: A metric that measures how often documents that should be
classified into certain classes are classified into those classes.
:param float f1: A metric that measures whether the optimal balance between
precision and recall is reached. The F1 score can be interpreted as a weighted
average of the precision and recall values. An F1 score reaches its best value
at 1 and worst value at 0.
"""
def __init__(
self,
precision: float,
recall: float,
f1: float,
) -> None:
"""
Initialize a ModelEvaluationMicroAverage object.
:param float precision: A metric that measures how many of the overall
documents are classified correctly.
:param float recall: A metric that measures how often documents that should
be classified into certain classes are classified into those classes.
:param float f1: A metric that measures whether the optimal balance between
precision and recall is reached. The F1 score can be interpreted as a
weighted average of the precision and recall values. An F1 score reaches
its best value at 1 and worst value at 0.
"""
self.precision = precision
self.recall = recall
self.f1 = f1
@classmethod
def from_dict(cls, _dict: Dict) -> 'ModelEvaluationMicroAverage':
"""Initialize a ModelEvaluationMicroAverage object from a json dictionary."""
args = {}
if (precision := _dict.get('precision')) is not None:
args['precision'] = precision
else:
raise ValueError(
'Required property \'precision\' not present in ModelEvaluationMicroAverage JSON'
)
if (recall := _dict.get('recall')) is not None:
args['recall'] = recall
else:
raise ValueError(
'Required property \'recall\' not present in ModelEvaluationMicroAverage JSON'
)
if (f1 := _dict.get('f1')) is not None:
args['f1'] = f1
else:
raise ValueError(
'Required property \'f1\' not present in ModelEvaluationMicroAverage JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ModelEvaluationMicroAverage object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'precision') and self.precision is not None:
_dict['precision'] = self.precision
if hasattr(self, 'recall') and self.recall is not None:
_dict['recall'] = self.recall
if hasattr(self, 'f1') and self.f1 is not None:
_dict['f1'] = self.f1
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ModelEvaluationMicroAverage object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ModelEvaluationMicroAverage') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ModelEvaluationMicroAverage') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class Notice:
"""
A notice produced for the collection.
:param str notice_id: (optional) Identifies the notice. Many notices might have
the same ID. This field exists so that user applications can programmatically
identify a notice and take automatic corrective action. Typical notice IDs
include:
`index_failed`, `index_failed_too_many_requests`,
`index_failed_incompatible_field`, `index_failed_cluster_unavailable`,
`ingestion_timeout`, `ingestion_error`, `bad_request`, `internal_error`,
`missing_model`, `unsupported_model`,
`smart_document_understanding_failed_incompatible_field`,
`smart_document_understanding_failed_internal_error`,
`smart_document_understanding_failed_internal_error`,
`smart_document_understanding_failed_warning`,
`smart_document_understanding_page_error`,
`smart_document_understanding_page_warning`. **Note:** This is not a complete
list. Other values might be returned.
:param datetime created: (optional) The creation date of the collection in the
format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'.
:param str document_id: (optional) Unique identifier of the document.
:param str collection_id: (optional) Unique identifier of the collection.
:param str query_id: (optional) Unique identifier of the query used for
relevance training.
:param str severity: (optional) Severity level of the notice.
:param str step: (optional) Ingestion or training step in which the notice
occurred.
:param str description: (optional) The description of the notice.
"""
def __init__(
self,
*,
notice_id: Optional[str] = None,
created: Optional[datetime] = None,
document_id: Optional[str] = None,
collection_id: Optional[str] = None,
query_id: Optional[str] = None,
severity: Optional[str] = None,
step: Optional[str] = None,
description: Optional[str] = None,
) -> None:
"""
Initialize a Notice object.
"""
self.notice_id = notice_id
self.created = created
self.document_id = document_id
self.collection_id = collection_id
self.query_id = query_id
self.severity = severity
self.step = step
self.description = description
@classmethod
def from_dict(cls, _dict: Dict) -> 'Notice':
"""Initialize a Notice object from a json dictionary."""
args = {}
if (notice_id := _dict.get('notice_id')) is not None:
args['notice_id'] = notice_id
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
if (query_id := _dict.get('query_id')) is not None:
args['query_id'] = query_id
if (severity := _dict.get('severity')) is not None:
args['severity'] = severity
if (step := _dict.get('step')) is not None:
args['step'] = step
if (description := _dict.get('description')) is not None:
args['description'] = description
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a Notice object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'notice_id') and getattr(self,
'notice_id') is not None:
_dict['notice_id'] = getattr(self, 'notice_id')
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'document_id') and getattr(self,
'document_id') is not None:
_dict['document_id'] = getattr(self, 'document_id')
if hasattr(self, 'collection_id') and getattr(
self, 'collection_id') is not None:
_dict['collection_id'] = getattr(self, 'collection_id')
if hasattr(self, 'query_id') and getattr(self, 'query_id') is not None:
_dict['query_id'] = getattr(self, 'query_id')
if hasattr(self, 'severity') and getattr(self, 'severity') is not None:
_dict['severity'] = getattr(self, 'severity')
if hasattr(self, 'step') and getattr(self, 'step') is not None:
_dict['step'] = getattr(self, 'step')
if hasattr(self, 'description') and getattr(self,
'description') is not None:
_dict['description'] = getattr(self, 'description')
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this Notice object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'Notice') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'Notice') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class SeverityEnum(str, Enum):
"""
Severity level of the notice.
"""
WARNING = 'warning'
ERROR = 'error'
class PerClassModelEvaluation:
"""
An object that measures the metrics from a training run for each classification label
separately.
:param str name: Class name. Each class name is derived from a value in the
**answer_field**.
:param float precision: A metric that measures how many of the overall documents
are classified correctly.
:param float recall: A metric that measures how often documents that should be
classified into certain classes are classified into those classes.
:param float f1: A metric that measures whether the optimal balance between
precision and recall is reached. The F1 score can be interpreted as a weighted
average of the precision and recall values. An F1 score reaches its best value
at 1 and worst value at 0.
"""
def __init__(
self,
name: str,
precision: float,
recall: float,
f1: float,
) -> None:
"""
Initialize a PerClassModelEvaluation object.
:param str name: Class name. Each class name is derived from a value in the
**answer_field**.
:param float precision: A metric that measures how many of the overall
documents are classified correctly.
:param float recall: A metric that measures how often documents that should
be classified into certain classes are classified into those classes.
:param float f1: A metric that measures whether the optimal balance between
precision and recall is reached. The F1 score can be interpreted as a
weighted average of the precision and recall values. An F1 score reaches
its best value at 1 and worst value at 0.
"""
self.name = name
self.precision = precision
self.recall = recall
self.f1 = f1
@classmethod
def from_dict(cls, _dict: Dict) -> 'PerClassModelEvaluation':
"""Initialize a PerClassModelEvaluation object from a json dictionary."""
args = {}
if (name := _dict.get('name')) is not None:
args['name'] = name
else:
raise ValueError(
'Required property \'name\' not present in PerClassModelEvaluation JSON'
)
if (precision := _dict.get('precision')) is not None:
args['precision'] = precision
else:
raise ValueError(
'Required property \'precision\' not present in PerClassModelEvaluation JSON'
)
if (recall := _dict.get('recall')) is not None:
args['recall'] = recall
else:
raise ValueError(
'Required property \'recall\' not present in PerClassModelEvaluation JSON'
)
if (f1 := _dict.get('f1')) is not None:
args['f1'] = f1
else:
raise ValueError(
'Required property \'f1\' not present in PerClassModelEvaluation JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a PerClassModelEvaluation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'precision') and self.precision is not None:
_dict['precision'] = self.precision
if hasattr(self, 'recall') and self.recall is not None:
_dict['recall'] = self.recall
if hasattr(self, 'f1') and self.f1 is not None:
_dict['f1'] = self.f1
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this PerClassModelEvaluation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'PerClassModelEvaluation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'PerClassModelEvaluation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ProjectDetails:
"""
Detailed information about the specified project.
:param str project_id: (optional) The Universally Unique Identifier (UUID) of
this project.
:param str name: (optional) The human readable name of this project.
:param str type: (optional) The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts* project
and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with Premium
plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from IBM
Cloud-managed instances only.
:param ProjectListDetailsRelevancyTrainingStatus relevancy_training_status:
(optional) Relevancy training status information for this project.
:param int collection_count: (optional) The number of collections configured in
this project.
:param DefaultQueryParams default_query_parameters: (optional) Default query
parameters for this project.
"""
def __init__(
self,
*,
project_id: Optional[str] = None,
name: Optional[str] = None,
type: Optional[str] = None,
relevancy_training_status: Optional[
'ProjectListDetailsRelevancyTrainingStatus'] = None,
collection_count: Optional[int] = None,
default_query_parameters: Optional['DefaultQueryParams'] = None,
) -> None:
"""
Initialize a ProjectDetails object.
:param str name: (optional) The human readable name of this project.
:param str type: (optional) The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts*
project and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with
Premium plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from
IBM Cloud-managed instances only.
:param DefaultQueryParams default_query_parameters: (optional) Default
query parameters for this project.
"""
self.project_id = project_id
self.name = name
self.type = type
self.relevancy_training_status = relevancy_training_status
self.collection_count = collection_count
self.default_query_parameters = default_query_parameters
@classmethod
def from_dict(cls, _dict: Dict) -> 'ProjectDetails':
"""Initialize a ProjectDetails object from a json dictionary."""
args = {}
if (project_id := _dict.get('project_id')) is not None:
args['project_id'] = project_id
if (name := _dict.get('name')) is not None:
args['name'] = name
if (type := _dict.get('type')) is not None:
args['type'] = type
if (relevancy_training_status :=
_dict.get('relevancy_training_status')) is not None:
args[
'relevancy_training_status'] = ProjectListDetailsRelevancyTrainingStatus.from_dict(
relevancy_training_status)
if (collection_count := _dict.get('collection_count')) is not None:
args['collection_count'] = collection_count
if (default_query_parameters :=
_dict.get('default_query_parameters')) is not None:
args['default_query_parameters'] = DefaultQueryParams.from_dict(
default_query_parameters)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ProjectDetails object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'project_id') and getattr(self,
'project_id') is not None:
_dict['project_id'] = getattr(self, 'project_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'relevancy_training_status') and getattr(
self, 'relevancy_training_status') is not None:
if isinstance(getattr(self, 'relevancy_training_status'), dict):
_dict['relevancy_training_status'] = getattr(
self, 'relevancy_training_status')
else:
_dict['relevancy_training_status'] = getattr(
self, 'relevancy_training_status').to_dict()
if hasattr(self, 'collection_count') and getattr(
self, 'collection_count') is not None:
_dict['collection_count'] = getattr(self, 'collection_count')
if hasattr(self, 'default_query_parameters'
) and self.default_query_parameters is not None:
if isinstance(self.default_query_parameters, dict):
_dict[
'default_query_parameters'] = self.default_query_parameters
else:
_dict[
'default_query_parameters'] = self.default_query_parameters.to_dict(
)
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ProjectDetails object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ProjectDetails') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ProjectDetails') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TypeEnum(str, Enum):
"""
The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts* project
and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with Premium
plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from IBM
Cloud-managed instances only.
"""
INTELLIGENT_DOCUMENT_PROCESSING = 'intelligent_document_processing'
DOCUMENT_RETRIEVAL = 'document_retrieval'
CONVERSATIONAL_SEARCH = 'conversational_search'
CONTENT_MINING = 'content_mining'
CONTENT_INTELLIGENCE = 'content_intelligence'
OTHER = 'other'
class ProjectListDetails:
"""
Details about a specific project.
:param str project_id: (optional) The Universally Unique Identifier (UUID) of
this project.
:param str name: (optional) The human readable name of this project.
:param str type: (optional) The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts* project
and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with Premium
plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from IBM
Cloud-managed instances only.
:param ProjectListDetailsRelevancyTrainingStatus relevancy_training_status:
(optional) Relevancy training status information for this project.
:param int collection_count: (optional) The number of collections configured in
this project.
"""
def __init__(
self,
*,
project_id: Optional[str] = None,
name: Optional[str] = None,
type: Optional[str] = None,
relevancy_training_status: Optional[
'ProjectListDetailsRelevancyTrainingStatus'] = None,
collection_count: Optional[int] = None,
) -> None:
"""
Initialize a ProjectListDetails object.
:param str name: (optional) The human readable name of this project.
:param str type: (optional) The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts*
project and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with
Premium plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from
IBM Cloud-managed instances only.
"""
self.project_id = project_id
self.name = name
self.type = type
self.relevancy_training_status = relevancy_training_status
self.collection_count = collection_count
@classmethod
def from_dict(cls, _dict: Dict) -> 'ProjectListDetails':
"""Initialize a ProjectListDetails object from a json dictionary."""
args = {}
if (project_id := _dict.get('project_id')) is not None:
args['project_id'] = project_id
if (name := _dict.get('name')) is not None:
args['name'] = name
if (type := _dict.get('type')) is not None:
args['type'] = type
if (relevancy_training_status :=
_dict.get('relevancy_training_status')) is not None:
args[
'relevancy_training_status'] = ProjectListDetailsRelevancyTrainingStatus.from_dict(
relevancy_training_status)
if (collection_count := _dict.get('collection_count')) is not None:
args['collection_count'] = collection_count
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ProjectListDetails object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'project_id') and getattr(self,
'project_id') is not None:
_dict['project_id'] = getattr(self, 'project_id')
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'relevancy_training_status') and getattr(
self, 'relevancy_training_status') is not None:
if isinstance(getattr(self, 'relevancy_training_status'), dict):
_dict['relevancy_training_status'] = getattr(
self, 'relevancy_training_status')
else:
_dict['relevancy_training_status'] = getattr(
self, 'relevancy_training_status').to_dict()
if hasattr(self, 'collection_count') and getattr(
self, 'collection_count') is not None:
_dict['collection_count'] = getattr(self, 'collection_count')
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ProjectListDetails object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ProjectListDetails') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ProjectListDetails') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TypeEnum(str, Enum):
"""
The type of project.
The `content_intelligence` type is a *Document Retrieval for Contracts* project
and the `other` type is a *Custom* project.
The `content_mining` and `content_intelligence` types are available with Premium
plan managed deployments and installed deployments only.
The Intelligent Document Processing (IDP) project type is available from IBM
Cloud-managed instances only.
"""
INTELLIGENT_DOCUMENT_PROCESSING = 'intelligent_document_processing'
DOCUMENT_RETRIEVAL = 'document_retrieval'
CONVERSATIONAL_SEARCH = 'conversational_search'
CONTENT_MINING = 'content_mining'
CONTENT_INTELLIGENCE = 'content_intelligence'
OTHER = 'other'
class ProjectListDetailsRelevancyTrainingStatus:
"""
Relevancy training status information for this project.
:param str data_updated: (optional) When the training data was updated.
:param int total_examples: (optional) The total number of examples.
:param bool sufficient_label_diversity: (optional) When `true`, sufficient label
diversity is present to allow training for this project.
:param bool processing: (optional) When `true`, the relevancy training is in
processing.
:param bool minimum_examples_added: (optional) When `true`, the minimum number
of examples required to train has been met.
:param str successfully_trained: (optional) The time that the most recent
successful training occurred.
:param bool available: (optional) When `true`, relevancy training is available
when querying collections in the project.
:param int notices: (optional) The number of notices generated during the
relevancy training.
:param bool minimum_queries_added: (optional) When `true`, the minimum number of
queries required to train has been met.
"""
def __init__(
self,
*,
data_updated: Optional[str] = None,
total_examples: Optional[int] = None,
sufficient_label_diversity: Optional[bool] = None,
processing: Optional[bool] = None,
minimum_examples_added: Optional[bool] = None,
successfully_trained: Optional[str] = None,
available: Optional[bool] = None,
notices: Optional[int] = None,
minimum_queries_added: Optional[bool] = None,
) -> None:
"""
Initialize a ProjectListDetailsRelevancyTrainingStatus object.
:param str data_updated: (optional) When the training data was updated.
:param int total_examples: (optional) The total number of examples.
:param bool sufficient_label_diversity: (optional) When `true`, sufficient
label diversity is present to allow training for this project.
:param bool processing: (optional) When `true`, the relevancy training is
in processing.
:param bool minimum_examples_added: (optional) When `true`, the minimum
number of examples required to train has been met.
:param str successfully_trained: (optional) The time that the most recent
successful training occurred.
:param bool available: (optional) When `true`, relevancy training is
available when querying collections in the project.
:param int notices: (optional) The number of notices generated during the
relevancy training.
:param bool minimum_queries_added: (optional) When `true`, the minimum
number of queries required to train has been met.
"""
self.data_updated = data_updated
self.total_examples = total_examples
self.sufficient_label_diversity = sufficient_label_diversity
self.processing = processing
self.minimum_examples_added = minimum_examples_added
self.successfully_trained = successfully_trained
self.available = available
self.notices = notices
self.minimum_queries_added = minimum_queries_added
@classmethod
def from_dict(cls,
_dict: Dict) -> 'ProjectListDetailsRelevancyTrainingStatus':
"""Initialize a ProjectListDetailsRelevancyTrainingStatus object from a json dictionary."""
args = {}
if (data_updated := _dict.get('data_updated')) is not None:
args['data_updated'] = data_updated
if (total_examples := _dict.get('total_examples')) is not None:
args['total_examples'] = total_examples
if (sufficient_label_diversity :=
_dict.get('sufficient_label_diversity')) is not None:
args['sufficient_label_diversity'] = sufficient_label_diversity
if (processing := _dict.get('processing')) is not None:
args['processing'] = processing
if (minimum_examples_added :=
_dict.get('minimum_examples_added')) is not None:
args['minimum_examples_added'] = minimum_examples_added
if (successfully_trained :=
_dict.get('successfully_trained')) is not None:
args['successfully_trained'] = successfully_trained
if (available := _dict.get('available')) is not None:
args['available'] = available
if (notices := _dict.get('notices')) is not None:
args['notices'] = notices
if (minimum_queries_added :=
_dict.get('minimum_queries_added')) is not None:
args['minimum_queries_added'] = minimum_queries_added
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ProjectListDetailsRelevancyTrainingStatus object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'data_updated') and self.data_updated is not None:
_dict['data_updated'] = self.data_updated
if hasattr(self, 'total_examples') and self.total_examples is not None:
_dict['total_examples'] = self.total_examples
if hasattr(self, 'sufficient_label_diversity'
) and self.sufficient_label_diversity is not None:
_dict[
'sufficient_label_diversity'] = self.sufficient_label_diversity
if hasattr(self, 'processing') and self.processing is not None:
_dict['processing'] = self.processing
if hasattr(self, 'minimum_examples_added'
) and self.minimum_examples_added is not None:
_dict['minimum_examples_added'] = self.minimum_examples_added
if hasattr(self, 'successfully_trained'
) and self.successfully_trained is not None:
_dict['successfully_trained'] = self.successfully_trained
if hasattr(self, 'available') and self.available is not None:
_dict['available'] = self.available
if hasattr(self, 'notices') and self.notices is not None:
_dict['notices'] = self.notices
if hasattr(self, 'minimum_queries_added'
) and self.minimum_queries_added is not None:
_dict['minimum_queries_added'] = self.minimum_queries_added
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ProjectListDetailsRelevancyTrainingStatus object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self,
other: 'ProjectListDetailsRelevancyTrainingStatus') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self,
other: 'ProjectListDetailsRelevancyTrainingStatus') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregation:
"""
An object that defines how to aggregate query results.
"""
def __init__(self,) -> None:
"""
Initialize a QueryAggregation object.
"""
msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format(
", ".join([
'QueryAggregationQueryTermAggregation',
'QueryAggregationQueryGroupByAggregation',
'QueryAggregationQueryHistogramAggregation',
'QueryAggregationQueryTimesliceAggregation',
'QueryAggregationQueryNestedAggregation',
'QueryAggregationQueryFilterAggregation',
'QueryAggregationQueryCalculationAggregation',
'QueryAggregationQueryTopHitsAggregation',
'QueryAggregationQueryPairAggregation',
'QueryAggregationQueryTrendAggregation',
'QueryAggregationQueryTopicAggregation'
]))
raise Exception(msg)
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregation':
"""Initialize a QueryAggregation object from a json dictionary."""
disc_class = cls._get_class_by_discriminator(_dict)
if disc_class != cls:
return disc_class.from_dict(_dict)
msg = "Cannot convert dictionary into an instance of base class 'QueryAggregation'. The discriminator value should map to a valid subclass: {1}".format(
", ".join([
'QueryAggregationQueryTermAggregation',
'QueryAggregationQueryGroupByAggregation',
'QueryAggregationQueryHistogramAggregation',
'QueryAggregationQueryTimesliceAggregation',
'QueryAggregationQueryNestedAggregation',
'QueryAggregationQueryFilterAggregation',
'QueryAggregationQueryCalculationAggregation',
'QueryAggregationQueryTopHitsAggregation',
'QueryAggregationQueryPairAggregation',
'QueryAggregationQueryTrendAggregation',
'QueryAggregationQueryTopicAggregation'
]))
raise Exception(msg)
@classmethod
def _from_dict(cls, _dict: Dict):
"""Initialize a QueryAggregation object from a json dictionary."""
return cls.from_dict(_dict)
@classmethod
def _get_class_by_discriminator(cls, _dict: Dict) -> object:
mapping = {}
mapping['term'] = 'QueryAggregationQueryTermAggregation'
mapping['group_by'] = 'QueryAggregationQueryGroupByAggregation'
mapping['histogram'] = 'QueryAggregationQueryHistogramAggregation'
mapping['timeslice'] = 'QueryAggregationQueryTimesliceAggregation'
mapping['nested'] = 'QueryAggregationQueryNestedAggregation'
mapping['filter'] = 'QueryAggregationQueryFilterAggregation'
mapping['min'] = 'QueryAggregationQueryCalculationAggregation'
mapping['max'] = 'QueryAggregationQueryCalculationAggregation'
mapping['sum'] = 'QueryAggregationQueryCalculationAggregation'
mapping['average'] = 'QueryAggregationQueryCalculationAggregation'
mapping['unique_count'] = 'QueryAggregationQueryCalculationAggregation'
mapping['top_hits'] = 'QueryAggregationQueryTopHitsAggregation'
mapping['pair'] = 'QueryAggregationQueryPairAggregation'
mapping['trend'] = 'QueryAggregationQueryTrendAggregation'
mapping['topic'] = 'QueryAggregationQueryTopicAggregation'
disc_value = _dict.get('type')
if disc_value is None:
raise ValueError(
'Discriminator property \'type\' not found in QueryAggregation JSON'
)
class_name = mapping.get(disc_value, disc_value)
try:
disc_class = getattr(sys.modules[__name__], class_name)
except AttributeError:
disc_class = cls
if isinstance(disc_class, object):
return disc_class
raise TypeError('%s is not a discriminator class' % class_name)
class QueryGroupByAggregationResult:
"""
Result group for the `group_by` aggregation.
:param str key: The condition that is met by the documents in this group. For
example, `YEARTXT<2000`.
:param int matching_results: Number of documents that meet the query and
condition.
:param float relevancy: (optional) The relevancy for this group. Returned only
if `relevancy:true` is specified in the request.
:param int total_matching_documents: (optional) Number of documents that meet
the condition in the whole set of documents in this collection. Returned only
when `relevancy:true` is specified in the request.
:param float estimated_matching_results: (optional) The number of documents that
are estimated to match the query and condition. Returned only when
`relevancy:true` is specified in the request.
:param List[dict] aggregations: (optional) An array of subaggregations. Returned
only when this aggregation is returned as a subaggregation.
"""
def __init__(
self,
key: str,
matching_results: int,
*,
relevancy: Optional[float] = None,
total_matching_documents: Optional[int] = None,
estimated_matching_results: Optional[float] = None,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryGroupByAggregationResult object.
:param str key: The condition that is met by the documents in this group.
For example, `YEARTXT<2000`.
:param int matching_results: Number of documents that meet the query and
condition.
:param float relevancy: (optional) The relevancy for this group. Returned
only if `relevancy:true` is specified in the request.
:param int total_matching_documents: (optional) Number of documents that
meet the condition in the whole set of documents in this collection.
Returned only when `relevancy:true` is specified in the request.
:param float estimated_matching_results: (optional) The number of documents
that are estimated to match the query and condition. Returned only when
`relevancy:true` is specified in the request.
:param List[dict] aggregations: (optional) An array of subaggregations.
Returned only when this aggregation is returned as a subaggregation.
"""
self.key = key
self.matching_results = matching_results
self.relevancy = relevancy
self.total_matching_documents = total_matching_documents
self.estimated_matching_results = estimated_matching_results
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryGroupByAggregationResult':
"""Initialize a QueryGroupByAggregationResult object from a json dictionary."""
args = {}
if (key := _dict.get('key')) is not None:
args['key'] = key
else:
raise ValueError(
'Required property \'key\' not present in QueryGroupByAggregationResult JSON'
)
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryGroupByAggregationResult JSON'
)
if (relevancy := _dict.get('relevancy')) is not None:
args['relevancy'] = relevancy
if (total_matching_documents :=
_dict.get('total_matching_documents')) is not None:
args['total_matching_documents'] = total_matching_documents
if (estimated_matching_results :=
_dict.get('estimated_matching_results')) is not None:
args['estimated_matching_results'] = estimated_matching_results
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryGroupByAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'key') and self.key is not None:
_dict['key'] = self.key
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'relevancy') and self.relevancy is not None:
_dict['relevancy'] = self.relevancy
if hasattr(self, 'total_matching_documents'
) and self.total_matching_documents is not None:
_dict['total_matching_documents'] = self.total_matching_documents
if hasattr(self, 'estimated_matching_results'
) and self.estimated_matching_results is not None:
_dict[
'estimated_matching_results'] = self.estimated_matching_results
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryGroupByAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryGroupByAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryGroupByAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryHistogramAggregationResult:
"""
Histogram numeric interval result.
:param int key: The value of the upper bound for the numeric segment.
:param int matching_results: Number of documents with the specified key as the
upper bound.
:param List[dict] aggregations: (optional) An array of subaggregations. Returned
only when this aggregation is returned as a subaggregation.
"""
def __init__(
self,
key: int,
matching_results: int,
*,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryHistogramAggregationResult object.
:param int key: The value of the upper bound for the numeric segment.
:param int matching_results: Number of documents with the specified key as
the upper bound.
:param List[dict] aggregations: (optional) An array of subaggregations.
Returned only when this aggregation is returned as a subaggregation.
"""
self.key = key
self.matching_results = matching_results
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryHistogramAggregationResult':
"""Initialize a QueryHistogramAggregationResult object from a json dictionary."""
args = {}
if (key := _dict.get('key')) is not None:
args['key'] = key
else:
raise ValueError(
'Required property \'key\' not present in QueryHistogramAggregationResult JSON'
)
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryHistogramAggregationResult JSON'
)
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryHistogramAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'key') and self.key is not None:
_dict['key'] = self.key
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryHistogramAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryHistogramAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryHistogramAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryLargePassages:
"""
Configuration for passage retrieval.
:param bool enabled: (optional) A passages query that returns the most relevant
passages from the results.
:param bool per_document: (optional) If `true`, ranks the documents by document
quality, and then returns the highest-ranked passages per document in a
`document_passages` field for each document entry in the results list of the
response.
If `false`, ranks the passages from all of the documents by passage quality
regardless of the document quality and returns them in a separate `passages`
field in the response.
:param int max_per_document: (optional) Maximum number of passages to return per
document in the result. Ignored if **passages.per_document** is `false`.
:param List[str] fields: (optional) A list of fields to extract passages from.
By default, passages are extracted from the `text` and `title` fields only. If
you add this parameter and specify an empty list (`[]`) as its value, then the
service searches all root-level fields for suitable passages.
:param int count: (optional) The maximum number of passages to return. Ignored
if **passages.per_document** is `true`.
:param int characters: (optional) The approximate number of characters that any
one passage will have.
:param bool find_answers: (optional) When true, `answer` objects are returned as
part of each passage in the query results. The primary difference between an
`answer` and a `passage` is that the length of a passage is defined by the
query, where the length of an `answer` is calculated by Discovery based on how
much text is needed to answer the question.
This parameter is ignored if passages are not enabled for the query, or no
**natural_language_query** is specified.
If the **find_answers** parameter is set to `true` and **per_document**
parameter is also set to `true`, then the document search results and the
passage search results within each document are reordered using the answer
confidences. The goal of this reordering is to place the best answer as the
first answer of the first passage of the first document. Similarly, if the
**find_answers** parameter is set to `true` and **per_document** parameter is
set to `false`, then the passage search results are reordered in decreasing
order of the highest confidence answer for each document and passage.
The **find_answers** parameter is available only on managed instances of
Discovery.
:param int max_answers_per_passage: (optional) The number of `answer` objects to
return per passage if the **find_answers** parmeter is specified as `true`.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
per_document: Optional[bool] = None,
max_per_document: Optional[int] = None,
fields: Optional[List[str]] = None,
count: Optional[int] = None,
characters: Optional[int] = None,
find_answers: Optional[bool] = None,
max_answers_per_passage: Optional[int] = None,
) -> None:
"""
Initialize a QueryLargePassages object.
:param bool enabled: (optional) A passages query that returns the most
relevant passages from the results.
:param bool per_document: (optional) If `true`, ranks the documents by
document quality, and then returns the highest-ranked passages per document
in a `document_passages` field for each document entry in the results list
of the response.
If `false`, ranks the passages from all of the documents by passage quality
regardless of the document quality and returns them in a separate
`passages` field in the response.
:param int max_per_document: (optional) Maximum number of passages to
return per document in the result. Ignored if **passages.per_document** is
`false`.
:param List[str] fields: (optional) A list of fields to extract passages
from. By default, passages are extracted from the `text` and `title` fields
only. If you add this parameter and specify an empty list (`[]`) as its
value, then the service searches all root-level fields for suitable
passages.
:param int count: (optional) The maximum number of passages to return.
Ignored if **passages.per_document** is `true`.
:param int characters: (optional) The approximate number of characters that
any one passage will have.
:param bool find_answers: (optional) When true, `answer` objects are
returned as part of each passage in the query results. The primary
difference between an `answer` and a `passage` is that the length of a
passage is defined by the query, where the length of an `answer` is
calculated by Discovery based on how much text is needed to answer the
question.
This parameter is ignored if passages are not enabled for the query, or no
**natural_language_query** is specified.
If the **find_answers** parameter is set to `true` and **per_document**
parameter is also set to `true`, then the document search results and the
passage search results within each document are reordered using the answer
confidences. The goal of this reordering is to place the best answer as the
first answer of the first passage of the first document. Similarly, if the
**find_answers** parameter is set to `true` and **per_document** parameter
is set to `false`, then the passage search results are reordered in
decreasing order of the highest confidence answer for each document and
passage.
The **find_answers** parameter is available only on managed instances of
Discovery.
:param int max_answers_per_passage: (optional) The number of `answer`
objects to return per passage if the **find_answers** parmeter is specified
as `true`.
"""
self.enabled = enabled
self.per_document = per_document
self.max_per_document = max_per_document
self.fields = fields
self.count = count
self.characters = characters
self.find_answers = find_answers
self.max_answers_per_passage = max_answers_per_passage
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryLargePassages':
"""Initialize a QueryLargePassages object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (per_document := _dict.get('per_document')) is not None:
args['per_document'] = per_document
if (max_per_document := _dict.get('max_per_document')) is not None:
args['max_per_document'] = max_per_document
if (fields := _dict.get('fields')) is not None:
args['fields'] = fields
if (count := _dict.get('count')) is not None:
args['count'] = count
if (characters := _dict.get('characters')) is not None:
args['characters'] = characters
if (find_answers := _dict.get('find_answers')) is not None:
args['find_answers'] = find_answers
if (max_answers_per_passage :=
_dict.get('max_answers_per_passage')) is not None:
args['max_answers_per_passage'] = max_answers_per_passage
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryLargePassages object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'per_document') and self.per_document is not None:
_dict['per_document'] = self.per_document
if hasattr(self,
'max_per_document') and self.max_per_document is not None:
_dict['max_per_document'] = self.max_per_document
if hasattr(self, 'fields') and self.fields is not None:
_dict['fields'] = self.fields
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
if hasattr(self, 'characters') and self.characters is not None:
_dict['characters'] = self.characters
if hasattr(self, 'find_answers') and self.find_answers is not None:
_dict['find_answers'] = self.find_answers
if hasattr(self, 'max_answers_per_passage'
) and self.max_answers_per_passage is not None:
_dict['max_answers_per_passage'] = self.max_answers_per_passage
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryLargePassages object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryLargePassages') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryLargePassages') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryLargeSimilar:
"""
Finds results from documents that are similar to documents of interest. Use this
parameter to add a *More like these* function to your search. You can include this
parameter with or without a **query**, **filter** or **natural_language_query**
parameter.
:param bool enabled: (optional) When `true`, includes documents in the query
results that are similar to documents you specify.
:param List[str] document_ids: (optional) The list of documents of interest.
Required if **enabled** is `true`.
:param List[str] fields: (optional) Looks for similarities in the specified
subset of fields in the documents. If not specified, all of the document fields
are used.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
document_ids: Optional[List[str]] = None,
fields: Optional[List[str]] = None,
) -> None:
"""
Initialize a QueryLargeSimilar object.
:param bool enabled: (optional) When `true`, includes documents in the
query results that are similar to documents you specify.
:param List[str] document_ids: (optional) The list of documents of
interest. Required if **enabled** is `true`.
:param List[str] fields: (optional) Looks for similarities in the specified
subset of fields in the documents. If not specified, all of the document
fields are used.
"""
self.enabled = enabled
self.document_ids = document_ids
self.fields = fields
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryLargeSimilar':
"""Initialize a QueryLargeSimilar object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (document_ids := _dict.get('document_ids')) is not None:
args['document_ids'] = document_ids
if (fields := _dict.get('fields')) is not None:
args['fields'] = fields
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryLargeSimilar object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'document_ids') and self.document_ids is not None:
_dict['document_ids'] = self.document_ids
if hasattr(self, 'fields') and self.fields is not None:
_dict['fields'] = self.fields
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryLargeSimilar object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryLargeSimilar') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryLargeSimilar') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryLargeSuggestedRefinements:
"""
Configuration for suggested refinements.
**Note**: The **suggested_refinements** parameter that identified dynamic facets from
the data is deprecated.
:param bool enabled: (optional) Whether to perform suggested refinements.
:param int count: (optional) Maximum number of suggested refinements texts to be
returned. The maximum is `100`.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
count: Optional[int] = None,
) -> None:
"""
Initialize a QueryLargeSuggestedRefinements object.
:param bool enabled: (optional) Whether to perform suggested refinements.
:param int count: (optional) Maximum number of suggested refinements texts
to be returned. The maximum is `100`.
"""
self.enabled = enabled
self.count = count
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryLargeSuggestedRefinements':
"""Initialize a QueryLargeSuggestedRefinements object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (count := _dict.get('count')) is not None:
args['count'] = count
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryLargeSuggestedRefinements object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryLargeSuggestedRefinements object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryLargeSuggestedRefinements') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryLargeSuggestedRefinements') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryLargeTableResults:
"""
Configuration for table retrieval.
:param bool enabled: (optional) Whether to enable table retrieval.
:param int count: (optional) Maximum number of tables to return.
"""
def __init__(
self,
*,
enabled: Optional[bool] = None,
count: Optional[int] = None,
) -> None:
"""
Initialize a QueryLargeTableResults object.
:param bool enabled: (optional) Whether to enable table retrieval.
:param int count: (optional) Maximum number of tables to return.
"""
self.enabled = enabled
self.count = count
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryLargeTableResults':
"""Initialize a QueryLargeTableResults object from a json dictionary."""
args = {}
if (enabled := _dict.get('enabled')) is not None:
args['enabled'] = enabled
if (count := _dict.get('count')) is not None:
args['count'] = count
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryLargeTableResults object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'enabled') and self.enabled is not None:
_dict['enabled'] = self.enabled
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryLargeTableResults object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryLargeTableResults') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryLargeTableResults') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryNoticesResponse:
"""
Object that contains notice query results.
:param int matching_results: (optional) The number of matching results.
:param List[Notice] notices: (optional) Array of document results that match the
query.
"""
def __init__(
self,
*,
matching_results: Optional[int] = None,
notices: Optional[List['Notice']] = None,
) -> None:
"""
Initialize a QueryNoticesResponse object.
:param int matching_results: (optional) The number of matching results.
:param List[Notice] notices: (optional) Array of document results that
match the query.
"""
self.matching_results = matching_results
self.notices = notices
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryNoticesResponse':
"""Initialize a QueryNoticesResponse object from a json dictionary."""
args = {}
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
if (notices := _dict.get('notices')) is not None:
args['notices'] = [Notice.from_dict(v) for v in notices]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryNoticesResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'notices') and self.notices is not None:
notices_list = []
for v in self.notices:
if isinstance(v, dict):
notices_list.append(v)
else:
notices_list.append(v.to_dict())
_dict['notices'] = notices_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryNoticesResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryNoticesResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryNoticesResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryPairAggregationResult:
"""
Result for the `pair` aggregation.
:param List[dict] aggregations: (optional) Array of subaggregations of type
`term`, `group_by`, `histogram`, or `timeslice`. Each element of the matrix that
is returned contains a **relevancy** value that is calculated from the
combination of each value from the first and second aggregations.
"""
def __init__(
self,
*,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryPairAggregationResult object.
:param List[dict] aggregations: (optional) Array of subaggregations of type
`term`, `group_by`, `histogram`, or `timeslice`. Each element of the matrix
that is returned contains a **relevancy** value that is calculated from the
combination of each value from the first and second aggregations.
"""
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryPairAggregationResult':
"""Initialize a QueryPairAggregationResult object from a json dictionary."""
args = {}
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryPairAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryPairAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryPairAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryPairAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryResponse:
"""
A response that contains the documents and aggregations for the query.
:param int matching_results: (optional) The number of matching results for the
query. Results that match due to a curation only are not counted in the total.
:param List[QueryResult] results: (optional) Array of document results for the
query.
:param List[QueryAggregation] aggregations: (optional) Array of aggregations for
the query.
:param RetrievalDetails retrieval_details: (optional) An object contain
retrieval type information.
:param str suggested_query: (optional) Suggested correction to the submitted
**natural_language_query** value.
:param List[QuerySuggestedRefinement] suggested_refinements: (optional)
Deprecated: Array of suggested refinements. **Note**: The
`suggested_refinements` parameter that identified dynamic facets from the data
is deprecated.
:param List[QueryTableResult] table_results: (optional) Array of table results.
:param List[QueryResponsePassage] passages: (optional) Passages that best match
the query from across all of the collections in the project. Returned if
**passages.per_document** is `false`.
"""
def __init__(
self,
*,
matching_results: Optional[int] = None,
results: Optional[List['QueryResult']] = None,
aggregations: Optional[List['QueryAggregation']] = None,
retrieval_details: Optional['RetrievalDetails'] = None,
suggested_query: Optional[str] = None,
suggested_refinements: Optional[
List['QuerySuggestedRefinement']] = None,
table_results: Optional[List['QueryTableResult']] = None,
passages: Optional[List['QueryResponsePassage']] = None,
) -> None:
"""
Initialize a QueryResponse object.
:param int matching_results: (optional) The number of matching results for
the query. Results that match due to a curation only are not counted in the
total.
:param List[QueryResult] results: (optional) Array of document results for
the query.
:param List[QueryAggregation] aggregations: (optional) Array of
aggregations for the query.
:param RetrievalDetails retrieval_details: (optional) An object contain
retrieval type information.
:param str suggested_query: (optional) Suggested correction to the
submitted **natural_language_query** value.
:param List[QuerySuggestedRefinement] suggested_refinements: (optional)
Deprecated: Array of suggested refinements. **Note**: The
`suggested_refinements` parameter that identified dynamic facets from the
data is deprecated.
:param List[QueryTableResult] table_results: (optional) Array of table
results.
:param List[QueryResponsePassage] passages: (optional) Passages that best
match the query from across all of the collections in the project. Returned
if **passages.per_document** is `false`.
"""
self.matching_results = matching_results
self.results = results
self.aggregations = aggregations
self.retrieval_details = retrieval_details
self.suggested_query = suggested_query
self.suggested_refinements = suggested_refinements
self.table_results = table_results
self.passages = passages
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryResponse':
"""Initialize a QueryResponse object from a json dictionary."""
args = {}
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
if (results := _dict.get('results')) is not None:
args['results'] = [QueryResult.from_dict(v) for v in results]
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = [
QueryAggregation.from_dict(v) for v in aggregations
]
if (retrieval_details := _dict.get('retrieval_details')) is not None:
args['retrieval_details'] = RetrievalDetails.from_dict(
retrieval_details)
if (suggested_query := _dict.get('suggested_query')) is not None:
args['suggested_query'] = suggested_query
if (suggested_refinements :=
_dict.get('suggested_refinements')) is not None:
args['suggested_refinements'] = [
QuerySuggestedRefinement.from_dict(v)
for v in suggested_refinements
]
if (table_results := _dict.get('table_results')) is not None:
args['table_results'] = [
QueryTableResult.from_dict(v) for v in table_results
]
if (passages := _dict.get('passages')) is not None:
args['passages'] = [
QueryResponsePassage.from_dict(v) for v in passages
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
if hasattr(self, 'aggregations') and self.aggregations is not None:
aggregations_list = []
for v in self.aggregations:
if isinstance(v, dict):
aggregations_list.append(v)
else:
aggregations_list.append(v.to_dict())
_dict['aggregations'] = aggregations_list
if hasattr(self,
'retrieval_details') and self.retrieval_details is not None:
if isinstance(self.retrieval_details, dict):
_dict['retrieval_details'] = self.retrieval_details
else:
_dict['retrieval_details'] = self.retrieval_details.to_dict()
if hasattr(self,
'suggested_query') and self.suggested_query is not None:
_dict['suggested_query'] = self.suggested_query
if hasattr(self, 'suggested_refinements'
) and self.suggested_refinements is not None:
suggested_refinements_list = []
for v in self.suggested_refinements:
if isinstance(v, dict):
suggested_refinements_list.append(v)
else:
suggested_refinements_list.append(v.to_dict())
_dict['suggested_refinements'] = suggested_refinements_list
if hasattr(self, 'table_results') and self.table_results is not None:
table_results_list = []
for v in self.table_results:
if isinstance(v, dict):
table_results_list.append(v)
else:
table_results_list.append(v.to_dict())
_dict['table_results'] = table_results_list
if hasattr(self, 'passages') and self.passages is not None:
passages_list = []
for v in self.passages:
if isinstance(v, dict):
passages_list.append(v)
else:
passages_list.append(v.to_dict())
_dict['passages'] = passages_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryResponsePassage:
"""
A passage query response.
:param str passage_text: (optional) The content of the extracted passage.
:param float passage_score: (optional) The confidence score of the passage's
analysis. A higher score indicates greater confidence. The score is used to rank
the passages from all documents and is returned only if
**passages.per_document** is `false`.
:param str document_id: (optional) The unique identifier of the ingested
document.
:param str collection_id: (optional) The unique identifier of the collection.
:param int start_offset: (optional) The position of the first character of the
extracted passage in the originating field.
:param int end_offset: (optional) The position after the last character of the
extracted passage in the originating field.
:param str field: (optional) The label of the field from which the passage has
been extracted.
:param List[ResultPassageAnswer] answers: (optional) An array of extracted
answers to the specified query. Returned for natural language queries when
**passages.per_document** is `false`.
"""
def __init__(
self,
*,
passage_text: Optional[str] = None,
passage_score: Optional[float] = None,
document_id: Optional[str] = None,
collection_id: Optional[str] = None,
start_offset: Optional[int] = None,
end_offset: Optional[int] = None,
field: Optional[str] = None,
answers: Optional[List['ResultPassageAnswer']] = None,
) -> None:
"""
Initialize a QueryResponsePassage object.
:param str passage_text: (optional) The content of the extracted passage.
:param float passage_score: (optional) The confidence score of the
passage's analysis. A higher score indicates greater confidence. The score
is used to rank the passages from all documents and is returned only if
**passages.per_document** is `false`.
:param str document_id: (optional) The unique identifier of the ingested
document.
:param str collection_id: (optional) The unique identifier of the
collection.
:param int start_offset: (optional) The position of the first character of
the extracted passage in the originating field.
:param int end_offset: (optional) The position after the last character of
the extracted passage in the originating field.
:param str field: (optional) The label of the field from which the passage
has been extracted.
:param List[ResultPassageAnswer] answers: (optional) An array of extracted
answers to the specified query. Returned for natural language queries when
**passages.per_document** is `false`.
"""
self.passage_text = passage_text
self.passage_score = passage_score
self.document_id = document_id
self.collection_id = collection_id
self.start_offset = start_offset
self.end_offset = end_offset
self.field = field
self.answers = answers
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryResponsePassage':
"""Initialize a QueryResponsePassage object from a json dictionary."""
args = {}
if (passage_text := _dict.get('passage_text')) is not None:
args['passage_text'] = passage_text
if (passage_score := _dict.get('passage_score')) is not None:
args['passage_score'] = passage_score
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
if (start_offset := _dict.get('start_offset')) is not None:
args['start_offset'] = start_offset
if (end_offset := _dict.get('end_offset')) is not None:
args['end_offset'] = end_offset
if (field := _dict.get('field')) is not None:
args['field'] = field
if (answers := _dict.get('answers')) is not None:
args['answers'] = [
ResultPassageAnswer.from_dict(v) for v in answers
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryResponsePassage object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'passage_text') and self.passage_text is not None:
_dict['passage_text'] = self.passage_text
if hasattr(self, 'passage_score') and self.passage_score is not None:
_dict['passage_score'] = self.passage_score
if hasattr(self, 'document_id') and self.document_id is not None:
_dict['document_id'] = self.document_id
if hasattr(self, 'collection_id') and self.collection_id is not None:
_dict['collection_id'] = self.collection_id
if hasattr(self, 'start_offset') and self.start_offset is not None:
_dict['start_offset'] = self.start_offset
if hasattr(self, 'end_offset') and self.end_offset is not None:
_dict['end_offset'] = self.end_offset
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
if hasattr(self, 'answers') and self.answers is not None:
answers_list = []
for v in self.answers:
if isinstance(v, dict):
answers_list.append(v)
else:
answers_list.append(v.to_dict())
_dict['answers'] = answers_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryResponsePassage object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryResponsePassage') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryResponsePassage') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryResult:
"""
Result document for the specified query.
:param str document_id: The unique identifier of the document.
:param dict metadata: (optional) Metadata of the document.
:param QueryResultMetadata result_metadata: Metadata of a query result.
:param List[QueryResultPassage] document_passages: (optional) Passages from the
document that best matches the query. Returned if **passages.per_document** is
`true`.
This type supports additional properties of type object. The remaining key-value
pairs.
"""
# The set of defined properties for the class
_properties = frozenset(
['document_id', 'metadata', 'result_metadata', 'document_passages'])
def __init__(
self,
document_id: str,
result_metadata: 'QueryResultMetadata',
*,
metadata: Optional[dict] = None,
document_passages: Optional[List['QueryResultPassage']] = None,
**kwargs: Optional[object],
) -> None:
"""
Initialize a QueryResult object.
:param str document_id: The unique identifier of the document.
:param QueryResultMetadata result_metadata: Metadata of a query result.
:param dict metadata: (optional) Metadata of the document.
:param List[QueryResultPassage] document_passages: (optional) Passages from
the document that best matches the query. Returned if
**passages.per_document** is `true`.
:param object **kwargs: (optional) The remaining key-value pairs.
"""
self.document_id = document_id
self.metadata = metadata
self.result_metadata = result_metadata
self.document_passages = document_passages
for k, v in kwargs.items():
if k not in QueryResult._properties:
if not isinstance(v, object):
raise ValueError(
'Value for additional property {} must be of type object'
.format(k))
setattr(self, k, v)
else:
raise ValueError(
'Property {} cannot be specified as an additional property'.
format(k))
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryResult':
"""Initialize a QueryResult object from a json dictionary."""
args = {}
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
else:
raise ValueError(
'Required property \'document_id\' not present in QueryResult JSON'
)
if (metadata := _dict.get('metadata')) is not None:
args['metadata'] = metadata
if (result_metadata := _dict.get('result_metadata')) is not None:
args['result_metadata'] = QueryResultMetadata.from_dict(
result_metadata)
else:
raise ValueError(
'Required property \'result_metadata\' not present in QueryResult JSON'
)
if (document_passages := _dict.get('document_passages')) is not None:
args['document_passages'] = [
QueryResultPassage.from_dict(v) for v in document_passages
]
for k, v in _dict.items():
if k not in cls._properties:
if not isinstance(v, object):
raise ValueError(
'Value for additional property {} must be of type object'
.format(k))
args[k] = v
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_id') and self.document_id is not None:
_dict['document_id'] = self.document_id
if hasattr(self, 'metadata') and self.metadata is not None:
_dict['metadata'] = self.metadata
if hasattr(self,
'result_metadata') and self.result_metadata is not None:
if isinstance(self.result_metadata, dict):
_dict['result_metadata'] = self.result_metadata
else:
_dict['result_metadata'] = self.result_metadata.to_dict()
if hasattr(self,
'document_passages') and self.document_passages is not None:
document_passages_list = []
for v in self.document_passages:
if isinstance(v, dict):
document_passages_list.append(v)
else:
document_passages_list.append(v.to_dict())
_dict['document_passages'] = document_passages_list
for k in [
_k for _k in vars(self).keys()
if _k not in QueryResult._properties
]:
_dict[k] = getattr(self, k)
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def get_properties(self) -> Dict:
"""Return the additional properties from this instance of QueryResult in the form of a dict."""
_dict = {}
for k in [
_k for _k in vars(self).keys()
if _k not in QueryResult._properties
]:
_dict[k] = getattr(self, k)
return _dict
def set_properties(self, _dict: dict):
"""Set a dictionary of additional properties in this instance of QueryResult"""
for k in [
_k for _k in vars(self).keys()
if _k not in QueryResult._properties
]:
delattr(self, k)
for k, v in _dict.items():
if k not in QueryResult._properties:
if not isinstance(v, object):
raise ValueError(
'Value for additional property {} must be of type object'
.format(k))
setattr(self, k, v)
else:
raise ValueError(
'Property {} cannot be specified as an additional property'.
format(k))
def __str__(self) -> str:
"""Return a `str` version of this QueryResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryResultMetadata:
"""
Metadata of a query result.
:param str document_retrieval_source: (optional) The document retrieval source
that produced this search result.
:param str collection_id: The collection id associated with this training data
set.
:param float confidence: (optional) The confidence score for the given result.
Calculated based on how relevant the result is estimated to be. The score can
range from `0.0` to `1.0`. The higher the number, the more relevant the
document. The `confidence` value for a result was calculated using the model
specified in the `document_retrieval_strategy` field of the result set. This
field is returned only if the **natural_language_query** parameter is specified
in the query.
"""
def __init__(
self,
collection_id: str,
*,
document_retrieval_source: Optional[str] = None,
confidence: Optional[float] = None,
) -> None:
"""
Initialize a QueryResultMetadata object.
:param str collection_id: The collection id associated with this training
data set.
:param str document_retrieval_source: (optional) The document retrieval
source that produced this search result.
:param float confidence: (optional) The confidence score for the given
result. Calculated based on how relevant the result is estimated to be. The
score can range from `0.0` to `1.0`. The higher the number, the more
relevant the document. The `confidence` value for a result was calculated
using the model specified in the `document_retrieval_strategy` field of the
result set. This field is returned only if the **natural_language_query**
parameter is specified in the query.
"""
self.document_retrieval_source = document_retrieval_source
self.collection_id = collection_id
self.confidence = confidence
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryResultMetadata':
"""Initialize a QueryResultMetadata object from a json dictionary."""
args = {}
if (document_retrieval_source :=
_dict.get('document_retrieval_source')) is not None:
args['document_retrieval_source'] = document_retrieval_source
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
else:
raise ValueError(
'Required property \'collection_id\' not present in QueryResultMetadata JSON'
)
if (confidence := _dict.get('confidence')) is not None:
args['confidence'] = confidence
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryResultMetadata object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_retrieval_source'
) and self.document_retrieval_source is not None:
_dict['document_retrieval_source'] = self.document_retrieval_source
if hasattr(self, 'collection_id') and self.collection_id is not None:
_dict['collection_id'] = self.collection_id
if hasattr(self, 'confidence') and self.confidence is not None:
_dict['confidence'] = self.confidence
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryResultMetadata object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryResultMetadata') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryResultMetadata') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentRetrievalSourceEnum(str, Enum):
"""
The document retrieval source that produced this search result.
"""
SEARCH = 'search'
CURATION = 'curation'
class QueryResultPassage:
"""
A passage query result.
:param str passage_text: (optional) The content of the extracted passage.
:param int start_offset: (optional) The position of the first character of the
extracted passage in the originating field.
:param int end_offset: (optional) The position after the last character of the
extracted passage in the originating field.
:param str field: (optional) The label of the field from which the passage has
been extracted.
:param List[ResultPassageAnswer] answers: (optional) An arry of extracted
answers to the specified query. Returned for natural language queries when
**passages.per_document** is `true`.
"""
def __init__(
self,
*,
passage_text: Optional[str] = None,
start_offset: Optional[int] = None,
end_offset: Optional[int] = None,
field: Optional[str] = None,
answers: Optional[List['ResultPassageAnswer']] = None,
) -> None:
"""
Initialize a QueryResultPassage object.
:param str passage_text: (optional) The content of the extracted passage.
:param int start_offset: (optional) The position of the first character of
the extracted passage in the originating field.
:param int end_offset: (optional) The position after the last character of
the extracted passage in the originating field.
:param str field: (optional) The label of the field from which the passage
has been extracted.
:param List[ResultPassageAnswer] answers: (optional) An arry of extracted
answers to the specified query. Returned for natural language queries when
**passages.per_document** is `true`.
"""
self.passage_text = passage_text
self.start_offset = start_offset
self.end_offset = end_offset
self.field = field
self.answers = answers
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryResultPassage':
"""Initialize a QueryResultPassage object from a json dictionary."""
args = {}
if (passage_text := _dict.get('passage_text')) is not None:
args['passage_text'] = passage_text
if (start_offset := _dict.get('start_offset')) is not None:
args['start_offset'] = start_offset
if (end_offset := _dict.get('end_offset')) is not None:
args['end_offset'] = end_offset
if (field := _dict.get('field')) is not None:
args['field'] = field
if (answers := _dict.get('answers')) is not None:
args['answers'] = [
ResultPassageAnswer.from_dict(v) for v in answers
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryResultPassage object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'passage_text') and self.passage_text is not None:
_dict['passage_text'] = self.passage_text
if hasattr(self, 'start_offset') and self.start_offset is not None:
_dict['start_offset'] = self.start_offset
if hasattr(self, 'end_offset') and self.end_offset is not None:
_dict['end_offset'] = self.end_offset
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
if hasattr(self, 'answers') and self.answers is not None:
answers_list = []
for v in self.answers:
if isinstance(v, dict):
answers_list.append(v)
else:
answers_list.append(v.to_dict())
_dict['answers'] = answers_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryResultPassage object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryResultPassage') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryResultPassage') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QuerySuggestedRefinement:
"""
A suggested additional query term or terms user to filter results. **Note**: The
`suggested_refinements` parameter is deprecated.
:param str text: (optional) The text used to filter.
"""
def __init__(
self,
*,
text: Optional[str] = None,
) -> None:
"""
Initialize a QuerySuggestedRefinement object.
:param str text: (optional) The text used to filter.
"""
self.text = text
@classmethod
def from_dict(cls, _dict: Dict) -> 'QuerySuggestedRefinement':
"""Initialize a QuerySuggestedRefinement object from a json dictionary."""
args = {}
if (text := _dict.get('text')) is not None:
args['text'] = text
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QuerySuggestedRefinement object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QuerySuggestedRefinement object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QuerySuggestedRefinement') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QuerySuggestedRefinement') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryTableResult:
"""
A tables whose content or context match a search query.
:param str table_id: (optional) The identifier for the retrieved table.
:param str source_document_id: (optional) The identifier of the document the
table was retrieved from.
:param str collection_id: (optional) The identifier of the collection the table
was retrieved from.
:param str table_html: (optional) HTML snippet of the table info.
:param int table_html_offset: (optional) The offset of the table html snippet in
the original document html.
:param TableResultTable table: (optional) Full table object retrieved from Table
Understanding Enrichment.
"""
def __init__(
self,
*,
table_id: Optional[str] = None,
source_document_id: Optional[str] = None,
collection_id: Optional[str] = None,
table_html: Optional[str] = None,
table_html_offset: Optional[int] = None,
table: Optional['TableResultTable'] = None,
) -> None:
"""
Initialize a QueryTableResult object.
:param str table_id: (optional) The identifier for the retrieved table.
:param str source_document_id: (optional) The identifier of the document
the table was retrieved from.
:param str collection_id: (optional) The identifier of the collection the
table was retrieved from.
:param str table_html: (optional) HTML snippet of the table info.
:param int table_html_offset: (optional) The offset of the table html
snippet in the original document html.
:param TableResultTable table: (optional) Full table object retrieved from
Table Understanding Enrichment.
"""
self.table_id = table_id
self.source_document_id = source_document_id
self.collection_id = collection_id
self.table_html = table_html
self.table_html_offset = table_html_offset
self.table = table
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryTableResult':
"""Initialize a QueryTableResult object from a json dictionary."""
args = {}
if (table_id := _dict.get('table_id')) is not None:
args['table_id'] = table_id
if (source_document_id := _dict.get('source_document_id')) is not None:
args['source_document_id'] = source_document_id
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
if (table_html := _dict.get('table_html')) is not None:
args['table_html'] = table_html
if (table_html_offset := _dict.get('table_html_offset')) is not None:
args['table_html_offset'] = table_html_offset
if (table := _dict.get('table')) is not None:
args['table'] = TableResultTable.from_dict(table)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryTableResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'table_id') and self.table_id is not None:
_dict['table_id'] = self.table_id
if hasattr(
self,
'source_document_id') and self.source_document_id is not None:
_dict['source_document_id'] = self.source_document_id
if hasattr(self, 'collection_id') and self.collection_id is not None:
_dict['collection_id'] = self.collection_id
if hasattr(self, 'table_html') and self.table_html is not None:
_dict['table_html'] = self.table_html
if hasattr(self,
'table_html_offset') and self.table_html_offset is not None:
_dict['table_html_offset'] = self.table_html_offset
if hasattr(self, 'table') and self.table is not None:
if isinstance(self.table, dict):
_dict['table'] = self.table
else:
_dict['table'] = self.table.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryTableResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryTableResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryTableResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryTermAggregationResult:
"""
Top value result for the `term` aggregation.
:param str key: Value of the field with a nonzero frequency in the document set.
:param int matching_results: Number of documents that contain the 'key'.
:param float relevancy: (optional) The relevancy score for this result. Returned
only if `relevancy:true` is specified in the request.
:param int total_matching_documents: (optional) Number of documents in the
collection that contain the term in the specified field. Returned only when
`relevancy:true` is specified in the request.
:param float estimated_matching_results: (optional) Number of documents that are
estimated to match the query and also meet the condition. Returned only when
`relevancy:true` is specified in the request.
:param List[dict] aggregations: (optional) An array of subaggregations. Returned
only when this aggregation is combined with other aggregations in the request or
is returned as a subaggregation.
"""
def __init__(
self,
key: str,
matching_results: int,
*,
relevancy: Optional[float] = None,
total_matching_documents: Optional[int] = None,
estimated_matching_results: Optional[float] = None,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryTermAggregationResult object.
:param str key: Value of the field with a nonzero frequency in the document
set.
:param int matching_results: Number of documents that contain the 'key'.
:param float relevancy: (optional) The relevancy score for this result.
Returned only if `relevancy:true` is specified in the request.
:param int total_matching_documents: (optional) Number of documents in the
collection that contain the term in the specified field. Returned only when
`relevancy:true` is specified in the request.
:param float estimated_matching_results: (optional) Number of documents
that are estimated to match the query and also meet the condition. Returned
only when `relevancy:true` is specified in the request.
:param List[dict] aggregations: (optional) An array of subaggregations.
Returned only when this aggregation is combined with other aggregations in
the request or is returned as a subaggregation.
"""
self.key = key
self.matching_results = matching_results
self.relevancy = relevancy
self.total_matching_documents = total_matching_documents
self.estimated_matching_results = estimated_matching_results
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryTermAggregationResult':
"""Initialize a QueryTermAggregationResult object from a json dictionary."""
args = {}
if (key := _dict.get('key')) is not None:
args['key'] = key
else:
raise ValueError(
'Required property \'key\' not present in QueryTermAggregationResult JSON'
)
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryTermAggregationResult JSON'
)
if (relevancy := _dict.get('relevancy')) is not None:
args['relevancy'] = relevancy
if (total_matching_documents :=
_dict.get('total_matching_documents')) is not None:
args['total_matching_documents'] = total_matching_documents
if (estimated_matching_results :=
_dict.get('estimated_matching_results')) is not None:
args['estimated_matching_results'] = estimated_matching_results
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryTermAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'key') and self.key is not None:
_dict['key'] = self.key
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'relevancy') and self.relevancy is not None:
_dict['relevancy'] = self.relevancy
if hasattr(self, 'total_matching_documents'
) and self.total_matching_documents is not None:
_dict['total_matching_documents'] = self.total_matching_documents
if hasattr(self, 'estimated_matching_results'
) and self.estimated_matching_results is not None:
_dict[
'estimated_matching_results'] = self.estimated_matching_results
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryTermAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryTermAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryTermAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryTimesliceAggregationResult:
"""
A timeslice interval segment.
:param str key_as_string: String date value of the upper bound for the timeslice
interval in ISO-8601 format.
:param int key: Numeric date value of the upper bound for the timeslice interval
in UNIX milliseconds since epoch.
:param int matching_results: Number of documents with the specified key as the
upper bound.
:param List[dict] aggregations: (optional) An array of subaggregations. Returned
only when this aggregation is returned as a subaggregation.
"""
def __init__(
self,
key_as_string: str,
key: int,
matching_results: int,
*,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryTimesliceAggregationResult object.
:param str key_as_string: String date value of the upper bound for the
timeslice interval in ISO-8601 format.
:param int key: Numeric date value of the upper bound for the timeslice
interval in UNIX milliseconds since epoch.
:param int matching_results: Number of documents with the specified key as
the upper bound.
:param List[dict] aggregations: (optional) An array of subaggregations.
Returned only when this aggregation is returned as a subaggregation.
"""
self.key_as_string = key_as_string
self.key = key
self.matching_results = matching_results
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryTimesliceAggregationResult':
"""Initialize a QueryTimesliceAggregationResult object from a json dictionary."""
args = {}
if (key_as_string := _dict.get('key_as_string')) is not None:
args['key_as_string'] = key_as_string
else:
raise ValueError(
'Required property \'key_as_string\' not present in QueryTimesliceAggregationResult JSON'
)
if (key := _dict.get('key')) is not None:
args['key'] = key
else:
raise ValueError(
'Required property \'key\' not present in QueryTimesliceAggregationResult JSON'
)
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryTimesliceAggregationResult JSON'
)
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryTimesliceAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'key_as_string') and self.key_as_string is not None:
_dict['key_as_string'] = self.key_as_string
if hasattr(self, 'key') and self.key is not None:
_dict['key'] = self.key
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryTimesliceAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryTimesliceAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryTimesliceAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryTopHitsAggregationResult:
"""
A query response that contains the matching documents for the preceding aggregations.
:param int matching_results: Number of matching results.
:param List[dict] hits: (optional) An array of the document results in an
ordered list.
"""
def __init__(
self,
matching_results: int,
*,
hits: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryTopHitsAggregationResult object.
:param int matching_results: Number of matching results.
:param List[dict] hits: (optional) An array of the document results in an
ordered list.
"""
self.matching_results = matching_results
self.hits = hits
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryTopHitsAggregationResult':
"""Initialize a QueryTopHitsAggregationResult object from a json dictionary."""
args = {}
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryTopHitsAggregationResult JSON'
)
if (hits := _dict.get('hits')) is not None:
args['hits'] = hits
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryTopHitsAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'hits') and self.hits is not None:
_dict['hits'] = self.hits
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryTopHitsAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryTopHitsAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryTopHitsAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryTopicAggregationResult:
"""
Result for the `topic` aggregation.
:param List[dict] aggregations: (optional) Array of subaggregations of type
`term` or `group_by` and `timeslice`. Each element of the matrix that is
returned contains a **topic_indicator** that is calculated from the combination
of each aggregation value and segment of time.
"""
def __init__(
self,
*,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryTopicAggregationResult object.
:param List[dict] aggregations: (optional) Array of subaggregations of
type `term` or `group_by` and `timeslice`. Each element of the matrix that
is returned contains a **topic_indicator** that is calculated from the
combination of each aggregation value and segment of time.
"""
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryTopicAggregationResult':
"""Initialize a QueryTopicAggregationResult object from a json dictionary."""
args = {}
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryTopicAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryTopicAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryTopicAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryTopicAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryTrendAggregationResult:
"""
Result for the `trend` aggregation.
:param List[dict] aggregations: (optional) Array of subaggregations of type
`term` or `group_by` and `timeslice`. Each element of the matrix that is
returned contains a **trend_indicator** that is calculated from the combination
of each aggregation value and segment of time.
"""
def __init__(
self,
*,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryTrendAggregationResult object.
:param List[dict] aggregations: (optional) Array of subaggregations of type
`term` or `group_by` and `timeslice`. Each element of the matrix that is
returned contains a **trend_indicator** that is calculated from the
combination of each aggregation value and segment of time.
"""
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryTrendAggregationResult':
"""Initialize a QueryTrendAggregationResult object from a json dictionary."""
args = {}
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryTrendAggregationResult object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryTrendAggregationResult object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryTrendAggregationResult') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryTrendAggregationResult') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class ResultPassageAnswer:
"""
Object that contains a potential answer to the specified query.
:param str answer_text: (optional) Answer text for the specified query as
identified by Discovery.
:param int start_offset: (optional) The position of the first character of the
extracted answer in the originating field.
:param int end_offset: (optional) The position after the last character of the
extracted answer in the originating field.
:param float confidence: (optional) An estimate of the probability that the
answer is relevant.
"""
def __init__(
self,
*,
answer_text: Optional[str] = None,
start_offset: Optional[int] = None,
end_offset: Optional[int] = None,
confidence: Optional[float] = None,
) -> None:
"""
Initialize a ResultPassageAnswer object.
:param str answer_text: (optional) Answer text for the specified query as
identified by Discovery.
:param int start_offset: (optional) The position of the first character of
the extracted answer in the originating field.
:param int end_offset: (optional) The position after the last character of
the extracted answer in the originating field.
:param float confidence: (optional) An estimate of the probability that the
answer is relevant.
"""
self.answer_text = answer_text
self.start_offset = start_offset
self.end_offset = end_offset
self.confidence = confidence
@classmethod
def from_dict(cls, _dict: Dict) -> 'ResultPassageAnswer':
"""Initialize a ResultPassageAnswer object from a json dictionary."""
args = {}
if (answer_text := _dict.get('answer_text')) is not None:
args['answer_text'] = answer_text
if (start_offset := _dict.get('start_offset')) is not None:
args['start_offset'] = start_offset
if (end_offset := _dict.get('end_offset')) is not None:
args['end_offset'] = end_offset
if (confidence := _dict.get('confidence')) is not None:
args['confidence'] = confidence
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a ResultPassageAnswer object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'answer_text') and self.answer_text is not None:
_dict['answer_text'] = self.answer_text
if hasattr(self, 'start_offset') and self.start_offset is not None:
_dict['start_offset'] = self.start_offset
if hasattr(self, 'end_offset') and self.end_offset is not None:
_dict['end_offset'] = self.end_offset
if hasattr(self, 'confidence') and self.confidence is not None:
_dict['confidence'] = self.confidence
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this ResultPassageAnswer object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'ResultPassageAnswer') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'ResultPassageAnswer') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class RetrievalDetails:
"""
An object contain retrieval type information.
:param str document_retrieval_strategy: (optional) Identifies the document
retrieval strategy used for this query. `relevancy_training` indicates that the
results were returned using a relevancy trained model.
**Note**: In the event of trained collections being queried, but the trained
model is not used to return results, the **document_retrieval_strategy** is
listed as `untrained`.
"""
def __init__(
self,
*,
document_retrieval_strategy: Optional[str] = None,
) -> None:
"""
Initialize a RetrievalDetails object.
:param str document_retrieval_strategy: (optional) Identifies the document
retrieval strategy used for this query. `relevancy_training` indicates that
the results were returned using a relevancy trained model.
**Note**: In the event of trained collections being queried, but the
trained model is not used to return results, the
**document_retrieval_strategy** is listed as `untrained`.
"""
self.document_retrieval_strategy = document_retrieval_strategy
@classmethod
def from_dict(cls, _dict: Dict) -> 'RetrievalDetails':
"""Initialize a RetrievalDetails object from a json dictionary."""
args = {}
if (document_retrieval_strategy :=
_dict.get('document_retrieval_strategy')) is not None:
args['document_retrieval_strategy'] = document_retrieval_strategy
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a RetrievalDetails object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_retrieval_strategy'
) and self.document_retrieval_strategy is not None:
_dict[
'document_retrieval_strategy'] = self.document_retrieval_strategy
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this RetrievalDetails object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'RetrievalDetails') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'RetrievalDetails') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class DocumentRetrievalStrategyEnum(str, Enum):
"""
Identifies the document retrieval strategy used for this query.
`relevancy_training` indicates that the results were returned using a relevancy
trained model.
**Note**: In the event of trained collections being queried, but the trained model
is not used to return results, the **document_retrieval_strategy** is listed as
`untrained`.
"""
UNTRAINED = 'untrained'
RELEVANCY_TRAINING = 'relevancy_training'
class StopWordList:
"""
List of words to filter out of text that is submitted in queries.
:param List[str] stopwords: List of stop words.
"""
def __init__(
self,
stopwords: List[str],
) -> None:
"""
Initialize a StopWordList object.
:param List[str] stopwords: List of stop words.
"""
self.stopwords = stopwords
@classmethod
def from_dict(cls, _dict: Dict) -> 'StopWordList':
"""Initialize a StopWordList object from a json dictionary."""
args = {}
if (stopwords := _dict.get('stopwords')) is not None:
args['stopwords'] = stopwords
else:
raise ValueError(
'Required property \'stopwords\' not present in StopWordList JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a StopWordList object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'stopwords') and self.stopwords is not None:
_dict['stopwords'] = self.stopwords
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this StopWordList object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'StopWordList') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'StopWordList') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableBodyCells:
"""
Cells that are not table header, column header, or row header cells.
:param str cell_id: (optional) The unique ID of the cell in the current table.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The textual contents of this cell from the input
document without associated markup content.
:param int row_index_begin: (optional) The `begin` index of this cell's `row`
location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's `column`
location in the current table.
:param List[str] row_header_ids: (optional) A list of ID values that represent
the table row headers that are associated with this body cell.
:param List[str] row_header_texts: (optional) A list of row header values that
are associated with this body cell.
:param List[str] row_header_texts_normalized: (optional) A list of normalized
row header values that are associated with this body cell.
:param List[str] column_header_ids: (optional) A list of ID values that
represent the column headers that are associated with this body cell.
:param List[str] column_header_texts: (optional) A list of column header values
that are associated with this body cell.
:param List[str] column_header_texts_normalized: (optional) A list of normalized
column header values that are associated with this body cell.
:param List[DocumentAttribute] attributes: (optional) A list of document
attributes.
"""
def __init__(
self,
*,
cell_id: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
row_index_begin: Optional[int] = None,
row_index_end: Optional[int] = None,
column_index_begin: Optional[int] = None,
column_index_end: Optional[int] = None,
row_header_ids: Optional[List[str]] = None,
row_header_texts: Optional[List[str]] = None,
row_header_texts_normalized: Optional[List[str]] = None,
column_header_ids: Optional[List[str]] = None,
column_header_texts: Optional[List[str]] = None,
column_header_texts_normalized: Optional[List[str]] = None,
attributes: Optional[List['DocumentAttribute']] = None,
) -> None:
"""
Initialize a TableBodyCells object.
:param str cell_id: (optional) The unique ID of the cell in the current
table.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The textual contents of this cell from the
input document without associated markup content.
:param int row_index_begin: (optional) The `begin` index of this cell's
`row` location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's
`column` location in the current table.
:param List[str] row_header_ids: (optional) A list of ID values that
represent the table row headers that are associated with this body cell.
:param List[str] row_header_texts: (optional) A list of row header values
that are associated with this body cell.
:param List[str] row_header_texts_normalized: (optional) A list of
normalized row header values that are associated with this body cell.
:param List[str] column_header_ids: (optional) A list of ID values that
represent the column headers that are associated with this body cell.
:param List[str] column_header_texts: (optional) A list of column header
values that are associated with this body cell.
:param List[str] column_header_texts_normalized: (optional) A list of
normalized column header values that are associated with this body cell.
:param List[DocumentAttribute] attributes: (optional) A list of document
attributes.
"""
self.cell_id = cell_id
self.location = location
self.text = text
self.row_index_begin = row_index_begin
self.row_index_end = row_index_end
self.column_index_begin = column_index_begin
self.column_index_end = column_index_end
self.row_header_ids = row_header_ids
self.row_header_texts = row_header_texts
self.row_header_texts_normalized = row_header_texts_normalized
self.column_header_ids = column_header_ids
self.column_header_texts = column_header_texts
self.column_header_texts_normalized = column_header_texts_normalized
self.attributes = attributes
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableBodyCells':
"""Initialize a TableBodyCells object from a json dictionary."""
args = {}
if (cell_id := _dict.get('cell_id')) is not None:
args['cell_id'] = cell_id
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
if (row_index_begin := _dict.get('row_index_begin')) is not None:
args['row_index_begin'] = row_index_begin
if (row_index_end := _dict.get('row_index_end')) is not None:
args['row_index_end'] = row_index_end
if (column_index_begin := _dict.get('column_index_begin')) is not None:
args['column_index_begin'] = column_index_begin
if (column_index_end := _dict.get('column_index_end')) is not None:
args['column_index_end'] = column_index_end
if (row_header_ids := _dict.get('row_header_ids')) is not None:
args['row_header_ids'] = row_header_ids
if (row_header_texts := _dict.get('row_header_texts')) is not None:
args['row_header_texts'] = row_header_texts
if (row_header_texts_normalized :=
_dict.get('row_header_texts_normalized')) is not None:
args['row_header_texts_normalized'] = row_header_texts_normalized
if (column_header_ids := _dict.get('column_header_ids')) is not None:
args['column_header_ids'] = column_header_ids
if (column_header_texts :=
_dict.get('column_header_texts')) is not None:
args['column_header_texts'] = column_header_texts
if (column_header_texts_normalized :=
_dict.get('column_header_texts_normalized')) is not None:
args[
'column_header_texts_normalized'] = column_header_texts_normalized
if (attributes := _dict.get('attributes')) is not None:
args['attributes'] = [
DocumentAttribute.from_dict(v) for v in attributes
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableBodyCells object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'cell_id') and self.cell_id is not None:
_dict['cell_id'] = self.cell_id
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self,
'row_index_begin') and self.row_index_begin is not None:
_dict['row_index_begin'] = self.row_index_begin
if hasattr(self, 'row_index_end') and self.row_index_end is not None:
_dict['row_index_end'] = self.row_index_end
if hasattr(
self,
'column_index_begin') and self.column_index_begin is not None:
_dict['column_index_begin'] = self.column_index_begin
if hasattr(self,
'column_index_end') and self.column_index_end is not None:
_dict['column_index_end'] = self.column_index_end
if hasattr(self, 'row_header_ids') and self.row_header_ids is not None:
_dict['row_header_ids'] = self.row_header_ids
if hasattr(self,
'row_header_texts') and self.row_header_texts is not None:
_dict['row_header_texts'] = self.row_header_texts
if hasattr(self, 'row_header_texts_normalized'
) and self.row_header_texts_normalized is not None:
_dict[
'row_header_texts_normalized'] = self.row_header_texts_normalized
if hasattr(self,
'column_header_ids') and self.column_header_ids is not None:
_dict['column_header_ids'] = self.column_header_ids
if hasattr(
self,
'column_header_texts') and self.column_header_texts is not None:
_dict['column_header_texts'] = self.column_header_texts
if hasattr(self, 'column_header_texts_normalized'
) and self.column_header_texts_normalized is not None:
_dict[
'column_header_texts_normalized'] = self.column_header_texts_normalized
if hasattr(self, 'attributes') and self.attributes is not None:
attributes_list = []
for v in self.attributes:
if isinstance(v, dict):
attributes_list.append(v)
else:
attributes_list.append(v.to_dict())
_dict['attributes'] = attributes_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableBodyCells object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableBodyCells') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableBodyCells') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableCellKey:
"""
A key in a key-value pair.
:param str cell_id: (optional) The unique ID of the key in the table.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The text content of the table cell without HTML
markup.
"""
def __init__(
self,
*,
cell_id: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
) -> None:
"""
Initialize a TableCellKey object.
:param str cell_id: (optional) The unique ID of the key in the table.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The text content of the table cell without HTML
markup.
"""
self.cell_id = cell_id
self.location = location
self.text = text
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableCellKey':
"""Initialize a TableCellKey object from a json dictionary."""
args = {}
if (cell_id := _dict.get('cell_id')) is not None:
args['cell_id'] = cell_id
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableCellKey object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'cell_id') and self.cell_id is not None:
_dict['cell_id'] = self.cell_id
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableCellKey object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableCellKey') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableCellKey') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableCellValues:
"""
A value in a key-value pair.
:param str cell_id: (optional) The unique ID of the value in the table.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The text content of the table cell without HTML
markup.
"""
def __init__(
self,
*,
cell_id: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
) -> None:
"""
Initialize a TableCellValues object.
:param str cell_id: (optional) The unique ID of the value in the table.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The text content of the table cell without HTML
markup.
"""
self.cell_id = cell_id
self.location = location
self.text = text
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableCellValues':
"""Initialize a TableCellValues object from a json dictionary."""
args = {}
if (cell_id := _dict.get('cell_id')) is not None:
args['cell_id'] = cell_id
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableCellValues object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'cell_id') and self.cell_id is not None:
_dict['cell_id'] = self.cell_id
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableCellValues object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableCellValues') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableCellValues') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableColumnHeaders:
"""
Column-level cells, each applicable as a header to other cells in the same column as
itself, of the current table.
:param str cell_id: (optional) The unique ID of the cell in the current table.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The textual contents of this cell from the input
document without associated markup content.
:param str text_normalized: (optional) Normalized column header text.
:param int row_index_begin: (optional) The `begin` index of this cell's `row`
location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's `column`
location in the current table.
"""
def __init__(
self,
*,
cell_id: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
text_normalized: Optional[str] = None,
row_index_begin: Optional[int] = None,
row_index_end: Optional[int] = None,
column_index_begin: Optional[int] = None,
column_index_end: Optional[int] = None,
) -> None:
"""
Initialize a TableColumnHeaders object.
:param str cell_id: (optional) The unique ID of the cell in the current
table.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The textual contents of this cell from the
input document without associated markup content.
:param str text_normalized: (optional) Normalized column header text.
:param int row_index_begin: (optional) The `begin` index of this cell's
`row` location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's
`column` location in the current table.
"""
self.cell_id = cell_id
self.location = location
self.text = text
self.text_normalized = text_normalized
self.row_index_begin = row_index_begin
self.row_index_end = row_index_end
self.column_index_begin = column_index_begin
self.column_index_end = column_index_end
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableColumnHeaders':
"""Initialize a TableColumnHeaders object from a json dictionary."""
args = {}
if (cell_id := _dict.get('cell_id')) is not None:
args['cell_id'] = cell_id
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
if (text_normalized := _dict.get('text_normalized')) is not None:
args['text_normalized'] = text_normalized
if (row_index_begin := _dict.get('row_index_begin')) is not None:
args['row_index_begin'] = row_index_begin
if (row_index_end := _dict.get('row_index_end')) is not None:
args['row_index_end'] = row_index_end
if (column_index_begin := _dict.get('column_index_begin')) is not None:
args['column_index_begin'] = column_index_begin
if (column_index_end := _dict.get('column_index_end')) is not None:
args['column_index_end'] = column_index_end
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableColumnHeaders object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'cell_id') and self.cell_id is not None:
_dict['cell_id'] = self.cell_id
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self,
'text_normalized') and self.text_normalized is not None:
_dict['text_normalized'] = self.text_normalized
if hasattr(self,
'row_index_begin') and self.row_index_begin is not None:
_dict['row_index_begin'] = self.row_index_begin
if hasattr(self, 'row_index_end') and self.row_index_end is not None:
_dict['row_index_end'] = self.row_index_end
if hasattr(
self,
'column_index_begin') and self.column_index_begin is not None:
_dict['column_index_begin'] = self.column_index_begin
if hasattr(self,
'column_index_end') and self.column_index_end is not None:
_dict['column_index_end'] = self.column_index_end
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableColumnHeaders object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableColumnHeaders') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableColumnHeaders') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableElementLocation:
"""
The numeric location of the identified element in the document, represented with two
integers labeled `begin` and `end`.
:param int begin: The element's `begin` index.
:param int end: The element's `end` index.
"""
def __init__(
self,
begin: int,
end: int,
) -> None:
"""
Initialize a TableElementLocation object.
:param int begin: The element's `begin` index.
:param int end: The element's `end` index.
"""
self.begin = begin
self.end = end
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableElementLocation':
"""Initialize a TableElementLocation object from a json dictionary."""
args = {}
if (begin := _dict.get('begin')) is not None:
args['begin'] = begin
else:
raise ValueError(
'Required property \'begin\' not present in TableElementLocation JSON'
)
if (end := _dict.get('end')) is not None:
args['end'] = end
else:
raise ValueError(
'Required property \'end\' not present in TableElementLocation JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableElementLocation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'begin') and self.begin is not None:
_dict['begin'] = self.begin
if hasattr(self, 'end') and self.end is not None:
_dict['end'] = self.end
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableElementLocation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableElementLocation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableElementLocation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableHeaders:
"""
The contents of the current table's header.
:param str cell_id: (optional) The unique ID of the cell in the current table.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The textual contents of the cell from the input
document without associated markup content.
:param int row_index_begin: (optional) The `begin` index of this cell's `row`
location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's `column`
location in the current table.
"""
def __init__(
self,
*,
cell_id: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
row_index_begin: Optional[int] = None,
row_index_end: Optional[int] = None,
column_index_begin: Optional[int] = None,
column_index_end: Optional[int] = None,
) -> None:
"""
Initialize a TableHeaders object.
:param str cell_id: (optional) The unique ID of the cell in the current
table.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The textual contents of the cell from the input
document without associated markup content.
:param int row_index_begin: (optional) The `begin` index of this cell's
`row` location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's
`column` location in the current table.
"""
self.cell_id = cell_id
self.location = location
self.text = text
self.row_index_begin = row_index_begin
self.row_index_end = row_index_end
self.column_index_begin = column_index_begin
self.column_index_end = column_index_end
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableHeaders':
"""Initialize a TableHeaders object from a json dictionary."""
args = {}
if (cell_id := _dict.get('cell_id')) is not None:
args['cell_id'] = cell_id
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
if (row_index_begin := _dict.get('row_index_begin')) is not None:
args['row_index_begin'] = row_index_begin
if (row_index_end := _dict.get('row_index_end')) is not None:
args['row_index_end'] = row_index_end
if (column_index_begin := _dict.get('column_index_begin')) is not None:
args['column_index_begin'] = column_index_begin
if (column_index_end := _dict.get('column_index_end')) is not None:
args['column_index_end'] = column_index_end
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableHeaders object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'cell_id') and self.cell_id is not None:
_dict['cell_id'] = self.cell_id
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self,
'row_index_begin') and self.row_index_begin is not None:
_dict['row_index_begin'] = self.row_index_begin
if hasattr(self, 'row_index_end') and self.row_index_end is not None:
_dict['row_index_end'] = self.row_index_end
if hasattr(
self,
'column_index_begin') and self.column_index_begin is not None:
_dict['column_index_begin'] = self.column_index_begin
if hasattr(self,
'column_index_end') and self.column_index_end is not None:
_dict['column_index_end'] = self.column_index_end
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableHeaders object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableHeaders') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableHeaders') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableKeyValuePairs:
"""
Key-value pairs detected across cell boundaries.
:param TableCellKey key: (optional) A key in a key-value pair.
:param List[TableCellValues] value: (optional) A list of values in a key-value
pair.
"""
def __init__(
self,
*,
key: Optional['TableCellKey'] = None,
value: Optional[List['TableCellValues']] = None,
) -> None:
"""
Initialize a TableKeyValuePairs object.
:param TableCellKey key: (optional) A key in a key-value pair.
:param List[TableCellValues] value: (optional) A list of values in a
key-value pair.
"""
self.key = key
self.value = value
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableKeyValuePairs':
"""Initialize a TableKeyValuePairs object from a json dictionary."""
args = {}
if (key := _dict.get('key')) is not None:
args['key'] = TableCellKey.from_dict(key)
if (value := _dict.get('value')) is not None:
args['value'] = [TableCellValues.from_dict(v) for v in value]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableKeyValuePairs object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'key') and self.key is not None:
if isinstance(self.key, dict):
_dict['key'] = self.key
else:
_dict['key'] = self.key.to_dict()
if hasattr(self, 'value') and self.value is not None:
value_list = []
for v in self.value:
if isinstance(v, dict):
value_list.append(v)
else:
value_list.append(v.to_dict())
_dict['value'] = value_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableKeyValuePairs object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableKeyValuePairs') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableKeyValuePairs') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableResultTable:
"""
Full table object retrieved from Table Understanding Enrichment.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The textual contents of the current table from the
input document without associated markup content.
:param TableTextLocation section_title: (optional) Text and associated location
within a table.
:param TableTextLocation title: (optional) Text and associated location within a
table.
:param List[TableHeaders] table_headers: (optional) An array of table-level
cells that apply as headers to all the other cells in the current table.
:param List[TableRowHeaders] row_headers: (optional) An array of row-level
cells, each applicable as a header to other cells in the same row as itself, of
the current table.
:param List[TableColumnHeaders] column_headers: (optional) An array of
column-level cells, each applicable as a header to other cells in the same
column as itself, of the current table.
:param List[TableKeyValuePairs] key_value_pairs: (optional) An array of
key-value pairs identified in the current table.
:param List[TableBodyCells] body_cells: (optional) An array of cells that are
neither table header nor column header nor row header cells, of the current
table with corresponding row and column header associations.
:param List[TableTextLocation] contexts: (optional) An array of lists of textual
entries across the document related to the current table being parsed.
"""
def __init__(
self,
*,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
section_title: Optional['TableTextLocation'] = None,
title: Optional['TableTextLocation'] = None,
table_headers: Optional[List['TableHeaders']] = None,
row_headers: Optional[List['TableRowHeaders']] = None,
column_headers: Optional[List['TableColumnHeaders']] = None,
key_value_pairs: Optional[List['TableKeyValuePairs']] = None,
body_cells: Optional[List['TableBodyCells']] = None,
contexts: Optional[List['TableTextLocation']] = None,
) -> None:
"""
Initialize a TableResultTable object.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The textual contents of the current table from
the input document without associated markup content.
:param TableTextLocation section_title: (optional) Text and associated
location within a table.
:param TableTextLocation title: (optional) Text and associated location
within a table.
:param List[TableHeaders] table_headers: (optional) An array of table-level
cells that apply as headers to all the other cells in the current table.
:param List[TableRowHeaders] row_headers: (optional) An array of row-level
cells, each applicable as a header to other cells in the same row as
itself, of the current table.
:param List[TableColumnHeaders] column_headers: (optional) An array of
column-level cells, each applicable as a header to other cells in the same
column as itself, of the current table.
:param List[TableKeyValuePairs] key_value_pairs: (optional) An array of
key-value pairs identified in the current table.
:param List[TableBodyCells] body_cells: (optional) An array of cells that
are neither table header nor column header nor row header cells, of the
current table with corresponding row and column header associations.
:param List[TableTextLocation] contexts: (optional) An array of lists of
textual entries across the document related to the current table being
parsed.
"""
self.location = location
self.text = text
self.section_title = section_title
self.title = title
self.table_headers = table_headers
self.row_headers = row_headers
self.column_headers = column_headers
self.key_value_pairs = key_value_pairs
self.body_cells = body_cells
self.contexts = contexts
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableResultTable':
"""Initialize a TableResultTable object from a json dictionary."""
args = {}
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
if (section_title := _dict.get('section_title')) is not None:
args['section_title'] = TableTextLocation.from_dict(section_title)
if (title := _dict.get('title')) is not None:
args['title'] = TableTextLocation.from_dict(title)
if (table_headers := _dict.get('table_headers')) is not None:
args['table_headers'] = [
TableHeaders.from_dict(v) for v in table_headers
]
if (row_headers := _dict.get('row_headers')) is not None:
args['row_headers'] = [
TableRowHeaders.from_dict(v) for v in row_headers
]
if (column_headers := _dict.get('column_headers')) is not None:
args['column_headers'] = [
TableColumnHeaders.from_dict(v) for v in column_headers
]
if (key_value_pairs := _dict.get('key_value_pairs')) is not None:
args['key_value_pairs'] = [
TableKeyValuePairs.from_dict(v) for v in key_value_pairs
]
if (body_cells := _dict.get('body_cells')) is not None:
args['body_cells'] = [
TableBodyCells.from_dict(v) for v in body_cells
]
if (contexts := _dict.get('contexts')) is not None:
args['contexts'] = [
TableTextLocation.from_dict(v) for v in contexts
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableResultTable object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self, 'section_title') and self.section_title is not None:
if isinstance(self.section_title, dict):
_dict['section_title'] = self.section_title
else:
_dict['section_title'] = self.section_title.to_dict()
if hasattr(self, 'title') and self.title is not None:
if isinstance(self.title, dict):
_dict['title'] = self.title
else:
_dict['title'] = self.title.to_dict()
if hasattr(self, 'table_headers') and self.table_headers is not None:
table_headers_list = []
for v in self.table_headers:
if isinstance(v, dict):
table_headers_list.append(v)
else:
table_headers_list.append(v.to_dict())
_dict['table_headers'] = table_headers_list
if hasattr(self, 'row_headers') and self.row_headers is not None:
row_headers_list = []
for v in self.row_headers:
if isinstance(v, dict):
row_headers_list.append(v)
else:
row_headers_list.append(v.to_dict())
_dict['row_headers'] = row_headers_list
if hasattr(self, 'column_headers') and self.column_headers is not None:
column_headers_list = []
for v in self.column_headers:
if isinstance(v, dict):
column_headers_list.append(v)
else:
column_headers_list.append(v.to_dict())
_dict['column_headers'] = column_headers_list
if hasattr(self,
'key_value_pairs') and self.key_value_pairs is not None:
key_value_pairs_list = []
for v in self.key_value_pairs:
if isinstance(v, dict):
key_value_pairs_list.append(v)
else:
key_value_pairs_list.append(v.to_dict())
_dict['key_value_pairs'] = key_value_pairs_list
if hasattr(self, 'body_cells') and self.body_cells is not None:
body_cells_list = []
for v in self.body_cells:
if isinstance(v, dict):
body_cells_list.append(v)
else:
body_cells_list.append(v.to_dict())
_dict['body_cells'] = body_cells_list
if hasattr(self, 'contexts') and self.contexts is not None:
contexts_list = []
for v in self.contexts:
if isinstance(v, dict):
contexts_list.append(v)
else:
contexts_list.append(v.to_dict())
_dict['contexts'] = contexts_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableResultTable object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableResultTable') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableResultTable') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableRowHeaders:
"""
Row-level cells, each applicable as a header to other cells in the same row as itself,
of the current table.
:param str cell_id: (optional) The unique ID of the cell in the current table.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
:param str text: (optional) The textual contents of this cell from the input
document without associated markup content.
:param str text_normalized: (optional) Normalized row header text.
:param int row_index_begin: (optional) The `begin` index of this cell's `row`
location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's `column`
location in the current table.
"""
def __init__(
self,
*,
cell_id: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
text: Optional[str] = None,
text_normalized: Optional[str] = None,
row_index_begin: Optional[int] = None,
row_index_end: Optional[int] = None,
column_index_begin: Optional[int] = None,
column_index_end: Optional[int] = None,
) -> None:
"""
Initialize a TableRowHeaders object.
:param str cell_id: (optional) The unique ID of the cell in the current
table.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
:param str text: (optional) The textual contents of this cell from the
input document without associated markup content.
:param str text_normalized: (optional) Normalized row header text.
:param int row_index_begin: (optional) The `begin` index of this cell's
`row` location in the current table.
:param int row_index_end: (optional) The `end` index of this cell's `row`
location in the current table.
:param int column_index_begin: (optional) The `begin` index of this cell's
`column` location in the current table.
:param int column_index_end: (optional) The `end` index of this cell's
`column` location in the current table.
"""
self.cell_id = cell_id
self.location = location
self.text = text
self.text_normalized = text_normalized
self.row_index_begin = row_index_begin
self.row_index_end = row_index_end
self.column_index_begin = column_index_begin
self.column_index_end = column_index_end
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableRowHeaders':
"""Initialize a TableRowHeaders object from a json dictionary."""
args = {}
if (cell_id := _dict.get('cell_id')) is not None:
args['cell_id'] = cell_id
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
if (text := _dict.get('text')) is not None:
args['text'] = text
if (text_normalized := _dict.get('text_normalized')) is not None:
args['text_normalized'] = text_normalized
if (row_index_begin := _dict.get('row_index_begin')) is not None:
args['row_index_begin'] = row_index_begin
if (row_index_end := _dict.get('row_index_end')) is not None:
args['row_index_end'] = row_index_end
if (column_index_begin := _dict.get('column_index_begin')) is not None:
args['column_index_begin'] = column_index_begin
if (column_index_end := _dict.get('column_index_end')) is not None:
args['column_index_end'] = column_index_end
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableRowHeaders object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'cell_id') and self.cell_id is not None:
_dict['cell_id'] = self.cell_id
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self,
'text_normalized') and self.text_normalized is not None:
_dict['text_normalized'] = self.text_normalized
if hasattr(self,
'row_index_begin') and self.row_index_begin is not None:
_dict['row_index_begin'] = self.row_index_begin
if hasattr(self, 'row_index_end') and self.row_index_end is not None:
_dict['row_index_end'] = self.row_index_end
if hasattr(
self,
'column_index_begin') and self.column_index_begin is not None:
_dict['column_index_begin'] = self.column_index_begin
if hasattr(self,
'column_index_end') and self.column_index_end is not None:
_dict['column_index_end'] = self.column_index_end
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableRowHeaders object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableRowHeaders') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableRowHeaders') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TableTextLocation:
"""
Text and associated location within a table.
:param str text: (optional) The text retrieved.
:param TableElementLocation location: (optional) The numeric location of the
identified element in the document, represented with two integers labeled
`begin` and `end`.
"""
def __init__(
self,
*,
text: Optional[str] = None,
location: Optional['TableElementLocation'] = None,
) -> None:
"""
Initialize a TableTextLocation object.
:param str text: (optional) The text retrieved.
:param TableElementLocation location: (optional) The numeric location of
the identified element in the document, represented with two integers
labeled `begin` and `end`.
"""
self.text = text
self.location = location
@classmethod
def from_dict(cls, _dict: Dict) -> 'TableTextLocation':
"""Initialize a TableTextLocation object from a json dictionary."""
args = {}
if (text := _dict.get('text')) is not None:
args['text'] = text
if (location := _dict.get('location')) is not None:
args['location'] = TableElementLocation.from_dict(location)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TableTextLocation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self, 'location') and self.location is not None:
if isinstance(self.location, dict):
_dict['location'] = self.location
else:
_dict['location'] = self.location.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TableTextLocation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TableTextLocation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TableTextLocation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TrainingExample:
"""
Object that contains example response details for a training query.
:param str document_id: The document ID associated with this training example.
:param str collection_id: The collection ID associated with this training
example.
:param int relevance: The relevance score of the training example. Scores range
from `0` to `100`. Zero means not relevant. The higher the number, the more
relevant the example.
:param datetime created: (optional) The date and time the example was created.
:param datetime updated: (optional) The date and time the example was updated.
"""
def __init__(
self,
document_id: str,
collection_id: str,
relevance: int,
*,
created: Optional[datetime] = None,
updated: Optional[datetime] = None,
) -> None:
"""
Initialize a TrainingExample object.
:param str document_id: The document ID associated with this training
example.
:param str collection_id: The collection ID associated with this training
example.
:param int relevance: The relevance score of the training example. Scores
range from `0` to `100`. Zero means not relevant. The higher the number,
the more relevant the example.
"""
self.document_id = document_id
self.collection_id = collection_id
self.relevance = relevance
self.created = created
self.updated = updated
@classmethod
def from_dict(cls, _dict: Dict) -> 'TrainingExample':
"""Initialize a TrainingExample object from a json dictionary."""
args = {}
if (document_id := _dict.get('document_id')) is not None:
args['document_id'] = document_id
else:
raise ValueError(
'Required property \'document_id\' not present in TrainingExample JSON'
)
if (collection_id := _dict.get('collection_id')) is not None:
args['collection_id'] = collection_id
else:
raise ValueError(
'Required property \'collection_id\' not present in TrainingExample JSON'
)
if (relevance := _dict.get('relevance')) is not None:
args['relevance'] = relevance
else:
raise ValueError(
'Required property \'relevance\' not present in TrainingExample JSON'
)
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (updated := _dict.get('updated')) is not None:
args['updated'] = string_to_datetime(updated)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TrainingExample object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_id') and self.document_id is not None:
_dict['document_id'] = self.document_id
if hasattr(self, 'collection_id') and self.collection_id is not None:
_dict['collection_id'] = self.collection_id
if hasattr(self, 'relevance') and self.relevance is not None:
_dict['relevance'] = self.relevance
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'updated') and getattr(self, 'updated') is not None:
_dict['updated'] = datetime_to_string(getattr(self, 'updated'))
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TrainingExample object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TrainingExample') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TrainingExample') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TrainingQuery:
"""
Object that contains training query details.
:param str query_id: (optional) The query ID associated with the training query.
:param str natural_language_query: The natural text query that is used as the
training query.
:param str filter: (optional) The filter used on the collection before the
**natural_language_query** is applied. Only specify a filter if the documents
that you consider to be most relevant are not included in the top 100 results
when you submit test queries. If you specify a filter during training, apply the
same filter to queries that are submitted at runtime for optimal ranking
results.
:param datetime created: (optional) The date and time the query was created.
:param datetime updated: (optional) The date and time the query was updated.
:param List[TrainingExample] examples: Array of training examples.
"""
def __init__(
self,
natural_language_query: str,
examples: List['TrainingExample'],
*,
query_id: Optional[str] = None,
filter: Optional[str] = None,
created: Optional[datetime] = None,
updated: Optional[datetime] = None,
) -> None:
"""
Initialize a TrainingQuery object.
:param str natural_language_query: The natural text query that is used as
the training query.
:param List[TrainingExample] examples: Array of training examples.
:param str filter: (optional) The filter used on the collection before the
**natural_language_query** is applied. Only specify a filter if the
documents that you consider to be most relevant are not included in the top
100 results when you submit test queries. If you specify a filter during
training, apply the same filter to queries that are submitted at runtime
for optimal ranking results.
"""
self.query_id = query_id
self.natural_language_query = natural_language_query
self.filter = filter
self.created = created
self.updated = updated
self.examples = examples
@classmethod
def from_dict(cls, _dict: Dict) -> 'TrainingQuery':
"""Initialize a TrainingQuery object from a json dictionary."""
args = {}
if (query_id := _dict.get('query_id')) is not None:
args['query_id'] = query_id
if (natural_language_query :=
_dict.get('natural_language_query')) is not None:
args['natural_language_query'] = natural_language_query
else:
raise ValueError(
'Required property \'natural_language_query\' not present in TrainingQuery JSON'
)
if (filter := _dict.get('filter')) is not None:
args['filter'] = filter
if (created := _dict.get('created')) is not None:
args['created'] = string_to_datetime(created)
if (updated := _dict.get('updated')) is not None:
args['updated'] = string_to_datetime(updated)
if (examples := _dict.get('examples')) is not None:
args['examples'] = [TrainingExample.from_dict(v) for v in examples]
else:
raise ValueError(
'Required property \'examples\' not present in TrainingQuery JSON'
)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TrainingQuery object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'query_id') and getattr(self, 'query_id') is not None:
_dict['query_id'] = getattr(self, 'query_id')
if hasattr(self, 'natural_language_query'
) and self.natural_language_query is not None:
_dict['natural_language_query'] = self.natural_language_query
if hasattr(self, 'filter') and self.filter is not None:
_dict['filter'] = self.filter
if hasattr(self, 'created') and getattr(self, 'created') is not None:
_dict['created'] = datetime_to_string(getattr(self, 'created'))
if hasattr(self, 'updated') and getattr(self, 'updated') is not None:
_dict['updated'] = datetime_to_string(getattr(self, 'updated'))
if hasattr(self, 'examples') and self.examples is not None:
examples_list = []
for v in self.examples:
if isinstance(v, dict):
examples_list.append(v)
else:
examples_list.append(v.to_dict())
_dict['examples'] = examples_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TrainingQuery object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TrainingQuery') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TrainingQuery') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class TrainingQuerySet:
"""
Object specifying the training queries contained in the identified training set.
:param List[TrainingQuery] queries: (optional) Array of training queries. At
least 50 queries are required for training to begin. A maximum of 10,000 queries
are returned.
"""
def __init__(
self,
*,
queries: Optional[List['TrainingQuery']] = None,
) -> None:
"""
Initialize a TrainingQuerySet object.
:param List[TrainingQuery] queries: (optional) Array of training queries.
At least 50 queries are required for training to begin. A maximum of 10,000
queries are returned.
"""
self.queries = queries
@classmethod
def from_dict(cls, _dict: Dict) -> 'TrainingQuerySet':
"""Initialize a TrainingQuerySet object from a json dictionary."""
args = {}
if (queries := _dict.get('queries')) is not None:
args['queries'] = [TrainingQuery.from_dict(v) for v in queries]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a TrainingQuerySet object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'queries') and self.queries is not None:
queries_list = []
for v in self.queries:
if isinstance(v, dict):
queries_list.append(v)
else:
queries_list.append(v.to_dict())
_dict['queries'] = queries_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this TrainingQuerySet object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'TrainingQuerySet') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'TrainingQuerySet') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class UpdateDocumentClassifier:
"""
An object that contains a new name or description for a document classifier, updated
training data, or new or updated test data.
:param str name: (optional) A new name for the classifier.
:param str description: (optional) A new description for the classifier.
"""
def __init__(
self,
*,
name: Optional[str] = None,
description: Optional[str] = None,
) -> None:
"""
Initialize a UpdateDocumentClassifier object.
:param str name: (optional) A new name for the classifier.
:param str description: (optional) A new description for the classifier.
"""
self.name = name
self.description = description
@classmethod
def from_dict(cls, _dict: Dict) -> 'UpdateDocumentClassifier':
"""Initialize a UpdateDocumentClassifier object from a json dictionary."""
args = {}
if (name := _dict.get('name')) is not None:
args['name'] = name
if (description := _dict.get('description')) is not None:
args['description'] = description
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a UpdateDocumentClassifier object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'description') and self.description is not None:
_dict['description'] = self.description
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this UpdateDocumentClassifier object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'UpdateDocumentClassifier') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'UpdateDocumentClassifier') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class WebhookHeader:
"""
An array of headers to pass with the HTTP request. Optional when `type` is `webhook`.
Not valid when creating any other type of enrichment.
:param str name: The name of an HTTP header.
:param str value: The value of an HTTP header.
"""
def __init__(
self,
name: str,
value: str,
) -> None:
"""
Initialize a WebhookHeader object.
:param str name: The name of an HTTP header.
:param str value: The value of an HTTP header.
"""
self.name = name
self.value = value
@classmethod
def from_dict(cls, _dict: Dict) -> 'WebhookHeader':
"""Initialize a WebhookHeader object from a json dictionary."""
args = {}
if (name := _dict.get('name')) is not None:
args['name'] = name
else:
raise ValueError(
'Required property \'name\' not present in WebhookHeader JSON')
if (value := _dict.get('value')) is not None:
args['value'] = value
else:
raise ValueError(
'Required property \'value\' not present in WebhookHeader JSON')
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a WebhookHeader object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'value') and self.value is not None:
_dict['value'] = self.value
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this WebhookHeader object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'WebhookHeader') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'WebhookHeader') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class PullBatchesResponse:
"""
A compressed newline delimited JSON (NDJSON) file containing the document. The NDJSON
format is used to describe structured data. The file name format is
`{batch_id}.ndjson.gz`. For more information, see [Binary attachment from the pull
batches
method](/docs/discovery-data?topic=discovery-data-external-enrichment#binary-attachment-pull-batches).
:param str file: (optional) A compressed NDJSON file containing the document.
"""
def __init__(
self,
*,
file: Optional[str] = None,
) -> None:
"""
Initialize a PullBatchesResponse object.
:param str file: (optional) A compressed NDJSON file containing the
document.
"""
self.file = file
@classmethod
def from_dict(cls, _dict: Dict) -> 'PullBatchesResponse':
"""Initialize a PullBatchesResponse object from a json dictionary."""
args = {}
if (file := _dict.get('file')) is not None:
args['file'] = file
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a PullBatchesResponse object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'file') and self.file is not None:
_dict['file'] = self.file
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this PullBatchesResponse object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'PullBatchesResponse') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'PullBatchesResponse') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryCalculationAggregation(QueryAggregation):
"""
Returns a scalar calculation across all documents for the field specified. Possible
calculations include min, max, sum, average, and unique_count.
:param str type: (optional) Specifies the calculation type, such as 'average`,
`max`, `min`, `sum`, or `unique_count`.
:param str field: The field to perform the calculation on.
:param float value: (optional) The value of the calculation.
"""
def __init__(
self,
field: str,
*,
type: Optional[str] = None,
value: Optional[float] = None,
) -> None:
"""
Initialize a QueryAggregationQueryCalculationAggregation object.
:param str field: The field to perform the calculation on.
:param str type: (optional) Specifies the calculation type, such as
'average`, `max`, `min`, `sum`, or `unique_count`.
:param float value: (optional) The value of the calculation.
"""
# pylint: disable=super-init-not-called
self.type = type
self.field = field
self.value = value
@classmethod
def from_dict(cls,
_dict: Dict) -> 'QueryAggregationQueryCalculationAggregation':
"""Initialize a QueryAggregationQueryCalculationAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (field := _dict.get('field')) is not None:
args['field'] = field
else:
raise ValueError(
'Required property \'field\' not present in QueryAggregationQueryCalculationAggregation JSON'
)
if (value := _dict.get('value')) is not None:
args['value'] = value
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryCalculationAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
if hasattr(self, 'value') and self.value is not None:
_dict['value'] = self.value
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryCalculationAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self,
other: 'QueryAggregationQueryCalculationAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self,
other: 'QueryAggregationQueryCalculationAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryFilterAggregation(QueryAggregation):
"""
A modifier that narrows the document set of the subaggregations it precedes.
:param str type: (optional) Specifies that the aggregation type is `filter`.
:param str match: The filter that is written in Discovery Query Language syntax
and is applied to the documents before subaggregations are run.
:param int matching_results: Number of documents that match the filter.
:param List[dict] aggregations: (optional) An array of subaggregations.
"""
def __init__(
self,
match: str,
matching_results: int,
*,
type: Optional[str] = None,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryAggregationQueryFilterAggregation object.
:param str match: The filter that is written in Discovery Query Language
syntax and is applied to the documents before subaggregations are run.
:param int matching_results: Number of documents that match the filter.
:param str type: (optional) Specifies that the aggregation type is
`filter`.
:param List[dict] aggregations: (optional) An array of subaggregations.
"""
# pylint: disable=super-init-not-called
self.type = type
self.match = match
self.matching_results = matching_results
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregationQueryFilterAggregation':
"""Initialize a QueryAggregationQueryFilterAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (match := _dict.get('match')) is not None:
args['match'] = match
else:
raise ValueError(
'Required property \'match\' not present in QueryAggregationQueryFilterAggregation JSON'
)
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryAggregationQueryFilterAggregation JSON'
)
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryFilterAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'match') and self.match is not None:
_dict['match'] = self.match
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryFilterAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryFilterAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryFilterAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryGroupByAggregation(QueryAggregation):
"""
Separates document results into groups that meet the conditions you specify.
:param str type: (optional) Specifies that the aggregation type is `group_by`.
:param List[QueryGroupByAggregationResult] results: (optional) An array of
results.
"""
def __init__(
self,
*,
type: Optional[str] = None,
results: Optional[List['QueryGroupByAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryGroupByAggregation object.
:param str type: (optional) Specifies that the aggregation type is
`group_by`.
:param List[QueryGroupByAggregationResult] results: (optional) An array of
results.
"""
# pylint: disable=super-init-not-called
self.type = type
self.results = results
@classmethod
def from_dict(cls,
_dict: Dict) -> 'QueryAggregationQueryGroupByAggregation':
"""Initialize a QueryAggregationQueryGroupByAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryGroupByAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryGroupByAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryGroupByAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryGroupByAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryGroupByAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryHistogramAggregation(QueryAggregation):
"""
Numeric interval segments to categorize documents by using field values from a single
numeric field to describe the category.
:param str type: (optional) Specifies that the aggregation type is `histogram`.
:param str field: The numeric field name used to create the histogram.
:param int interval: The size of the sections that the results are split into.
:param str name: (optional) Identifier that can optionally be specified in the
query request of this aggregation.
:param List[QueryHistogramAggregationResult] results: (optional) Array of
numeric intervals.
"""
def __init__(
self,
field: str,
interval: int,
*,
type: Optional[str] = None,
name: Optional[str] = None,
results: Optional[List['QueryHistogramAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryHistogramAggregation object.
:param str field: The numeric field name used to create the histogram.
:param int interval: The size of the sections that the results are split
into.
:param str type: (optional) Specifies that the aggregation type is
`histogram`.
:param str name: (optional) Identifier that can optionally be specified in
the query request of this aggregation.
:param List[QueryHistogramAggregationResult] results: (optional) Array of
numeric intervals.
"""
# pylint: disable=super-init-not-called
self.type = type
self.field = field
self.interval = interval
self.name = name
self.results = results
@classmethod
def from_dict(cls,
_dict: Dict) -> 'QueryAggregationQueryHistogramAggregation':
"""Initialize a QueryAggregationQueryHistogramAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (field := _dict.get('field')) is not None:
args['field'] = field
else:
raise ValueError(
'Required property \'field\' not present in QueryAggregationQueryHistogramAggregation JSON'
)
if (interval := _dict.get('interval')) is not None:
args['interval'] = interval
else:
raise ValueError(
'Required property \'interval\' not present in QueryAggregationQueryHistogramAggregation JSON'
)
if (name := _dict.get('name')) is not None:
args['name'] = name
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryHistogramAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryHistogramAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
if hasattr(self, 'interval') and self.interval is not None:
_dict['interval'] = self.interval
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryHistogramAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self,
other: 'QueryAggregationQueryHistogramAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self,
other: 'QueryAggregationQueryHistogramAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryNestedAggregation(QueryAggregation):
"""
A restriction that alters the document set that is used by the aggregations that it
precedes. Subsequent aggregations are applied to nested documents from the specified
field.
:param str type: (optional) Specifies that the aggregation type is `nested`.
:param str path: The path to the document field to scope subsequent aggregations
to.
:param int matching_results: Number of nested documents found in the specified
field.
:param List[dict] aggregations: (optional) An array of subaggregations.
"""
def __init__(
self,
path: str,
matching_results: int,
*,
type: Optional[str] = None,
aggregations: Optional[List[dict]] = None,
) -> None:
"""
Initialize a QueryAggregationQueryNestedAggregation object.
:param str path: The path to the document field to scope subsequent
aggregations to.
:param int matching_results: Number of nested documents found in the
specified field.
:param str type: (optional) Specifies that the aggregation type is
`nested`.
:param List[dict] aggregations: (optional) An array of subaggregations.
"""
# pylint: disable=super-init-not-called
self.type = type
self.path = path
self.matching_results = matching_results
self.aggregations = aggregations
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregationQueryNestedAggregation':
"""Initialize a QueryAggregationQueryNestedAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (path := _dict.get('path')) is not None:
args['path'] = path
else:
raise ValueError(
'Required property \'path\' not present in QueryAggregationQueryNestedAggregation JSON'
)
if (matching_results := _dict.get('matching_results')) is not None:
args['matching_results'] = matching_results
else:
raise ValueError(
'Required property \'matching_results\' not present in QueryAggregationQueryNestedAggregation JSON'
)
if (aggregations := _dict.get('aggregations')) is not None:
args['aggregations'] = aggregations
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryNestedAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'path') and self.path is not None:
_dict['path'] = self.path
if hasattr(self,
'matching_results') and self.matching_results is not None:
_dict['matching_results'] = self.matching_results
if hasattr(self, 'aggregations') and self.aggregations is not None:
_dict['aggregations'] = self.aggregations
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryNestedAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryNestedAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryNestedAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryPairAggregation(QueryAggregation):
"""
Calculates relevancy values using combinations of document sets from results of the
specified pair of aggregations.
:param str type: (optional) Specifies that the aggregation type is `pair`.
:param str first: (optional) Specifies the first aggregation in the pair. The
aggregation must be a `term`, `group_by`, `histogram`, or `timeslice`
aggregation type.
:param str second: (optional) Specifies the second aggregation in the pair. The
aggregation must be a `term`, `group_by`, `histogram`, or `timeslice`
aggregation type.
:param bool show_estimated_matching_results: (optional) Indicates whether to
include estimated matching result information.
:param bool show_total_matching_documents: (optional) Indicates whether to
include total matching documents information.
:param List[QueryPairAggregationResult] results: (optional) An array of
aggregations.
"""
def __init__(
self,
*,
type: Optional[str] = None,
first: Optional[str] = None,
second: Optional[str] = None,
show_estimated_matching_results: Optional[bool] = None,
show_total_matching_documents: Optional[bool] = None,
results: Optional[List['QueryPairAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryPairAggregation object.
:param str type: (optional) Specifies that the aggregation type is `pair`.
:param str first: (optional) Specifies the first aggregation in the pair.
The aggregation must be a `term`, `group_by`, `histogram`, or `timeslice`
aggregation type.
:param str second: (optional) Specifies the second aggregation in the pair.
The aggregation must be a `term`, `group_by`, `histogram`, or `timeslice`
aggregation type.
:param bool show_estimated_matching_results: (optional) Indicates whether
to include estimated matching result information.
:param bool show_total_matching_documents: (optional) Indicates whether to
include total matching documents information.
:param List[QueryPairAggregationResult] results: (optional) An array of
aggregations.
"""
# pylint: disable=super-init-not-called
self.type = type
self.first = first
self.second = second
self.show_estimated_matching_results = show_estimated_matching_results
self.show_total_matching_documents = show_total_matching_documents
self.results = results
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregationQueryPairAggregation':
"""Initialize a QueryAggregationQueryPairAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (first := _dict.get('first')) is not None:
args['first'] = first
if (second := _dict.get('second')) is not None:
args['second'] = second
if (show_estimated_matching_results :=
_dict.get('show_estimated_matching_results')) is not None:
args[
'show_estimated_matching_results'] = show_estimated_matching_results
if (show_total_matching_documents :=
_dict.get('show_total_matching_documents')) is not None:
args[
'show_total_matching_documents'] = show_total_matching_documents
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryPairAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryPairAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'first') and self.first is not None:
_dict['first'] = self.first
if hasattr(self, 'second') and self.second is not None:
_dict['second'] = self.second
if hasattr(self, 'show_estimated_matching_results'
) and self.show_estimated_matching_results is not None:
_dict[
'show_estimated_matching_results'] = self.show_estimated_matching_results
if hasattr(self, 'show_total_matching_documents'
) and self.show_total_matching_documents is not None:
_dict[
'show_total_matching_documents'] = self.show_total_matching_documents
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryPairAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryPairAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryPairAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryTermAggregation(QueryAggregation):
"""
Returns results from the field that is specified.
:param str type: (optional) Specifies that the aggregation type is `term`.
:param str field: (optional) The field in the document where the values come
from.
:param int count: (optional) The number of results returned. Not returned if
`relevancy:true` is specified in the request.
:param str name: (optional) Identifier specified in the query request of this
aggregation. Not returned if `relevancy:true` is specified in the request.
:param List[QueryTermAggregationResult] results: (optional) An array of results.
"""
def __init__(
self,
*,
type: Optional[str] = None,
field: Optional[str] = None,
count: Optional[int] = None,
name: Optional[str] = None,
results: Optional[List['QueryTermAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryTermAggregation object.
:param str type: (optional) Specifies that the aggregation type is `term`.
:param str field: (optional) The field in the document where the values
come from.
:param int count: (optional) The number of results returned. Not returned
if `relevancy:true` is specified in the request.
:param str name: (optional) Identifier specified in the query request of
this aggregation. Not returned if `relevancy:true` is specified in the
request.
:param List[QueryTermAggregationResult] results: (optional) An array of
results.
"""
# pylint: disable=super-init-not-called
self.type = type
self.field = field
self.count = count
self.name = name
self.results = results
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregationQueryTermAggregation':
"""Initialize a QueryAggregationQueryTermAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (field := _dict.get('field')) is not None:
args['field'] = field
if (count := _dict.get('count')) is not None:
args['count'] = count
if (name := _dict.get('name')) is not None:
args['name'] = name
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryTermAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryTermAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
if hasattr(self, 'count') and self.count is not None:
_dict['count'] = self.count
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryTermAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryTermAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryTermAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryTimesliceAggregation(QueryAggregation):
"""
A specialized histogram aggregation that uses dates to create interval segments.
:param str type: (optional) Specifies that the aggregation type is `timeslice`.
:param str field: The date field name used to create the timeslice.
:param str interval: The date interval value. Valid values are seconds, minutes,
hours, days, weeks, and years.
:param str name: (optional) Identifier that can optionally be specified in the
query request of this aggregation.
:param List[QueryTimesliceAggregationResult] results: (optional) Array of
aggregation results.
"""
def __init__(
self,
field: str,
interval: str,
*,
type: Optional[str] = None,
name: Optional[str] = None,
results: Optional[List['QueryTimesliceAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryTimesliceAggregation object.
:param str field: The date field name used to create the timeslice.
:param str interval: The date interval value. Valid values are seconds,
minutes, hours, days, weeks, and years.
:param str type: (optional) Specifies that the aggregation type is
`timeslice`.
:param str name: (optional) Identifier that can optionally be specified in
the query request of this aggregation.
:param List[QueryTimesliceAggregationResult] results: (optional) Array of
aggregation results.
"""
# pylint: disable=super-init-not-called
self.type = type
self.field = field
self.interval = interval
self.name = name
self.results = results
@classmethod
def from_dict(cls,
_dict: Dict) -> 'QueryAggregationQueryTimesliceAggregation':
"""Initialize a QueryAggregationQueryTimesliceAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (field := _dict.get('field')) is not None:
args['field'] = field
else:
raise ValueError(
'Required property \'field\' not present in QueryAggregationQueryTimesliceAggregation JSON'
)
if (interval := _dict.get('interval')) is not None:
args['interval'] = interval
else:
raise ValueError(
'Required property \'interval\' not present in QueryAggregationQueryTimesliceAggregation JSON'
)
if (name := _dict.get('name')) is not None:
args['name'] = name
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryTimesliceAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryTimesliceAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'field') and self.field is not None:
_dict['field'] = self.field
if hasattr(self, 'interval') and self.interval is not None:
_dict['interval'] = self.interval
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryTimesliceAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self,
other: 'QueryAggregationQueryTimesliceAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self,
other: 'QueryAggregationQueryTimesliceAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryTopHitsAggregation(QueryAggregation):
"""
Returns the top documents ranked by the score of the query.
:param str type: (optional) Specifies that the aggregation type is `top_hits`.
:param int size: The number of documents to return.
:param str name: (optional) Identifier specified in the query request of this
aggregation.
:param QueryTopHitsAggregationResult hits: (optional) A query response that
contains the matching documents for the preceding aggregations.
"""
def __init__(
self,
size: int,
*,
type: Optional[str] = None,
name: Optional[str] = None,
hits: Optional['QueryTopHitsAggregationResult'] = None,
) -> None:
"""
Initialize a QueryAggregationQueryTopHitsAggregation object.
:param int size: The number of documents to return.
:param str type: (optional) Specifies that the aggregation type is
`top_hits`.
:param str name: (optional) Identifier specified in the query request of
this aggregation.
:param QueryTopHitsAggregationResult hits: (optional) A query response that
contains the matching documents for the preceding aggregations.
"""
# pylint: disable=super-init-not-called
self.type = type
self.size = size
self.name = name
self.hits = hits
@classmethod
def from_dict(cls,
_dict: Dict) -> 'QueryAggregationQueryTopHitsAggregation':
"""Initialize a QueryAggregationQueryTopHitsAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (size := _dict.get('size')) is not None:
args['size'] = size
else:
raise ValueError(
'Required property \'size\' not present in QueryAggregationQueryTopHitsAggregation JSON'
)
if (name := _dict.get('name')) is not None:
args['name'] = name
if (hits := _dict.get('hits')) is not None:
args['hits'] = QueryTopHitsAggregationResult.from_dict(hits)
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryTopHitsAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'size') and self.size is not None:
_dict['size'] = self.size
if hasattr(self, 'name') and self.name is not None:
_dict['name'] = self.name
if hasattr(self, 'hits') and self.hits is not None:
if isinstance(self.hits, dict):
_dict['hits'] = self.hits
else:
_dict['hits'] = self.hits.to_dict()
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryTopHitsAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryTopHitsAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryTopHitsAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryTopicAggregation(QueryAggregation):
"""
Detects how much the frequency of a given facet value deviates from the expected
average for the given time period. This aggregation type does not use data from
previous time periods. It calculates an index by using the averages of frequency
counts of other facet values for the given time period.
:param str type: (optional) Specifies that the aggregation type is `topic`.
:param str facet: (optional) Specifies the `term` or `group_by` aggregation for
the facet that you want to analyze.
:param str time_segments: (optional) Specifies the `timeslice` aggregation that
defines the time segments.
:param bool show_estimated_matching_results: (optional) Indicates whether to
include estimated matching result information.
:param bool show_total_matching_documents: (optional) Indicates whether to
include total matching documents information.
:param List[QueryTopicAggregationResult] results: (optional) An array of
aggregations.
"""
def __init__(
self,
*,
type: Optional[str] = None,
facet: Optional[str] = None,
time_segments: Optional[str] = None,
show_estimated_matching_results: Optional[bool] = None,
show_total_matching_documents: Optional[bool] = None,
results: Optional[List['QueryTopicAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryTopicAggregation object.
:param str type: (optional) Specifies that the aggregation type is `topic`.
:param str facet: (optional) Specifies the `term` or `group_by` aggregation
for the facet that you want to analyze.
:param str time_segments: (optional) Specifies the `timeslice` aggregation
that defines the time segments.
:param bool show_estimated_matching_results: (optional) Indicates whether
to include estimated matching result information.
:param bool show_total_matching_documents: (optional) Indicates whether to
include total matching documents information.
:param List[QueryTopicAggregationResult] results: (optional) An array of
aggregations.
"""
# pylint: disable=super-init-not-called
self.type = type
self.facet = facet
self.time_segments = time_segments
self.show_estimated_matching_results = show_estimated_matching_results
self.show_total_matching_documents = show_total_matching_documents
self.results = results
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregationQueryTopicAggregation':
"""Initialize a QueryAggregationQueryTopicAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (facet := _dict.get('facet')) is not None:
args['facet'] = facet
if (time_segments := _dict.get('time_segments')) is not None:
args['time_segments'] = time_segments
if (show_estimated_matching_results :=
_dict.get('show_estimated_matching_results')) is not None:
args[
'show_estimated_matching_results'] = show_estimated_matching_results
if (show_total_matching_documents :=
_dict.get('show_total_matching_documents')) is not None:
args[
'show_total_matching_documents'] = show_total_matching_documents
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryTopicAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryTopicAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'facet') and self.facet is not None:
_dict['facet'] = self.facet
if hasattr(self, 'time_segments') and self.time_segments is not None:
_dict['time_segments'] = self.time_segments
if hasattr(self, 'show_estimated_matching_results'
) and self.show_estimated_matching_results is not None:
_dict[
'show_estimated_matching_results'] = self.show_estimated_matching_results
if hasattr(self, 'show_total_matching_documents'
) and self.show_total_matching_documents is not None:
_dict[
'show_total_matching_documents'] = self.show_total_matching_documents
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryTopicAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryTopicAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryTopicAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
class QueryAggregationQueryTrendAggregation(QueryAggregation):
"""
Detects sharp and unexpected changes in the frequency of a facet or facet value over
time based on the past history of frequency changes of the facet value.
:param str type: (optional) Specifies that the aggregation type is `trend`.
:param str facet: (optional) Specifies the `term` or `group_by` aggregation for
the facet that you want to analyze.
:param str time_segments: (optional) Specifies the `timeslice` aggregation that
defines the time segments.
:param bool show_estimated_matching_results: (optional) Indicates whether to
include estimated matching result information.
:param bool show_total_matching_documents: (optional) Indicates whether to
include total matching documents information.
:param List[QueryTrendAggregationResult] results: (optional) An array of
aggregations.
"""
def __init__(
self,
*,
type: Optional[str] = None,
facet: Optional[str] = None,
time_segments: Optional[str] = None,
show_estimated_matching_results: Optional[bool] = None,
show_total_matching_documents: Optional[bool] = None,
results: Optional[List['QueryTrendAggregationResult']] = None,
) -> None:
"""
Initialize a QueryAggregationQueryTrendAggregation object.
:param str type: (optional) Specifies that the aggregation type is `trend`.
:param str facet: (optional) Specifies the `term` or `group_by` aggregation
for the facet that you want to analyze.
:param str time_segments: (optional) Specifies the `timeslice` aggregation
that defines the time segments.
:param bool show_estimated_matching_results: (optional) Indicates whether
to include estimated matching result information.
:param bool show_total_matching_documents: (optional) Indicates whether to
include total matching documents information.
:param List[QueryTrendAggregationResult] results: (optional) An array of
aggregations.
"""
# pylint: disable=super-init-not-called
self.type = type
self.facet = facet
self.time_segments = time_segments
self.show_estimated_matching_results = show_estimated_matching_results
self.show_total_matching_documents = show_total_matching_documents
self.results = results
@classmethod
def from_dict(cls, _dict: Dict) -> 'QueryAggregationQueryTrendAggregation':
"""Initialize a QueryAggregationQueryTrendAggregation object from a json dictionary."""
args = {}
if (type := _dict.get('type')) is not None:
args['type'] = type
if (facet := _dict.get('facet')) is not None:
args['facet'] = facet
if (time_segments := _dict.get('time_segments')) is not None:
args['time_segments'] = time_segments
if (show_estimated_matching_results :=
_dict.get('show_estimated_matching_results')) is not None:
args[
'show_estimated_matching_results'] = show_estimated_matching_results
if (show_total_matching_documents :=
_dict.get('show_total_matching_documents')) is not None:
args[
'show_total_matching_documents'] = show_total_matching_documents
if (results := _dict.get('results')) is not None:
args['results'] = [
QueryTrendAggregationResult.from_dict(v) for v in results
]
return cls(**args)
@classmethod
def _from_dict(cls, _dict):
"""Initialize a QueryAggregationQueryTrendAggregation object from a json dictionary."""
return cls.from_dict(_dict)
def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'type') and self.type is not None:
_dict['type'] = self.type
if hasattr(self, 'facet') and self.facet is not None:
_dict['facet'] = self.facet
if hasattr(self, 'time_segments') and self.time_segments is not None:
_dict['time_segments'] = self.time_segments
if hasattr(self, 'show_estimated_matching_results'
) and self.show_estimated_matching_results is not None:
_dict[
'show_estimated_matching_results'] = self.show_estimated_matching_results
if hasattr(self, 'show_total_matching_documents'
) and self.show_total_matching_documents is not None:
_dict[
'show_total_matching_documents'] = self.show_total_matching_documents
if hasattr(self, 'results') and self.results is not None:
results_list = []
for v in self.results:
if isinstance(v, dict):
results_list.append(v)
else:
results_list.append(v.to_dict())
_dict['results'] = results_list
return _dict
def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()
def __str__(self) -> str:
"""Return a `str` version of this QueryAggregationQueryTrendAggregation object."""
return json.dumps(self.to_dict(), indent=2)
def __eq__(self, other: 'QueryAggregationQueryTrendAggregation') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other: 'QueryAggregationQueryTrendAggregation') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other
|