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
|
// File: classhfst_1_1AttReader.xml
%feature("docstring") hfst::AttReader
"""
A class for reading input in AT&T text format and converting it into
transducer(s).
An example that reads AT&T input from file 'testfile.att' where epsilon is
represented as \"<eps>\" and creates the corresponding transducers and prints
them. If the input cannot be parsed, a message showing the invalid line in AT&T
input is printed and reading is stopped.
with open('testfile.att', 'r') as f:
try:
r = hfst.AttReader(f, \"<eps>\")
for tr in r:
print(tr)
except hfst.exceptions.NotValidAttFormatException as e:
print(e.what())
"""
%feature("docstring") hfst::AttReader::__init__
"""
Create an AttReader that reads input from file *f* where the epsilon is
represented as *epsilonstr*.
Parameters
----------
* `f` :
A python file.
* `epsilonstr` :
How epsilon is represented in the file. By default, \"@_EPSILON_SYMBOL_@\"
and \"@0@\" are both recognized.
"""
%feature("docstring") hfst::AttReader::__next__
"""
Return next element (for python version 3).
Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Exceptions
----------
* `StopIteration` :
"""
%feature("docstring") hfst::AttReader::read
"""
Read next transducer.
Read next transducer description in AT&T format and return a corresponding
transducer.
Exceptions
----------
* `hfst.exceptions.NotValidAttFormatException` :
* `hfst.exceptions.EndOfStreamException` :
"""
%feature("docstring") hfst::AttReader::__iter__
"""
An iterator to the reader.
Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
"""
%feature("docstring") hfst::AttReader::next
"""
Return next element (for python version 2).
Needed for 'for ... in' statement.
for transducer in att_reader:
print(transducer)
Exceptions
----------
* `StopIteration` :
"""
// File: classhfst_1_1HfstBasicTransducer.xml
%feature("docstring") hfst::implementations::HfstBasicTransducer
"""
A simple transducer class with tropical weights.
An example of creating an HfstBasicTransducer [foo:bar baz:baz] with weight 0.4
from scratch:
# Create an empty transducer
# The transducer has initially one start state (number zero)
# that is not final
fsm = hfst.HfstBasicTransducer()
# Add two states to the transducer
fsm.add_state(1)
fsm.add_state(2)
# Create a transition [foo:bar] leading to state 1 with weight 0.1
tr = hfst.HfstBasicTransition(1, 'foo', 'bar', 0.1)
# and add it to state zero
fsm.add_transition(0, tr)
# Add a transition [baz:baz] with weight 0 from state 1 to state 2
fsm.add_transition(1, hfst.HfstBasicTransition(2, 'baz', 'baz', 0.0))
# Set state 2 as final with weight 0.3
fsm.set_final_weight(2, 0.3)
An example of iterating through the states and transitions of the above
transducer when printing them in AT&T format to standard output:
# Go through all states
for state, arcs in enumerate(fsm):
for arc in arcs:
print('%i ' % (state), end='')
print(arc)
if fsm.is_final_state(state):
print('%i %f' % (state, fsm.get_final_weight(state)) )
See also: hfst.HfstBasicTransition
"""
%feature("docstring") hfst::HfstBasicTransducer::states_and_transitions
"""
The states and transitions of the transducer.
Returns
-------
A tuple of tuples of HfstBasicTransitions.
See also: hfst.HfstBasicTransducer.__enumerate__
"""
%feature("docstring") hfst::HfstBasicTransducer::get_final_weight
"""
Get the final weight of state *state* in this transducer.
Parameters
----------
* `state` :
The number of the state. If it does not exist, a StateIsNotFinalException is
thrown.
Exceptions
----------
* `hfst.exceptions.StateIsNotFinalException.` :
"""
%feature("docstring") hfst::HfstBasicTransducer::__init__
"""
Create a transducer with one initial state that has state number zero and is not
a final state, i.e.
create an empty transducer.
tr = hfst.HfstBasicTransducer()
"""
%feature("docstring") hfst::HfstBasicTransducer::__init__
"""
Create a transducer equivalent to *transducer*.
Parameters
----------
* `transducer` :
The transducer to be copied, hfst.HfstBasicTransducer or
hfst.HfstTransducer.
tr = hfst.regex('foo') # creates an HfstTransducer
TR = hfst.HfstBasicTransducer(tr)
TR2 = hfst.HfstBasicTransducer(TR)
"""
%feature("docstring") hfst::HfstBasicTransducer::symbols_used
"""
Get a list of all symbols used in the transitions of this transducer.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_symbol_from_alphabet
"""
Remove symbol *symbol* from the alphabet of the graph.
note: Use with care, removing symbols that occur in the transitions of the graph
can have unexpected results.
Parameters
----------
* `symbol` :
The string to be removed.
"""
%feature("docstring") hfst::HfstBasicTransducer::get_transition_pairs
"""
Get a list of all input/output symbol pairs used in the transitions of this
transducer.
"""
%feature("docstring") hfst::HfstBasicTransducer::is_infinitely_ambiguous
"""
Whether the transducer is infinitely ambiguous.
A transducer is infinitely ambiguous if there exists an input that will yield
infinitely many results, i.e. there are input epsilon loops that are traversed
with that input.
"""
%feature("docstring") hfst::HfstBasicTransducer::harmonize
"""
Harmonize this transducer and *another*.
In harmonization the unknown and identity symbols in transitions of both graphs
are expanded according to the symbols that are previously unknown to the graph.
For example the graphs
[a:b ?:?]
[c:d ? ?:c] are expanded to
[ a:b [?:? | ?:c | ?:d | c:d | d:c | c:? | d:?] ]
[ c:d [? | a | b] [?:c| a:c | b:?] ] when harmonized.
The symbol '?' means hfst.UNKNOWN in either or both sides of a transition
(transitions of type [?:x], [x:?] and [?:?]). The transition [?] means
hfst.IDENTITY.
note: This function is always called for all transducer arguments of functions
that take two or more graphs as their arguments, unless otherwise said.
"""
%feature("docstring") hfst::HfstBasicTransducer::sort_arcs
"""
Sort the arcs of this transducer according to input and output symbols.
Returns
-------
This transducer.
"""
%feature("docstring") hfst::HfstBasicTransducer::states
"""
The states of the transducer.
Returns
-------
A tuple of state numbers.
An example: /verbatim for state in fsm.states(): for arc in
fsm.transitions(state): print('i ' % (state), end='') print(arc) if
fsm.is_final_state(state): print('i f' % (state, fsm.get_final_weight(state)) )
/endverbatim
"""
%feature("docstring") hfst::HfstBasicTransducer::get_max_state
"""
Get the biggest state number in use.
Returns
-------
The biggest state number in use.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_state
"""
Add a new state to this transducer and return its number.
Returns
-------
The next (smallest) free state number.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_state
"""
Add a state *s* to this graph.
Parameters
----------
* `state` :
The number of the state to be added.
Returns
-------
*state*
If the state already exists, it is not added again. All states with state number
smaller than *s* are also added to the transducer if they did not exist before.
"""
%feature("docstring") hfst::HfstBasicTransducer::write_att
"""
Write this transducer in AT&T format to file *f*, *write_weights* defines
whether weights are written.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_symbols_from_alphabet
"""
Remove symbols *symbols* from the alphabet of the graph.
note: Use with care, removing symbols that occur in the transitions of the graph
can have unexpected results.
Parameters
----------
* `symbols` :
A tuple of strings to be removed.
"""
%feature("docstring") hfst::HfstBasicTransducer::__enumerate__
"""
Return an enumeration of the states and transitions of the transducer.
for state, arcs in enumerate(fsm):
for arc in arcs:
print('%i ' % (state), end='')
print(arc)
if fsm.is_final_state(state):
print('%i %f' % (state, fsm.get_final_weight(state)) )
"""
%feature("docstring") hfst::HfstBasicTransducer::longest_path_size
"""
The length of the longest path in transducer.
Length of a path means number of arcs on that path.
"""
%feature("docstring") hfst::HfstBasicTransducer::get_alphabet
"""
The symbols in the alphabet of the transducer.
The symbols do not necessarily occur in any transitions of the transducer.
Epsilon, unknown and identity symbols are always included in the alphabet.
Returns
-------
A tuple of strings.
"""
%feature("docstring") hfst::HfstBasicTransducer::substitute
"""
Substitute symbols or transitions in the transducer.
Parameters
----------
* `s` :
The symbol or transition to be substituted. Can also be a dictionary of
substitutions, if S == None.
* `S` :
The symbol, transition, a tuple of transitions or a transducer
(hfst.HfstBasicTransducer) that substitutes *s*.
* `kwargs` :
Arguments recognized are 'input' and 'output', their values can be False or
True, True being the default. These arguments are valid only if *s* and *S*
are strings, else they are ignored.
* `input` :
Whether substitution is performed on input side, defaults to True. Valid
only if *s* and *S* are strings.
* `output` :
Whether substitution is performed on output side, defaults to True. Valid
only if *s* and *S* are strings.
Possible combinations of arguments and their types are:
(1) substitute(str, str, input=bool, output=bool): substitute symbol with symbol
on input, output or both sides of each transition in the transducer. (2)
substitute(strpair, strpair): substitute transition with transition (3)
substitute(strpair, strpairtuple): substitute transition with several
transitions (4) substitute(strpair, transducer): substitute transition with a
transducer (5) substitute(dict): perform several symbol-to-symbol substitutions
(6) substitute(dict): perform several transition-to-transition substitutions
Examples:
(1) tr.substitute('a', 'A', input=True, output=False): substitute lowercase a:s
with uppercase ones (2) tr.substitute(('a','b'),('A','B')): substitute
transitions that map lowercase a into lowercase b with transitions that map
uppercase a into uppercase b (3) tr.substitute(('a','b'),
(('A','B'),('a','B'),('A','b'))): change either or both sides of a transition
[a:b] to uppercase (4) tr.substitute(('a','b'), hfst.regex('[a:b]+')) change
[a:b] transition into one or more consecutive [a:b] transitions (5)
tr.substitute({'a':'A', 'b':'B', 'c':'C'}) change lowercase a, b and c into
their uppercase variants (6) tr.substitute( {('a','a'):('A','A'),
('b','b'):('B','B'), ('c','c'):('C','C')} ): change lowercase a, b and c into
their uppercase variants
In case (4), epsilon transitions are used to attach copies of transducer *S*
between the SOURCE and TARGET state of each transition that is substituted. The
transition itself is deleted, but its weight is copied to the epsilon transition
leading from SOURCE to the initial state of *S*. Each final state of *S* is made
non-final and an epsilon transition leading to TARGET is attached to it. The
final weight is copied to the epsilon transition.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_transition
"""
Remove all transitions equivalent to *transition* from state *s*.
Parameters
----------
* `s` :
The state which *transition* belongs to.
* `transition` :
A transition which is compared with all transitions of state *s*, ignoring
the weights. It a transition is equivalent to *transition*, it is removed
from the transducer.
* `remove_symbols_from_alphabet` :
Remove such symbols from transducer alphabet that no longer occur in its
transitions (as a result of transition removal). Defaults to False.
Note: Removing transitions during iteration (e.g. with 'transitions') will
invalidate the iteration. Iteration of states (e.g. with 'states') is possible.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_transition
"""
Add a transition *transition* to state *state*, *add_symbols_to_alphabet*
defines whether the transition symbols are added to the alphabet.
Parameters
----------
* `state` :
The number of the state where the transition is added. If it does not exist,
it is created.
* `transition` :
A hfst.HfstBasicTransition that is added to *state*.
* `add_symbols_to_alphabet` :
Whether the transition symbols are added to the alphabet of the transducer.
(In special cases this is not wanted.)
Note: Adding transitions during iteration (e.g. with 'transitions') will
invalidate the iteration. Iteration of states (e.g. with 'states') is possible.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_transition
"""
Add a transition from state *source* to state *target* with input symbol
*input*, output symbol *output* and weight *weight*.
Parameters
----------
* `source` :
The number of the state where the transition is added. If it does not exist,
it is created.
* `target` :
The number of the state where the transition leads. If it does not exist, it
is created.
* `input` :
The input symbol of the transition.
* `output` :
The output symbol of the transition.
* `weight` :
The weight of the transition.
Note: Adding transitions during iteration (e.g. with 'transitions') will
invalidate the iteration. Iteration of states (e.g. with 'states') is possible.
"""
%feature("docstring") hfst::HfstBasicTransducer::read_prolog
"""
Read a transducer from prolog file *f*.
*linecount* is incremented as lines are read (is it in python?).
Returns
-------
A transducer constructed by reading from file *file*. This function is a static
one.
"""
%feature("docstring") hfst::HfstBasicTransducer::lookup_fd
"""
Lookup tokenized input *input* in the transducer minding flag diacritics.
Parameters
----------
* `str` :
A list/tuple of strings to look up.
* `kwargs` :
infinite_cutoff=-1, max_weight=None
* `infinite_cutoff` :
Defaults to -1, i.e. infinite.
* `max_weight` :
Defaults to None, i.e. infinity.
"""
%feature("docstring") hfst::HfstBasicTransducer::prune_alphabet
"""
Remove all symbols that do not occur in transitions of the transducer from its
alphabet.
Epsilon, unknown and identity symbols are always included in the alphabet.
"""
%feature("docstring") hfst::HfstBasicTransducer::write_prolog
"""
Write the transducer in prolog format to file *f*.
Name the transducer *name*.
"""
%feature("docstring") hfst::HfstBasicTransducer::disjunct
"""
Disjunct this transducer with a one-path transducer defined by consecutive
string pairs in *spv* that has weight *weight*.
pre: This graph must be a trie where all weights are in final states, i.e. all
transitions have a zero weight.
There is no way to test whether a graph is a trie, so the use of this function
is probably limited to fast construction of a lexicon. Here is an example:
lexicon = hfst.HfstBasicTransducer()
tok = hfst.HfstTokenizer()
lexicon.disjunct(tok.tokenize('dog'), 0.3)
lexicon.disjunct(tok.tokenize('cat'), 0.5)
lexicon.disjunct(tok.tokenize('elephant'), 1.6)
"""
%feature("docstring") hfst::HfstBasicTransducer::read_att
"""
Read a transducer in AT&T format from file *f*.
*epsilon_symbol* defines the symbol used for epsilon, *linecount* is incremented
as lines are read.
Returns
-------
A transducer constructed by reading from file *file*. This function is a static
one.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_symbol_to_alphabet
"""
Explicitly add *symbol* to the alphabet of the graph.
note: Usually the user does not have to take care of the alphabet of a graph.
This function can be useful in some special cases. @ param symbol The string
to be added.
"""
%feature("docstring") hfst::HfstBasicTransducer::__str__
"""
Return a string representation of the transducer.
print(fsm)
"""
%feature("docstring") hfst::HfstBasicTransducer::set_final_weight
"""
Set the final weight of state *state* in this transducer to *weight*.
If the state does not exist, it is created.
"""
%feature("docstring") hfst::HfstBasicTransducer::remove_final_weight
"""
Remove the final weight of state *state* in this transducer, i.e. make the state non-final.
"""
%feature("docstring") hfst::HfstBasicTransducer::add_symbols_to_alphabet
"""
Explicitly add *symbols* to the alphabet of the graph.
note: Usually the user does not have to take care of the alphabet of a graph.
This function can be useful in some special cases.
Parameters
----------
* `symbols` :
A tuple of strings to be added.
"""
%feature("docstring") hfst::HfstBasicTransducer::transitions
"""
Get the transitions of state *state* in this transducer.
If the state does not exist, a *StateIndexOutOfBoundsException* is thrown.
Returns
-------
A tuple of HfstBasicTransitions.
for state in fsm.states():
for arc in fsm.transitions(state):
print('%i ' % (state), end='')
print(arc)
if fsm.is_final_state(state):
print('%i %f' % (state, fsm.get_final_weight(state)) )
"""
%feature("docstring") hfst::HfstBasicTransducer::insert_freely
"""
Insert freely any number of *symbol_pair* in the transducer with weight
*weight*.
Parameters
----------
* `symbol_pair` :
A string pair to be inserted.
* `weight` :
The weight of the inserted symbol pair.
"""
%feature("docstring") hfst::HfstBasicTransducer::insert_freely
"""
Insert freely any number of *transducer* in this transducer.
param transducer An HfstBasicTransducer to be inserted.
"""
%feature("docstring") hfst::HfstBasicTransducer::write_xfst
"""
Write the transducer in xfst format to file *f*.
"""
%feature("docstring") hfst::HfstBasicTransducer::is_final_state
"""
Whether state *state* is final.
Parameters
----------
* `state` :
The state whose finality is returned.
"""
%feature("docstring") hfst::HfstBasicTransducer::is_lookup_infinitely_ambiguous
"""
Whether the transducer is infinitely ambiguous with input *str*.
Parameters
----------
* `str` :
The input.
A transducer is infinitely ambiguous with a given input if the input yields
infinitely many results, i.e. there are input epsilon loops that are traversed
with the input.
"""
// File: classhfst_1_1HfstBasicTransition.xml
%feature("docstring") hfst::HfstBasicTransition
"""
A transition class that consists of a target state, input and output symbols and
a a tropical weight.
See also: hfst.HfstBasicTransducer
"""
%feature("docstring") hfst::HfstBasicTransition::get_input_symbol
"""
Get the input symbol of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::get_weight
"""
Get the weight of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::set_weight
"""
Set the weight of the transition.
Parameters
----------
* `weight` :
Weight of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::get_output_symbol
"""
Get the output symbol of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::get_target_state
"""
Get number of the target state of the transition.
"""
%feature("docstring") hfst::HfstBasicTransition::__init__
"""
Create an HfstBasicTransition leading to target state *state* with input symbol
*input*, output symbol *output* and weight *weight*.
Parameters
----------
* `state` :
Number of the target state.
* `input` :
The input string.
* `output` :
The output string.
* `weight` :
The weight.
Exceptions
----------
* `EmptyStringException` :
transition = hfst.HfstBasicTransition(1, 'foo', 'bar', 0.5)
"""
// File: classhfst_1_1HfstInputStream.xml
%feature("docstring") hfst::HfstInputStream
"""
A stream for reading HFST binary transducers.
An example:
istr = hfst.HfstInputStream('testfile1.hfst')
transducers = []
while not (istr.is_eof()):
transducers.append(istr.read())
istr.close()
print(\"Read %i transducers in total.\" % len(transducers))
For documentation on the HFST binary transducer format, see here.
"""
%feature("docstring") hfst::HfstInputStream::is_bad
"""
Whether badbit is set.
"""
%feature("docstring") hfst::HfstInputStream::is_eof
"""
Whether the stream is at end.
"""
%feature("docstring") hfst::HfstInputStream::__init__
"""
Create a stream for reading binary transducers.
Parameters
----------
* `filename` :
The name of the transducer file. If not given, standard input is used.
Exceptions
----------
* `StreamNotReadableException` :
* `NotTransducerStreamException` :
* `EndOfStreamException` :
* `TransducerHeaderException` :
istr_to_stdin = hfst.HfstInputStream()
istr_to_file = hfst.HfstInputStream(filename='transducer.hfst')
"""
%feature("docstring") hfst::HfstInputStream::read
"""
Return next transducer.
Exceptions
----------
* `EndOfStreamException` :
"""
%feature("docstring") hfst::HfstInputStream::close
"""
Close the stream.
If the stream points to standard input, nothing is done.
"""
%feature("docstring") hfst::HfstInputStream::get_type
"""
The type of the first transducer in the stream.
By default, all transducers in a stream have the same type, else a
TransducerTypeMismatchException is thrown when reading the first transducer that
has a different type than the previous ones.
"""
%feature("docstring") hfst::HfstInputStream::is_good
"""
Whether the state of the stream is good for input operations.
"""
// File: classhfst_1_1HfstOutputStream.xml
%feature("docstring") hfst::HfstOutputStream
"""
A stream for writing binary transducers.
An example:
res = ['foo:bar','0','0 - 0','\"?\":?','a* b+']
ostr = hfst.HfstOutputStream(filename='testfile1.hfst')
for re in res:
ostr.write(hfst.regex(re))
ostr.flush()
ostr.close()
For more information on HFST transducer structure, see this page.
"""
%feature("docstring") hfst::HfstOutputStream::close
"""
Close the stream.
If the stream points to standard output, nothing is done.
"""
%feature("docstring") hfst::HfstOutputStream::__init__
"""
Open a stream for writing binary transducers.
Parameters
----------
* `kwargs` :
Arguments recognized are filename, hfst_format, type.
* `filename` :
The name of the file where transducers are written. If the file exists, it
is overwritten. If *filename* is not given, transducers are written to
standard output.
* `hfst_format` :
Whether transducers are written in hfst format (default is True) or as such
in their backend format.
* `type` :
The type of the transducers that will be written to the stream. Default is
hfst.get_default_fst_type().
ostr = hfst.HfstOutputStream() # a stream for writing default type
transducers in hfst format to standard output
transducer = hfst.regex('foo:bar::0.5')
ostr.write(transducer)
ostr.flush()
ostr = hfst.HfstOutputStream(filename='transducer.sfst', hfst_format=False,
type=hfst.ImplementationType.SFST_TYPE) # a stream for writing SFST_TYPE transducers in
their back-end format to a file
transducer1 = hfst.regex('foo:bar')
transducer1.convert(hfst.ImplementationType.SFST_TYPE) # if not set as the default type
transducer2 = hfst.regex('bar:baz')
transducer2.convert(hfst.ImplementationType.SFST_TYPE) # if not set as the default type
ostr.write(transducer1)
ostr.write(transducer2)
ostr.flush()
ostr.close()
"""
%feature("docstring") hfst::HfstOutputStream::flush
"""
Flush the stream.
"""
%feature("docstring") hfst::HfstOutputStream::write
"""
Write the transducer *transducer* in binary format to the stream.
All transducers must have the same type as the stream, else a
TransducerTypeMismatchException is thrown.
Exceptions
----------
* `hfst.exceptions.TransducerTypeMismatchException` :
"""
// File: classhfst_1_1HfstTransducer.xml
%feature("docstring") hfst::HfstTransducer
"""
A synchronous finite-state transducer.
"""
%feature("docstring") hfst::HfstTransducer::get_type
"""
The implementation type of the transducer.
Returns
-------
hfst.ImplementationType
"""
%feature("docstring") hfst::HfstTransducer::get_name
"""
Get the name of the transducer.
See also: set_name
"""
%feature("docstring") hfst::HfstTransducer::repeat_plus
"""
A concatenation of N transducers where N is any number from one to infinity.
"""
%feature("docstring") hfst::HfstTransducer::output_project
"""
Extract the output language of the transducer.
All transition symbol pairs *isymbol:osymbol* are changed to *osymbol:osymbol*.
"""
%feature("docstring") hfst::HfstTransducer::number_of_states
"""
The number of states in the transducer.
"""
%feature("docstring") hfst::HfstTransducer::minus
"""
Alias for subtract.
See also: hfst.HfstTransducer.subtract
"""
%feature("docstring") hfst::HfstTransducer::is_infinitely_ambiguous
"""
Whether the transducer is infinitely ambiguous.
A transducer is infinitely ambiguous if there exists an input that will yield
infinitely many results, i.e. there are input epsilon loops that are traversed
with that input.
"""
%feature("docstring") hfst::HfstTransducer::eliminate_flags
"""
Eliminate flag diacritics listed in *symbols* from the transducer.
Parameters
----------
* `symbols` :
The flags to be eliminated. TODO: explain more.
An equivalent transducer with no flags listed in *symbols*.
"""
%feature("docstring") hfst::HfstTransducer::longest_path_size
"""
Get length of longest path of the transducer.
"""
%feature("docstring") hfst::HfstTransducer::get_properties
"""
Get all properties from the transducer.
Returns
-------
A dictionary whose keys are properties and whose values are the values of those
properties.
"""
%feature("docstring") hfst::HfstTransducer::optionalize
"""
Disjunct the transducer with an epsilon transducer.
"""
%feature("docstring") hfst::HfstTransducer::intersect
"""
Intersect this transducer with *another*.
"""
%feature("docstring") hfst::HfstTransducer::repeat_n_plus
"""
A concatenation of N transducers where N is any number from *n* to infinity,
inclusive.
"""
%feature("docstring") hfst::HfstTransducer::compare
"""
Whether this transducer and *another* are equivalent.
Parameters
----------
* `another` :
The compared transducer.
pre: *self* and *another* must have the same implementation type.
Two transducers are equivalent iff they accept the same input/output string
pairs with the same weights and the same alignments.
note: For weighted transducers, the function often returns false negatives due
to weight precision issues.
"""
%feature("docstring") hfst::HfstTransducer::remove_from_alphabet
"""
Remove *symbol* from the alphabet of the transducer.
Parameters
----------
* `symbol` :
The symbol (string) to be removed.
pre: *symbol* does not occur in any transition of the transducer.
note: Use with care, removing a symbol that occurs in a transition of the
transducer can have unexpected results.
"""
%feature("docstring") hfst::HfstTransducer::substitute
"""
Substitute symbols or transitions in the transducer.
Parameters
----------
* `s` :
The symbol or transition to be substituted. Can also be a dictionary of
substitutions, if S == None.
* `S` :
The symbol, transition, a tuple of transitions or a transducer
(hfst.HfstTransducer) that substitutes *s*.
* `kwargs` :
Arguments recognized are 'input' and 'output', their values can be False or
True, True being the default. These arguments are valid only if *s* and *S*
are strings, else they are ignored.
* `input` :
Whether substitution is performed on input side, defaults to True. Valid
only if *s* and *S* are strings.
* `output` :
Whether substitution is performed on output side, defaults to True. Valid
only if *s* and \\ S are strings.
For more information, see hfst.HfstBasicTransducer.substitute. The function
works similarly, with the exception of argument *S*, which must be
hfst.HfstTransducer instead of hfst.HfstBasicTransducer.
See also: hfst.HfstBasicTransducer.substitute
"""
%feature("docstring") hfst::HfstTransducer::compose
"""
Compose this transducer with *another*.
Parameters
----------
* `another` :
The second argument in the composition. Not modified.
"""
%feature("docstring") hfst::HfstTransducer::write_prolog
"""
Write the transducer in prolog format with name *name* to file *f*,
*write_weights* defined whether weights are written.
Parameters
----------
* `f` :
A python file where the transducer is written.
* `name` :
The name of the transducer that must be given in a prolog file.
* `write_weights` :
Whether weights are written.
"""
%feature("docstring") hfst::HfstTransducer::repeat_n_to_k
"""
A concatenation of N transducers where N is any number from *n* to *k*,
inclusive.
"""
%feature("docstring") hfst::HfstTransducer::conjunct
"""
Alias for intersect.
See also: hfst.HfstTransducer.intersect
"""
%feature("docstring") hfst::HfstTransducer::repeat_n_minus
"""
A concatenation of N transducers where N is any number from zero to *n*,
inclusive.
"""
%feature("docstring") hfst::HfstTransducer::disjunct
"""
Disjunct this transducer with *another*.
"""
%feature("docstring") hfst::HfstTransducer::lookup_optimize
"""
Optimize the transducer for lookup.
This effectively converts the transducer into hfst.ImplementationType.HFST_OL_TYPE.
"""
%feature("docstring") hfst::HfstTransducer::extract_longest_paths
"""
Extract longest paths of the transducer.
Returns
-------
A dictionary.
"""
%feature("docstring") hfst::HfstTransducer::n_best
"""
Extract *n* best paths of the transducer.
In the case of a weighted transducer (hfst.ImplementationType.TROPICAL_OPENFST_TYPE or
hfst.ImplementationType.LOG_OPENFST_TYPE), best paths are defined as paths with the lowest
weight. In the case of an unweighted transducer (hfst.ImplementationType.SFST_TYPE or
hfst.ImplementationType.FOMA_TYPE), the function returns random paths.
This function is not implemented for hfst.ImplementationType.FOMA_TYPE or
hfst.ImplementationType.SFST_TYPE. If this function is called by an HfstTransducer of type
hfst.ImplementationType.FOMA_TYPE or hfst.ImplementationType.SFST_TYPE, it is converted to
hfst.ImplementationType.TROPICAL_OPENFST_TYPE, paths are extracted and it is converted back
to hfst.ImplementationType.FOMA_TYPE or hfst.ImplementationType.SFST_TYPE. If HFST is not linked to
OpenFst library, an hfst.exceptions.ImplementationTypeNotAvailableException is
thrown.
"""
%feature("docstring") hfst::HfstTransducer::is_implementation_type_available
"""
Whether HFST is linked to the transducer library needed by implementation type
*type*.
"""
%feature("docstring") hfst::HfstTransducer::invert
"""
Swap the input and output symbols of each transition in the transducer.
"""
%feature("docstring") hfst::HfstTransducer::extract_paths
"""
Extract paths that are recognized by the transducer.
Parameters
----------
* `kwargs` :
Arguments recognized are filter_flags, max_cycles, max_number, obey_flags,
output, random.
* `filter_flags` :
Whether flags diacritics are filtered out from the result (default True).
* `max_cycles` :
Indicates how many times a cycle will be followed, with negative numbers
indicating unlimited (default -1 i.e. unlimited).
* `max_number` :
The total number of resulting strings is capped at this value, with 0 or
negative indicating unlimited (default -1 i.e. unlimited).
* `obey_flags` :
Whether flag diacritics are validated (default True).
* `output` :
Output format. Values recognized: 'text', 'raw', 'dict' (the default). 'text'
returns a string where paths are separated by newlines and each path is represented
as input_string + ':' + output_string + '\t' + weight. 'raw' yields a tuple of
all paths where each path is a 2-tuple consisting of a weight and a tuple of
all transition symbol pairs, each symbol pair being a 2-tuple of an input and
an output symbol. 'dict' gives a dictionary that maps each input string into a
list of possible outputs, each output being a 2-tuple of an output string and
a weight.
* `random` :
Whether result strings are fetched randomly (default False).
Returns
-------
The extracted strings. *output* controls how they are represented.
pre: The transducer must be acyclic, if both *max_number* and *max_cycles* have
unlimited values. Else a hfst.exceptions.TransducerIsCyclicException will be
thrown.
An example:
>>> tr = hfst.regex('a:b+ (a:c+)')
>>> print(tr)
0 1 a b 0.000000
1 1 a b 0.000000
1 2 a c 0.000000
1 0.000000
2 2 a c 0.000000
2 0.000000
>>> print(tr.extract_paths(max_cycles=1, output='text'))
a:b 0
aa:bb 0
aaa:bbc 0
aaaa:bbcc 0
aa:bc 0
aaa:bcc 0
>>> print(tr.extract_paths(max_number=4, output='text'))
a:b 0
aa:bc 0
aaa:bcc 0
aaaa:bccc 0
>>> print(tr.extract_paths(max_cycles=1, max_number=4, output='text'))
a:b 0
aa:bb 0
aa:bc 0
aaa:bcc 0
Exceptions
----------
* `TransducerIsCyclicException` :
See also: hfst.HfstTransducer.n_best
note: Special symbols are printed as such.
Todo
a link to flag diacritics
"""
%feature("docstring") hfst::HfstTransducer::__str__
"""
An AT&T representation of the transducer.
Defined for print command. An example:
>>> print(hfst.regex('[foo:bar::2]+'))
0 1 foo bar 2.000000
1 1 foo bar 2.000000
1 0.000000 Todo
Works only for small transducers.
"""
%feature("docstring") hfst::HfstTransducer::is_cyclic
"""
Whether the transducer is cyclic.
"""
%feature("docstring") hfst::HfstTransducer::has_flag_diacritics
"""
Whether the transducer has flag diacritics in its transitions.
"""
%feature("docstring") hfst::HfstTransducer::eliminate_flag
"""
Eliminate flag diacritic *symbol* from the transducer.
Parameters
----------
* `symbol` :
The flag to be eliminated. TODO: explain more.
An equivalent transducer with no flags *symbol*.
"""
%feature("docstring") hfst::HfstTransducer::is_lookup_infinitely_ambiguous
"""
Whether lookup of path *input* will have infinite results.
Currently, this function will return whether the transducer is infinitely
ambiguous on any lookup path found in the transducer, i.e. the argument *input*
is ignored.
Todo
Do not ignore the argument *input*
"""
%feature("docstring") hfst::HfstTransducer::set_name
"""
Rename the transducer *name*.
Parameters
----------
* `name` :
The name of the transducer.
See also: get_name
"""
%feature("docstring") hfst::HfstTransducer::priority_union
"""
Make priority union of this transducer with *another*.
For the operation t1.priority_union(t2), the result is a union of t1 and t2,
except that whenever t1 and t2 have the same string on left side, the path in t2
overrides the path in t1.
Example
Transducer 1 (t1):
a : a
b : b
Transducer 2 (t2):
b : B
c : C
Result ( t1.priority_union(t2) ):
a : a
b : B
c : C For more information, read fsmbook.
"""
%feature("docstring") hfst::HfstTransducer::insert_freely
"""
Freely insert a transition or a transducer into the transducer.
Parameters
----------
* `ins` :
The transition or transducer to be inserted.
If *ins* is a transition, i.e. a 2-tuple of strings: A transition is added to
each state in this transducer. The transition leads from that state to itself
with input and output symbols defined by *ins*. The weight of the transition is
zero.
If *ins* is an hfst.HfstTransducer: A copy of *ins* is attached with epsilon
transitions to each state of this transducer. After the operation, for each
state S in this transducer, there is an epsilon transition that leads from state
S to the initial state of *ins*, and for each final state of *ins*, there is an
epsilon transition that leads from that final state to state S in this
transducer. The weights of the final states in *ins* are copied to the epsilon
transitions leading to state S.
"""
%feature("docstring") hfst::HfstTransducer::input_project
"""
Extract the input language of the transducer.
All transition symbol pairs *isymbol:osymbol* are changed to *isymbol:isymbol*.
"""
%feature("docstring") hfst::HfstTransducer::reverse
"""
Reverse the transducer.
A reverted transducer accepts the string 'n(0) n(1) ... n(N)' iff the original
transducer accepts the string 'n(N) n(N-1) ... n(0)'
"""
%feature("docstring") hfst::HfstTransducer::compose_intersect
"""
Compose this transducer with the intersection of transducers in *v*.
If *invert* is true, then compose the intersection of the transducers in *v*
with this transducer.
The algorithm used by this function is faster than intersecting all transducers
one by one and then composing this transducer with the intersection.
pre: The transducers in *v* are deterministic and epsilon-free.
Parameters
----------
* `v` :
A tuple of transducers.
* `invert` :
Whether the intersection of the transducers in *v* is composed with this
transducer.
"""
%feature("docstring") hfst::HfstTransducer::copy
"""
Return a deep copy of the transducer.
tr = hfst.regex('[foo:bar::0.3]*')
TR = tr.copy()
assert(tr.compare(TR))
"""
%feature("docstring") hfst::HfstTransducer::shuffle
"""
Shuffle this transducer with transducer *another*.
If transducer A accepts string 'foo' and transducer B string 'bar', the
transducer that results from shuffling A and B accepts all strings
[(f|b)(o|a)(o|r)].
pre: Both transducers must be automata, i.e. map strings onto themselves.
"""
%feature("docstring") hfst::HfstTransducer::prune
"""
Make transducer coaccessible.
A transducer is coaccessible iff there is a path from every state to a final
state.
"""
%feature("docstring") hfst::HfstTransducer::extract_shortest_paths
"""
Extract shortest paths of the transducer.
Returns
-------
A dictionary.
"""
%feature("docstring") hfst::HfstTransducer::set_final_weights
"""
Set the weights of all final states to *weight*.
If the HfstTransducer is of unweighted type (hfst.ImplementationType.SFST_TYPE or
hfst.ImplementationType.FOMA_TYPE), nothing is done.
"""
%feature("docstring") hfst::HfstTransducer::push_weights_to_end
"""
Push weights towards final state(s).
If the HfstTransducer is of unweighted type (hfst.ImplementationType.SFST_TYPE or
hfst.ImplementationType.FOMA_TYPE), nothing is done.
An example:
>>> import hfst
>>> tr = hfst.regex('[a::1 a:b::0.3 (b::0)]::0.7;')
>>> tr.push_weights_to_end()
>>> print(tr)
0 1 a a 0.000000
1 2 a b 0.000000
2 3 b b 0.000000
2 2.000000
3 2.000000
See also: hfst.HfstTransducer.push_weights_to_start
"""
%feature("docstring") hfst::HfstTransducer::push_weights_to_start
"""
Push weights towards initial state.
If the HfstTransducer is of unweighted type (hfst.ImplementationType.SFST_TYPE or
hfst.ImplementationType.FOMA_TYPE), nothing is done.
An example:
>>> import hfst
>>> tr = hfst.regex('[a::1 a:b::0.3 (b::0)]::0.7;')
>>> tr.push_weights_to_start()
>>> print(tr)
0 1 a a 2.000000
1 2 a b 0.000000
2 3 b b 0.000000
2 0.000000
3 0.000000
See also: hfst.HfstTransducer.push_weights_to_end
"""
%feature("docstring") hfst::HfstTransducer::subtract
"""
Subtract transducer *another* from this transducer.
"""
%feature("docstring") hfst::HfstTransducer::repeat_star
"""
A concatenation of N transducers where N is any number from zero to infinity.
"""
%feature("docstring") hfst::HfstTransducer::write_att
"""
Write the transducer in AT&T format to file *f*, *write_weights* defined whether
weights are written.
Parameters
----------
* `f` :
A python file where transducer is written.
* `write_weights` :
Whether weights are written.
"""
%feature("docstring") hfst::HfstTransducer::write_att
"""
Write the transducer in AT&T format to file *ofile*, *write_weights* defines
whether weights are written.
The fields in the resulting AT&T format are separated by tabulator characters.
NOTE: If the transition symbols contain space characters,the spaces are printed
as '@_SPACE_@' because whitespace characters are used as field separators in
AT&T format. Epsilon symbols are printed as '@0@'.
If several transducers are written in the same file, they must be separated by a
line of two consecutive hyphens \"--\", so that they will be read correctly by
hfst.read_att.
An example:
tr1 = hfst.regex('[foo:bar baz:0 \" \"]::0.3')
tr2 = hfst.empty_fst()
tr3 = hfst.epsilon_fst(0.5)
tr4 = hfst.regex('[foo]')
tr5 = hfst.empty_fst()
f = hfst.hfst_open('testfile.att', 'w')
for tr in [tr1, tr2, tr3, tr4]:
tr.write_att(f)
f.write('--\\n')
tr5.write_att(f)
f.close()
This will yield a file 'testfile.att' that looks as follows:
0 1 foo bar 0.299805
1 2 baz @0@ 0.000000
2 3 @_SPACE_@ @_SPACE_@ 0.000000
3 0.000000
--
--
0 0.500000
--
0 1 foo foo 0.000000
1 0.000000
--
Exceptions
----------
* `StreamCannotBeWrittenException` :
* `StreamIsClosedException` :
See also: hfst.HfstOutputStream.write
See also: hfst.HfstTransducer.__init__
"""
%feature("docstring") hfst::HfstTransducer::write_att
"""
Write the transducer in AT&T format to file named *filename*.
*write_weights* defines whether weights are written.
If the file exists, it is overwritten. If the file does not exist, it is
created.
"""
%feature("docstring") hfst::HfstTransducer::lookup
"""
Lookup string *input*.
Parameters
----------
* `input` :
The input.
* `kwargs` :
Possible parameters and their default values are: obey_flags=True,
max_number=-1, time_cutoff=0.0, output='tuple'
* `obey_flags` :
Whether flag diacritics are obeyed. Currently always True.
* `max_number` :
Maximum number of results returned, defaults to -1, i.e. infinity.
* `time_cutoff` :
How long the function can search for results before returning, expressed in
seconds. Defaults to 0.0, i.e. infinitely.
* `output` :
Possible values are 'tuple', 'text' and 'raw', 'tuple' being the default.
note: This function is implemented only for optimized lookup format
(hfst.ImplementationType.HFST_OL_TYPE or hfst.ImplementationType.HFST_OLW_TYPE). Either convert to
optimized lookup format or to HfstBasicTransducer if you wish to perform
lookup. Conversion to OL might take a while but it lookup is fast.
Conversion to HfstBasicTransducer is quick but lookup is slower.
"""
%feature("docstring") hfst::HfstTransducer::__init__
"""
Create an empty transducer.
tr = hfst.HfstTransducer()
assert(tr.compare(hfst.empty_fst()))
"""
%feature("docstring") hfst::HfstTransducer::__init__
"""
Create a deep copy of HfstTransducer *another* or a transducer equivalent to
HfstBasicTransducer *another*.
Parameters
----------
* `another` :
An HfstTransducer or HfstBasicTransducer.
An example:
tr1 = hfst.regex('foo bar foo')
tr2 = hfst.HfstTransducer(tr1)
tr2.substitute('foo','FOO')
tr1.concatenate(tr2)
"""
%feature("docstring") hfst::HfstTransducer::__init__
"""
Create an HFST transducer equivalent to HfstBasicTransducer *t*.
The type of the created transducer is defined by *type*.
Parameters
----------
* `t` :
An HfstBasicTransducer.
* `type` :
The type of the resulting transducer. If you want to use the default type,
you can just call hfst.HfstTransducer(fsm)
"""
%feature("docstring") hfst::HfstTransducer::insert_to_alphabet
"""
Explicitly insert *symbol* to the alphabet of the transducer.
Parameters
----------
* `symbol` :
The symbol (string) to be inserted.
note: Usually this function is not needed since new symbols are added to the
alphabet by default.
"""
%feature("docstring") hfst::HfstTransducer::concatenate
"""
Concatenate this transducer with *another*.
"""
%feature("docstring") hfst::HfstTransducer::determinize
"""
Determinize the transducer.
Determinizing a transducer yields an equivalent transducer that has no state
with two or more transitions whose input:output symbol pairs are the same.
"""
%feature("docstring") hfst::HfstTransducer::is_automaton
"""
Whether each transition in the transducer has equivalent input and output
symbols.
note: Transition with hfst.UNKNOWN on both sides IS NOT a transition with
equivalent input and output symbols.
note: Transition with hfst.IDENTITY on both sides IS a transition with
equivalent input and output symbols.
"""
%feature("docstring") hfst::HfstTransducer::minimize
"""
Minimize the transducer.
Minimizing a transducer yields an equivalent transducer with the smallest number
of states.
Bug
OpenFst's minimization algorithm seems to add epsilon transitions to weighted
transducers?
"""
%feature("docstring") hfst::HfstTransducer::set_property
"""
Set arbitrary string property *property* to *value*.
Parameters
----------
* `property` :
A string naming the property.
* `value` :
A string expressing the value of *property*.
set_property('name', 'name of the transducer') equals set_name('name of the
transducer').
note: While this function is capable of creating endless amounts of arbitrary
metadata, it is suggested that property names are drawn from central
repository, or prefixed with \"x-\". A property that does not follow this
convention may affect the behavior of transducer in future releases.
"""
%feature("docstring") hfst::HfstTransducer::convert
"""
Convert the transducer into an equivalent transducer in format *type*.
If a weighted transducer is converted into an unweighted one, all weights are
lost. In the reverse case, all weights are initialized to the semiring's one.
A transducer of type hfst.ImplementationType.SFST_TYPE, hfst.ImplementationType.TROPICAL_OPENFST_TYPE,
hfst.ImplementationType.LOG_OPENFST_TYPE or hfst.ImplementationType.FOMA_TYPE can be converted into an
hfst.ImplementationType.HFST_OL_TYPE or hfst.ImplementationType.HFST_OLW_TYPE transducer, but an
hfst.ImplementationType.HFST_OL_TYPE or hfst.ImplementationType.HFST_OLW_TYPE transducer cannot be
converted to any other type.
note: For conversion between HfstBasicTransducer and HfstTransducer, see
hfst.HfstTransducer.__init__ and hfst.HfstBasicTransducer.__init__
"""
%feature("docstring") hfst::HfstTransducer::remove_epsilons
"""
Remove all *epsilon:epsilon* transitions from the transducer so that the
resulting transducer is equivalent to the original one.
"""
%feature("docstring") hfst::HfstTransducer::repeat_n
"""
A concatenation of *n* transducers.
"""
%feature("docstring") hfst::HfstTransducer::number_of_arcs
"""
The number of transitions in the transducer.
"""
%feature("docstring") hfst::HfstTransducer::cross_product
"""
Make cross product of this transducer with *another*.
It pairs every string of this with every string of *another*. If strings are not
the same length, epsilon padding will be added in the end of the shorter string.
pre: Both transducers must be automata, i.e. map strings onto themselves.
"""
%feature("docstring") hfst::HfstTransducer::write
"""
Write the transducer in binary format to *ostr*.
Parameters
----------
* `ostr` :
A hfst.HfstOutputStream where the transducer is written.
"""
%feature("docstring") hfst::HfstTransducer::lenient_composition
"""
Perform a lenient composition on this transducer and *another*.
TODO: explain more.
"""
%feature("docstring") hfst::HfstTransducer::remove_optimization
"""
Remove lookup optimization.
This effectively converts transducer (back) into default fst type.
"""
%feature("docstring") hfst::HfstTransducer::get_property
"""
Get arbitrary string propert *property*.
Parameters
----------
* `property` :
The name of the property whose value is returned. get_property('name') works
like get_name().
"""
%feature("docstring") hfst::HfstTransducer::get_alphabet
"""
Get the alphabet of the transducer.
The alphabet is defined as the set of symbols known to the transducer.
Returns
-------
A tuple of strings.
"""
// File: classhfst_1_1MultiCharSymbolTrie.xml
%feature("docstring") hfst::MultiCharSymbolTrie
"""
TODO: documentation ???
"""
%feature("docstring") hfst::MultiCharSymbolTrie::__init__
"""
TODO: documentation.
"""
%feature("docstring") hfst::MultiCharSymbolTrie::add
"""
TODO: documentation.
Parameters
----------
* `string` :
const char *
"""
// File: classhfst_1_1PmatchContainer.xml
%feature("docstring") hfst_ol::Location
"""
Location of a pmatch result.
Attributes:
start: start index of match
length: length of match
input: the matched input string
output: the matching output string
tag: the tag of match
weight: the weight of match
input_parts: tuple of indices in input_symbol_strings
output_string: tuple of indices in output_symbol_strings
input_symbol_strings: tuple of matched input symbol strings
output_symbol_strings: tuple of matching output symbol strings
"""
%feature("docstring") hfst_ol::PmatchContainer
"""
A class for performing pattern matching.
"""
%feature("docstring") hfst_ol::PmatchContainer::__init__
"""
Create a PmatchContainer based on definitions *defs* or transducer read from *filename*.
NOTE: the first variant performs many checks and conversion and is much slower than
the second one. The second variant assumes that the transducer has been compiled for
pmatch and is in valid format.
* defs A tuple of transducers in hfst.HFST_OLW_FORMAT defining how pmatch is
done.
* filename Name of the file that contains a compiled transducer (archive) that is
used for pmatching.
See also: hfst.compile_pmatch_file
"""
%feature("docstring") hfst_ol::PmatchContainer::locate
"""
The locations of pmatched strings for string *input* where the results are limited
as defined by *time_cutoff* and *weight_cutoff*.
Parameters
----------
* `input` :
The input string.
* `time_cutoff` :
Time cutoff, defaults to zero, i.e. no cutoff.
* `weight_cutoff` :
Weight cutoff, defaults to infinity, i.e. no cutoff.
Returns
-------
A tuple of tuples of Location.
"""
%feature("docstring") hfst_ol::PmatchContainer::get_profiling_info
"""
todo
"""
%feature("docstring") hfst_ol::PmatchContainer::set_profile
"""
todo
"""
%feature("docstring") hfst_ol::PmatchContainer::set_extract_tags_mode
"""
todo
"""
%feature("docstring") hfst_ol::PmatchContainer::match
"""
Match input *input*.
"""
%feature("docstring") hfst_ol::PmatchContainer::set_verbose
"""
todo
"""
// File: classhfst_1_1PrologReader.xml
%feature("docstring") hfst::PrologReader
"""
A class for reading input in prolog text format and converting it into
transducer(s).
An example that reads prolog input from file 'testfile.prolog' and creates the
corresponding transducers and prints them. If the input cannot be parsed, a
message showing the invalid line in prolog input is printed and reading is
stopped.
with open('testfile.prolog', 'r') as f:
try:
r = hfst.PrologReader(f)
for tr in r:
print(tr)
except hfst.exceptions.NotValidPrologFormatException as e:
print(e.what())
"""
%feature("docstring") hfst::PrologReader::next
"""
Return next element (for python version 2).
Needed for 'for ... in' statement.
for transducer in prolog_reader:
print(transducer)
Exceptions
----------
* `StopIteration` :
"""
%feature("docstring") hfst::PrologReader::__iter__
"""
An iterator to the reader.
Needed for 'for ... in' statement.
for transducer in prolog_reader:
print(transducer)
"""
%feature("docstring") hfst::PrologReader::__next__
"""
Return next element (for python version 3).
Needed for 'for ... in' statement.
for transducer in prolog_reader:
print(transducer)
Exceptions
----------
* `StopIteration` :
"""
%feature("docstring") hfst::PrologReader::__init__
"""
Create a PrologReader that reads input from file *f*.
Parameters
----------
* `f` :
A python file.
"""
%feature("docstring") hfst::PrologReader::read
"""
Read next transducer.
Read next transducer description in prolog format and return a corresponding
transducer.
Exceptions
----------
* `hfst.exceptions.NotValidPrologFormatException` :
* `hfst.exceptions.EndOfStreamException` :
"""
// File: classhfst_1_1XreCompiler.xml
%feature("docstring") hfst::XreCompiler
"""
A regular expression compiler.
"""
%feature("docstring") hfst::XreCompiler::__init__
"""
Construct compiler for OpenFst format (the default) transducers.
"""
%feature("docstring") hfst::XreCompiler::__init__
"""
Create compiler for *impl* format transducers.
"""
%feature("docstring") hfst::XreCompiler::define_list
"""
todo
"""
%feature("docstring") hfst::XreCompiler::is_function_definition
"""
Whether *name* is a function definition.
"""
%feature("docstring") hfst::XreCompiler::is_definition
"""
Whether *name* is a definition.
"""
%feature("docstring") hfst::XreCompiler::set_verbosity
"""
Set the verbosity of the compiler.
* v True or False
"""
%feature("docstring") hfst::XreCompiler::undefine
"""
todo
"""
%feature("docstring") hfst::XreCompiler::setOutputToConsole
"""
(Windows-specific) Whether output is printed to console instead of standard
output.
* v True or False
"""
%feature("docstring") hfst::XreCompiler::compile
"""
Compile a transducer defined by *xre*.
May return a pointer to *empty* transducer on non-fatal error. A None pointer is
returned on fatal error, if abort is not called.
Returns
-------
An HfstTransducer pointer.
"""
%feature("docstring") hfst::XreCompiler::set_expand_definitions
"""
Whether definitions are expanded.
* v True or False
"""
%feature("docstring") hfst::XreCompiler::define_xre
"""
Add a definition macro.
Compilers will replace arcs labeled *name*, with a transducer defined by regular
expression *xre* in later phases of compilation (if set_expand_definitions(True)
has been called).
"""
%feature("docstring") hfst::XreCompiler::define_transducer
"""
Add a definition macro.
Compilers will replace arcs labeled *name*, with a transducer *transducer* in
later phases of compilation (if set_expand_definitions(True) has been called).
"""
%feature("docstring") hfst::XreCompiler::define_function
"""
todo
"""
%feature("docstring") hfst::XreCompiler::getOutputToConsole
"""
(Windows-specific) Whether output is printed to console instead of standard
output.
"""
// File: exceptions_2____init_____8py.xml
// File: ____init_____8py.xml
// File: namespacehfst_1_1exceptions.xml
// File: namespacehfst_1_1rules.xml
%feature("docstring") hfst::xeroxRules::Rule
"""
todo
"""
%feature("docstring") hfst::xeroxRules::replace
"""
todo
"""
// note: this function is offered as 'replace_left' in package hfst.xerox_rules
%feature("docstring") hfst::xeroxRules::xerox_replace_left
"""
todo
"""
%feature("docstring") hfst::xeroxRules::replace_leftmost_longest_match
"""
todo
"""
%feature("docstring") hfst::xeroxRules::replace_rightmost_longest_match
"""
todo
"""
%feature("docstring") hfst::xeroxRules::replace_leftmost_shortest_match
"""
todo
"""
%feature("docstring") hfst::xeroxRules::replace_rightmost_shortest_match
"""
todo
"""
%feature("docstring") hfst::xeroxRules::replace_epenthesis
"""
todo
"""
// note: this function is offered as 'restriction' in package hfst.xerox_rules
%feature("docstring") hfst::xeroxRules::xerox_restriction
"""
todo
"""
%feature("docstring") hfst::xeroxRules::before
"""
todo
"""
%feature("docstring") hfst::xeroxRules::after
"""
todo
"""
%feature("docstring") hfst::rules::two_level_if
"""
A transducer that obligatorily performs the mappings defined by *mappings* in
the context *context* when the alphabet is *alphabet*.
Parameters
----------
* `context` :
A pair of transducers where the first transducer defines the left context
and the second transducer the right context.
* `mappings` :
A set of mappings (a tuple of string pairs) that the resulting transducer
will perform in the context given in *context*.
* `alphabet` :
The set of symbol pairs (a tuple of string pairs) that defines the alphabet
(see the example).
For example, a transducer yielded by the following arguments (in pseudcode)
context = pair( [c|d], [e] )
mappings = set(a:b)
alphabet = set(a, a:b, b, c, d, e, ...) obligatorily maps the symbol a to b
if c or d precedes and e follows. (Elsewhere, the mapping of a to b is
optional). This expression is identical to ![.* [c|d] [a:. & !a:b] [e] .*] Note
that the alphabet must contain the pair a:b here.
See also: SFST manual
"""
%feature("docstring") hfst::rules::replace_down
"""
The same as replace_up, but matching is done on the output side of *mapping*.
See also: replace_up SFST manual.
"""
%feature("docstring") hfst::rules::replace_down
"""
The same as replace_down(context, mapping, optional, alphabet) but *mapping* is
performed in every context.
See also: replace_up
"""
%feature("docstring") hfst::rules::deep_restriction_and_coercion
"""
A transducer that is equivalent to the intersection of deep_restriction and
deep_coercion.
See also: deep_restriction deep_coercion SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::surface_restriction_and_coercion
"""
A transducer that is equivalent to the intersection of surface_restriction and
surface_coercion.
See also: surface_restriction surface_coercion SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::left_replace_down_karttunen
"""
Inversion of the replace_up and the result needs to be composed on the upper
side of the input language.
However, matching is done on the output side of *mapping*.
See also: replace_up
"""
%feature("docstring") hfst::rules::coercion
"""
A transducer that requires that one of the mappings defined by *mapping* must
occur in each context in *contexts*.
Symbols outside of the matching substrings are mapped to any symbol allowed by
*alphabet*.
See also: SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::left_replace_down
"""
Inversion of the replace_up and the result needs to be composed on the upper
side of the input language.
However, matching is done on the output side of *mapping*.
See also: replace_up
"""
%feature("docstring") hfst::rules::surface_coercion
"""
A transducer that specifies that a string from the input language of the
transducer *mapping* always has to the mapped to one of its output strings
according to transducer *mapping* if it appears in any of the contexts in
*contexts*.
Symbols outside of the matching substrings are mapped to any symbol allowed by
*alphabet*.
See also: SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::deep_coercion
"""
A transducer that specifies that a string from the output language of the
transducer *mapping* always has to be mapped to one of its input strings
(according to transducer *mappings*) if it appears in any of the contexts in
*contexts*.
Symbols outside of the matching substrings are mapped to any symbol allowed by
*alphabet*.
See also: SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::replace_down_karttunen
"""
TODO: document.
"""
%feature("docstring") hfst::rules::replace_left
"""
The same as replace_up, but left context matching is done on the output side of
*mapping* and right context on the input side of *mapping*.
See also: replace_up
"""
%feature("docstring") hfst::rules::two_level_if_and_only_if
"""
A transducer that always performs the mappings defined by *mappings* in the
context *context* and only in that context, when the alphabet is *alphabet*.
If called with the same arguments as in the example of two_level_if, the
transducer maps symbol a to b only and only if c or d precedes and e follows.
The mapping of a to b is obligatory in this context and cannot occur in any
other context.
The expression is equivalent to ![.* [c|d] [a:. & !a:b] [e] .*] & ![ [ ![.*
[c|d]] a:b .* ] | [ .* a:b ![[e] .*] ] ]
See also: two_level_if
"""
%feature("docstring") hfst::rules::surface_restriction
"""
A transducer that specifies that a string from the input language of the
transducer *mapping* may only be mapped to one of its output strings (according
to transducer *mapping*) if it appears in any of the contexts in *contexts*.
Symbols outside of the matching substrings are mapped to any symbol allowed by
*alphabet*.
See also: SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::left_replace_left
"""
Inversion of the replace_up and the result needs to be composed on the upper
side of the input language.
However, left context matching is done on the input side of *mapping* and right
context on the output side of *mapping*.
See also: replace_up */
"""
%feature("docstring") hfst::rules::deep_restriction
"""
A transducer that specifies that a string from the output language of the
transducer *mapping* may only be mapped to one of its input strings (according
to transducer *mappings*) if it appears in any of the contexts in
*contexts.Symbols* outside of the matching substrings are mapped to any symbol
allowed by *alphabet*.
See also: SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::left_replace_up
"""
Inversion of the replace_up and the result needs to be composed on the upper
side of the input language.
B <- A is the inversion of A -> B. *mapping* is performed in every context.
See also: replace_up
"""
%feature("docstring") hfst::rules::left_replace_up
"""
Inversion of the replace_up and the result needs to be composed on the upper
side of the input language.
B <- A is the inversion of A -> B.
See also: replace_up
"""
%feature("docstring") hfst::rules::left_replace_right
"""
Inversion of the replace_up and the result needs to be composed on the upper
side of the input language.
However, left context matching is done on the output side of *mapping* and right
context on the input side of *mapping*.
See also: replace_up
"""
%feature("docstring") hfst::rules::replace_up
"""
A transducer that performs an upward mapping *mapping* in the context *context*
when the alphabet is *alphabet*.
*optional* defines whether the mapping is optional.
Parameters
----------
* `context` :
A pair of transducers where the first transducer defines the left context
and the second transducer the right context. Both transducers must be
automata, i.e. map strings onto themselves.
* `mapping` :
The mapping (transducer) that the resulting transducer will perform in the
context given in *context*.
* `optional` :
Whether the mapping is optional.
* `alphabet` :
The set of symbol pairs that defines the alphabet (a tuple of string pairs).
Each substring s of the input string which is in the input language of the
transducer *mapping* and whose left context is matched by the expression [.* l]
(where l is the first element of *context*) and whose right context is matched
by [r .*] (where r is the second element in the context) is mapped to the
respective surface strings defined by transducer *mapping*. Any other character
is mapped to the characters specified in *alphabet*. The left and right contexts
must be automata (i.e. transducers which map strings onto themselves).
For example, a transducer yielded by the following arguments (in pseudocode)
context = pair( [c], [c] )
mappings = [ a:b a:b ]
alphabet = set(a, b, c) would map the string \"caacac\" to \"cbbcac\".
Note that the alphabet must contain the characters a and b, but not the pair a:b
(unless this replacement is to be allowed everywhere in the context).
Note that replace operations (unlike the two-level rules) have to be combined by
composition rather than intersection.
Exceptions
----------
* `ContextTransducersAreNotAutomataException` :
See also: SFST manual
"""
%feature("docstring") hfst::rules::replace_up
"""
The same as replace_up but *mapping* is performed in every context.
See also: replace_up
"""
%feature("docstring") hfst::rules::two_level_only_if
"""
A transducer that allows the mappings defined by *mappings* only in the context
*context*, when the alphabet is *alphabet*.
If called with the same arguments as in the example of two_level_if, the
transducer allows the mapping of symbol a to b only if c or d precedes and e
follows. The mapping of a to b is optional in this context but cannot occur in
any other context.
The expression is equivalent to ![ [ ![.* [c|d]] a:b .* ] | [ .* a:b ![[e] .*] ]
]
See also: two_level_if
"""
%feature("docstring") hfst::rules::restriction_and_coercion
"""
A transducer that is equivalent to the intersection of restriction and coercion
and requires that the mappings defined by *mapping* occur always and only in the
given contexts in *contexts*.
Symbols outside of the matching substrings are mapped to any symbol allowed by
*alphabet*.
See also: restriction coercion SFST manual
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::restriction
"""
A transducer that allows any (substring) mapping defined by *mapping* only if it
occurs in any of the contexts in *contexts*.
Symbols outside of the matching substrings are mapped to any symbol allowed by
*alphabet*.
Exceptions
----------
* `EmptySetOfContextsException` :
See also: SFST manual.
Parameters
----------
* `contexts` :
A tuple of HfstTransducer pairs.
* `mapping` :
An HfstTransducer.
* `alphabet` :
A tuple of string pairs.
"""
%feature("docstring") hfst::rules::replace_right
"""
The same as replace_up, but left context matching is done on the input side of
*mapping* and right context on the output side of *mapping*.
See also: replace_up SFST manual.
"""
// File: namespacehfst_1_1types.xml
// File: namespacehfst.xml
%feature("docstring") set_default_fst_type
"""
Set the default implementation type.
Parameters
----------
* `impl` :
An hfst.ImplementationType.
Set the implementation type (SFST_TYPE, TROPICAL_OPENFST_TYPE, FOMA_TYPE) that
is used by default by all operations that create transducers. The default value
is TROPICAL_OPENFST_TYPE
"""
%feature("docstring") read_att_transducer
"""
Read next transducer from AT&T file pointed by *f*.
*epsilonstr* defines the symbol used for epsilon in the file.
Parameters
----------
* `f` :
A python file
* `epsilonstr` :
How epsilon is represented in the file. By default, \"@_EPSILON_SYMBOL_@\"
and \"@0@\" are both recognized.
If the file contains several transducers, they must be separated by \"--\"
lines. In AT&T format, the transition lines are of the form:
[0-9]+[\\w]+[0-9]+[\\w]+[^\\w]+[\\w]+[^\\w]([\\w]+(-)[0-9]+(\\.[0-9]+))
and final state lines:
[0-9]+[\\w]+([\\w]+(-)[0-9]+(\\.[0-9]+))
If several transducers are listed in the same file, they are separated by lines
of two consecutive hyphens \"--\". If the weight
([\\w]+(-)[0-9]+(\\.[0-9]+)) is missing, the transition or final state is
given a zero weight.
NOTE: If transition symbols contains spaces, they must be escaped as '@_SPACE_@'
because spaces are used as field separators. Both '@0@' and '@_EPSILON_SYMBOL_@'
are always interpreted as epsilons.
An example:
0 1 foo bar 0.3
1 0.5
--
0 0.0
--
--
0 0.0
0 0 a <eps> 0.2
The example lists four transducers in AT&T format: one transducer accepting the
string pair <'foo','bar'>, one epsilon transducer, one empty transducer and one
transducer that accepts any number of 'a's and produces an empty string in all
cases. The transducers can be read with the following commands (from a file
named 'testfile.att'):
transducers = []
ifile = open('testfile.att', 'r')
try:
while (True):
t = hfst.read_att_transducer(ifile, '<eps>')
transducers.append(t)
print(\"read one transducer\")
except hfst.exceptions.NotValidAttFormatException as e:
print(\"Error reading transducer: not valid AT&T format.\")
except hfst.exceptions.EndOfStreamException as e:
pass
ifile.close()
print(\"Read %i transducers in total\" % len(transducers))
Epsilon will be represented as hfst.EPSILON in the resulting transducer. The
argument *epsilon_symbol* only denotes how epsilons are represented in *ifile*.
Bug
Empty transducers are in theory represented as empty strings in AT&T format.
However, this sometimes results in them getting interpreted as end-of-file. To
avoid this, use an empty line instead, i.e. a single newline character.
Exceptions
----------
* `NotValidAttFormatException` :
* `StreamNotReadableException` :
* `StreamIsClosedException` :
* `EndOfStreamException` :
See also: #write_att
"""
%feature("docstring") read_att_input
"""
Read AT&T input from the user and return a transducer.
Returns
-------
An HfstTransducer whose type is hfst.get_default_fst_type(). Read one AT&T line
at a time from standard input and finally return an equivalent transducer. An
empty line signals the end of input.
"""
%feature("docstring") compile_lexc_file
"""
Compile lexc file *filename* into a transducer.
Parameters
----------
* `filename` :
The name of the lexc file.
* `kwargs` :
Arguments recognized are: verbosity, with_flags, output.
* `verbosity` :
The verbosity of the compiler, defaults to 0 (silent). Possible values are:
0, 1, 2.
* `with_flags` :
Whether lexc flags are used when compiling, defaults to False.
* `output` :
Where output is printed. Possible values are sys.stdout, sys.stderr, a
StringIO, sys.stderr being the default?
"""
%feature("docstring") fst_type_to_string
"""
Get a string representation of transducer implementation type *type*.
Parameters
----------
* `type` :
An hfst.ImplementationType.
"""
%feature("docstring") epsilon_fst
"""
Get an epsilon transducer.
Parameters
----------
* `weight` :
The weight of the final state. Epsilon transducer has one state that is
final (with final weight *weight*), i.e. it recognizes the empty string.
"""
%feature("docstring") empty_fst
"""
Get an empty transducer.
Empty transducer has one state that is not final, i.e. it does not recognize any
string.
"""
%feature("docstring") compile_pmatch_expression
"""
Compile a pmatch expression into a tuple of transducers.
Parameters
----------
* `expr` :
A string defining how pmatch is done.
See also: hfst.compile_pmatch_file
"""
%feature("docstring") start_xfst
"""
Start interactive xfst compiler.
Parameters
----------
* `kwargs` :
Arguments recognized are: type, quit_on_fail.
* `quit_on_fail` :
Whether the compiler exits on any error, defaults to False.
* `type` :
Implementation type of the compiler, defaults to
hfst.get_default_fst_type().
"""
%feature("docstring") compile_pmatch_file
"""
Compile pmatch expressions as defined in *filename* and return a tuple of
transducers.
An example:
If we have a file named streets.txt that contains:
define CapWord UppercaseAlpha Alpha* ; define StreetWordFr [{avenue} |
{boulevard} | {rue}] ; define DeFr [ [{de} | {du} | {des} | {de la}] Whitespace
] | [{d'} | {l'}] ; define StreetFr StreetWordFr (Whitespace DeFr) CapWord+ ;
regex StreetFr EndTag(FrenchStreetName) ;
we can run:
defs = hfst.compile_pmatch_file('streets.txt') const =
hfst.PmatchContainer(defs) assert cont.match(\"Je marche seul dans l'avenue des
Ternes.\") == \"Je marche seul dans l'<FrenchStreetName>avenue des
Ternes</FrenchStreetName>.\"
"""
%feature("docstring") fst
"""
Get a transducer that recognizes one or more paths.
Parameters
----------
* `arg` :
See example below
Possible inputs:
One unweighted identity path:
'foo' -> [f o o]
Weighted path: a tuple of string and number, e.g.
('foo',1.4)
('bar',-3)
('baz',0)
Several paths: a list or a tuple of paths and/or weighted paths, e.g.
['foo', 'bar']
('foo', ('bar',5.0))
('foo', ('bar',5.0), 'baz', 'Foo', ('Bar',2.4))
[('foo',-1), ('bar',0), ('baz',3.5)]
A dictionary mapping strings to any of the above cases:
{'foo':'foo', 'bar':('foo',1.4), 'baz':(('foo',-1),'BAZ')}
"""
%feature("docstring") get_default_fst_type
"""
Get default transducer implementation type.
If the default type is not set, it defaults to hfst.ImplementationType.TROPICAL_OPENFST_TYPE
"""
%feature("docstring") regex
"""
Get a transducer as defined by regular expression *regexp*.
Parameters
----------
* `regexp` :
The regular expression defined with Xerox transducer notation.
* `kwargs` :
Argumnets recognized are: error.
* `error` :
Where warnings and errors are printed. Possible values are sys.stdout,
sys.stderr (the default), a StringIO or None, indicating a quiet mode.
"""
%feature("docstring") is_diacritic
"""
Whether symbol *symbol* is a flag diacritic.
Flag diacritics are of the form
@[PNDRCU][.][A-Z]+([.][A-Z]+)?@
"""
%feature("docstring") compile_xfst_file
"""
Compile (is 'run' a better term?) xfst file *filename*.
Parameters
----------
* `filename` :
The name of the xfst file.
* `kwargs` :
Arguments recognized are: verbosity, quit_on_fail, output, type.
* `verbosity` :
The verbosity of the compiler, defaults to 0 (silent). Possible values are:
0, 1, 2.
* `quit_on_fail` :
Whether the script is exited on any error, defaults to True.
* `output` :
Where output is printed. Possible values are sys.stdout, sys.stderr, a
StringIO, sys.stderr being the default?
* `type` :
Implementation type of the compiler, defaults to
hfst.get_default_fst_type().
"""
%feature("docstring") tokenized_fst
"""
Get a transducer that recognizes the concatenation of symbols or symbol pairs in
*arg*.
Parameters
----------
* `arg` :
The symbols or symbol pairs that form the path to be recognized.
Example
import libhfst
tok = hfst.HfstTokenizer()
tok.add_multichar_symbol('foo')
tok.add_multichar_symbol('bar')
tr = hfst.tokenized_fst(tok.tokenize('foobar', 'foobaz')) will create the
transducer [foo:foo bar:b 0:a 0:z]
"""
%feature("docstring") read_att_string
"""
Read a multiline string *att* and return a transducer.
Parameters
----------
* `att` :
A string in AT&& format that defines the transducer.
Returns
-------
An HfstTransducer whose type is hfst.get_default_fst_type(). Read *att* and
create a transducer as defined in it.
"""
%feature("docstring") read_prolog_transducer
"""
"""
// File: rules_2____init_____8py.xml
// File: types_2____init_____8py.xml
// File: classhfst_1_1exceptions_1_1ContextTransducersAreNotAutomataException.xml
%feature("docstring") hfst::exceptions::ContextTransducersAreNotAutomataException
"""
Transducers given as rule context are not automata.
See also: hfst.HfstTransducer.is_automaton()
"""
// File: classhfst_1_1exceptions_1_1EmptySetOfContextsException.xml
%feature("docstring") hfst::exceptions::EmptySetOfContextsException
"""
The set of transducer pairs is empty.
Thrown by rule functions.
"""
// File: classhfst_1_1exceptions_1_1EmptyStringException.xml
%feature("docstring") hfst::exceptions::EmptyStringException
"""
An argument string is an empty string.
A transition symbol cannot be an empty string.
"""
// File: classhfst_1_1exceptions_1_1EndOfStreamException.xml
%feature("docstring") hfst::exceptions::EndOfStreamException
"""
The stream is at end.
Thrown by hfst.HfstTransducer hfst.HfstInputStream.__init__
"""
// File: classhfst_1_1exceptions_1_1FlagDiacriticsAreNotIdentitiesException.xml
%feature("docstring") hfst::exceptions::FlagDiacriticsAreNotIdentitiesException
"""
Flag diacritics encountered on one but not the other side of a transition.
"""
// File: classhfst_1_1exceptions_1_1FunctionNotImplementedException.xml
%feature("docstring") hfst::exceptions::FunctionNotImplementedException
"""
Function has not been implemented (yet).
"""
// File: classhfst_1_1exceptions_1_1HfstException.xml
%feature("docstring") hfst::exceptions::HfstException
"""
Base class for HfstExceptions.
Holds its own name and the file and line number where it was thrown.
"""
%feature("docstring") hfst::exceptions::HfstException::what
"""
A message describing the error in more detail.
"""
// File: classhfst_1_1exceptions_1_1HfstFatalException.xml
%feature("docstring") hfst::exceptions::HfstFatalException
"""
An error happened probably due to a bug in the HFST code.
"""
// File: classhfst_1_1exceptions_1_1HfstTransducerTypeMismatchException.xml
%feature("docstring") hfst::exceptions::HfstTransducerTypeMismatchException
"""
Two or more HfstTransducers are not of the same type.
Same as HfstTransducerTypeMismatchException ???
"""
// File: classhfst_1_1exceptions_1_1ImplementationTypeNotAvailableException.xml
%feature("docstring") hfst::exceptions::ImplementationTypeNotAvailableException
"""
The library required by the implementation type requested is not linked to HFST.
"""
// File: classhfst_1_1exceptions_1_1IncorrectUtf8CodingException.xml
%feature("docstring") hfst::exceptions::IncorrectUtf8CodingException
"""
String is not valid utf-8.
This exception suggests that an input string is not valid utf8.
"""
// File: classhfst_1_1exceptions_1_1MetadataException.xml
%feature("docstring") hfst::exceptions::MetadataException
"""
A piece of metadata in an HFST header is not supported.
"""
// File: classhfst_1_1exceptions_1_1MissingOpenFstInputSymbolTableException.xml
%feature("docstring") hfst::exceptions::MissingOpenFstInputSymbolTableException
"""
An OpenFst transducer does not have an input symbol table.
When converting from OpenFst to tropical or log HFST, the OpenFst transducer
must have at least an input symbol table. If the output symbol table is missing,
it is assumed to be equivalent to the input symbol table.
Thrown by hfst.HfstTransducer.__init__
"""
// File: classhfst_1_1exceptions_1_1NotTransducerStreamException.xml
%feature("docstring") hfst::exceptions::NotTransducerStreamException
"""
The stream does not contain transducers.
Thrown by hfst.HfstTransducer hfst.HfstInputStream.__init__
An example.
f = open('foofile', 'w')
f.write('This is an ordinary text file.\\n')
f.close()
try:
instr = hfst.HfstInputStream('foofile')
tr = instr.read()
print(tr)
instr.close()
except hfst.exceptions.NotTransducerStreamException:
print(\"Could not print transducer: the file does not contain binary
transducers.\")
"""
// File: classhfst_1_1exceptions_1_1NotValidAttFormatException.xml
%feature("docstring") hfst::exceptions::NotValidAttFormatException
"""
The stream is not in valid AT&T format.
An example:
f = open('testfile1.att', 'w')
f.write('0 1 a b\\n\\
1 2 c\\n\\
2\\n')
f.close()
f = hfst.hfst_open('testfile1.att', 'r')
try:
tr = hfst.read_att(f)
except hfst.exceptions.NotValidAttFormatException:
print('Could not read file: it is not in valid ATT format.')
f.close() thrown by hfst.HfstTransducer.__init__
"""
// File: classhfst_1_1exceptions_1_1NotValidLexcFormatException.xml
%feature("docstring") hfst::exceptions::NotValidLexcFormatException
"""
The input is not in valid LexC format.
"""
// File: classhfst_1_1exceptions_1_1NotValidPrologFormatException.xml
%feature("docstring") hfst::exceptions::NotValidPrologFormatException
"""
The input is not in valid prolog format.
"""
// File: classhfst_1_1exceptions_1_1SpecifiedTypeRequiredException.xml
%feature("docstring") hfst::exceptions::SpecifiedTypeRequiredException
"""
The type of a transducer is not specified.
This exception is thrown when an implementation type argument is
hfst.ImplementationType.ERROR_TYPE.
"""
// File: classhfst_1_1exceptions_1_1StateIndexOutOfBoundsException.xml
%feature("docstring") hfst::exceptions::StateIndexOutOfBoundsException
"""
The state number argument is not valid.
An example :
tr = hfst.HfstBasicTransducer()
tr.add_state(1)
try:
w = tr.get_final_weight(2)
except hfst.exceptions.StateIndexOutOfBoundsException:
print('State number 2 does not exist')
"""
// File: classhfst_1_1exceptions_1_1StateIsNotFinalException.xml
%feature("docstring") hfst::exceptions::StateIsNotFinalException
"""
State is not final (and cannot have a final weight).
An example :
tr = hfst.HfstBasicTransducer()
tr.add_state(1)
# An exception is thrown as state number 1 is not final
try:
w = tr.get_final_weight(1)
except hfst.exceptions.StateIsNotFinalException:
print(\"State is not final.\")
You should use function hfst.HfstBasicTransducer.is_final_state if you are not
sure whether a state is final.
Thrown by hfst.HfstBasicTransducer get_final_weight.
"""
// File: classhfst_1_1exceptions_1_1StreamCannotBeWrittenException.xml
%feature("docstring") hfst::exceptions::StreamCannotBeWrittenException
"""
Stream cannot be written.
Thrown by hfst.HfstOutputStream.write and hfst.HfstTransducer.write_att
"""
// File: classhfst_1_1exceptions_1_1StreamIsClosedException.xml
%feature("docstring") hfst::exceptions::StreamIsClosedException
"""
Stream is closed.
Thrown by hfst.HfstTransducer.write_att hfst.HfstOutputStream.write
An example:
try:
tr = hfst.regex('foo')
outstr = hfst.HfstOutputStream(filename='testfile')
outstr.close()
outstr.write(tr)
except hfst.exceptions.StreamIsClosedException:
print(\"Could not write transducer: stream to file was closed.\")
"""
// File: classhfst_1_1exceptions_1_1StreamNotReadableException.xml
%feature("docstring") hfst::exceptions::StreamNotReadableException
"""
Stream cannot be read.
"""
// File: classhfst_1_1exceptions_1_1SymbolNotFoundException.xml
%feature("docstring") hfst::exceptions::SymbolNotFoundException
"""
A bug in the HFST code.
"""
// File: classhfst_1_1exceptions_1_1TransducerHasWrongTypeException.xml
%feature("docstring") hfst::exceptions::TransducerHasWrongTypeException
"""
Transducer has wrong type.
This exception suggests that an HfstTransducer has not been properly
initialized, probably due to a bug in the HFST library. Alternatively the
default constructor of HfstTransducer has been called at some point.
See also: hfst.HfstTransducer.__init__
"""
// File: classhfst_1_1exceptions_1_1TransducerHeaderException.xml
%feature("docstring") hfst::exceptions::TransducerHeaderException
"""
Transducer has a malformed HFST header.
Thrown by hfst.HfstTransducer.__init__ hfst.HfstInputStream
"""
// File: classhfst_1_1exceptions_1_1TransducerIsCyclicException.xml
%feature("docstring") hfst::exceptions::TransducerIsCyclicException
"""
Transducer is cyclic.
Thrown by hfst.HfstTransducer.extract_paths. An example
transducer = hfst.regex('[a:b]*')
try:
results = transducer.extract_paths(output='text')
print(\"The transducer has %i paths:\" % len(results))
print(results)
except hfst.exceptions.TransducerIsCyclicException:
print(\"The transducer is cyclic and has an infinite number of paths.
Some of them:\")
results = transducer.extract_paths(output='text', max_cycles=5)
print(results)
"""
// File: classhfst_1_1exceptions_1_1TransducerTypeMismatchException.xml
%feature("docstring") hfst::exceptions::TransducerTypeMismatchException
"""
Two or more transducers do not have the same type.
This can happen if (1) the calling and called transducer in a binary operation,
(2) two transducers in a pair of transducers, (3) two consecutive transducers
coming from an HfstInputStream or (4) two transducers in a function taking two
or more transducers as arguments do not have the same type.
An example:
hfst.set_default_fst_type(hfst.ImplementationType.TROPICAL_OPENFST_TYPE)
tr1 = hfst.regex('foo')
tr2 = hfst.regex('bar')
tr2.convert(hfst.ImplementationType.FOMA_TYPE)
try:
tr1.disjunct(tr2)
except hfst.exceptions.TransducerTypeMismatchException:
print('The implementation types of transducers must be the same.')
"""
// File: classhfst_1_1exceptions_1_1TransducersAreNotAutomataException.xml
%feature("docstring") hfst::exceptions::TransducersAreNotAutomataException
"""
Transducers are not automata.
Example:
tr1 = hfst.regex('foo:bar')
tr2 = hfst.regex('bar:baz')
try:
tr1.cross_product(tr2)
except hfst.exceptions.TransducersAreNotAutomataException:
print('Transducers must be automata in cross product.') This exception
is thrown by hfst.HfstTransducer.cross_product when either input transducer does
not have equivalent input and output symbols in all its transitions.
"""
|