| 1 | [[PageOutline(3-4, Sections)]] |
| 2 | |
| 3 | == !DetectLanguage == |
| 4 | |
| 5 | === Intro === |
| 6 | |
| 7 | detect language for given strings |
| 8 | |
| 9 | |
| 10 | ---- |
| 11 | === Description === |
| 12 | |
| 13 | '''struct !DetectLanguage(string $token, array($text, $text, ...) $data)''' |
| 14 | |
| 15 | Given an array of strings ''data'' the function will return a structure with detected languages for all the strings given as parameters. |
| 16 | |
| 17 | |
| 18 | ---- |
| 19 | === Parameters === |
| 20 | |
| 21 | {{{ |
| 22 | struct( |
| 23 | (string) [token], |
| 24 | array( |
| 25 | (string) [text], |
| 26 | (string) [text], ... |
| 27 | ) [data] |
| 28 | ) |
| 29 | }}} |
| 30 | |
| 31 | ''token (required)'':: |
| 32 | token string identifying user's session, taken from [wiki:XmlRpcLogIn LogIn] output structure. |
| 33 | ''data'':: |
| 34 | * array of strings you want language detected for. |
| 35 | * these strings should be gzipped (without header) and then base64-encoded (to improve transfer speed and save bandwidth). |
| 36 | * strings should be at least 4096 bytes long for good results - but you can send the whole subtitle contents. |
| 37 | |
| 38 | |
| 39 | ---- |
| 40 | === Return Values === |
| 41 | |
| 42 | Output is returned in this structure: |
| 43 | {{{ |
| 44 | struct( |
| 45 | (string) [status], |
| 46 | struct( |
| 47 | (string) [<md5>], |
| 48 | (string) [<md5>], ... |
| 49 | ) [data], |
| 50 | (double) [seconds] |
| 51 | ) |
| 52 | }}} |
| 53 | |
| 54 | |
| 55 | and contains these elements: |
| 56 | ''status'':: |
| 57 | function result code, see [wiki:XmlRpcStatusCode list of status codes] |
| 58 | ''data'':: |
| 59 | contains a structure holding in key the MD5 of the unpacked input string and in value its detected 3-letter language code |
| 60 | ''seconds'':: |
| 61 | time taken to execute this command on server |
| 62 | |
| 63 | |
| 64 | ---- |
| 65 | === Implementations === |
| 66 | |
| 67 | There are currently no available sample implementations. |
| 68 | |
| 69 | |
| 70 | ---- |
| 71 | === Changelog === |
| 72 | |
| 73 | Version 1: created this function |
| 74 | |
| 75 | |
| 76 | ---- |
| 77 | === Examples === |
| 78 | |
| 79 | |
| 80 | ==== Input ==== |
| 81 | |
| 82 | {{{ |
| 83 | #!xml |
| 84 | <methodCall> |
| 85 | <methodName>DetectLanguage</methodName> |
| 86 | <params> |
| 87 | <param> |
| 88 | <value><string>gi6jqoote1ofl5fafu8657mfr1</string></value> |
| 89 | </param> |
| 90 | <param> |
| 91 | <value> |
| 92 | <array> |
| 93 | <data> |
| 94 | <value><string>eNpLyUstVshKVUjMSVXILnpYnFepkJL6CQBfNwj/</string></value> |
| 95 | |
| 96 | ... more gzipped and then base64-encoded strings go here (if any) ... |
| 97 | |
| 98 | </data> |
| 99 | </array> |
| 100 | </value> |
| 101 | </param> |
| 102 | </params> |
| 103 | </methodCall> |
| 104 | }}} |
| 105 | |
| 106 | |
| 107 | ==== Output ==== |
| 108 | |
| 109 | {{{ |
| 110 | #!xml |
| 111 | <methodResponse> |
| 112 | <params> |
| 113 | <param> |
| 114 | <value> |
| 115 | <struct> |
| 116 | <member> |
| 117 | <name>status</name> |
| 118 | <value><string>200 OK</string></value> |
| 119 | </member> |
| 120 | <member> |
| 121 | <name>data</name> |
| 122 | <value> |
| 123 | <struct> |
| 124 | <member> |
| 125 | <name>dfaffb9aa53bc5e9694fd962b9968b7e</name> |
| 126 | <value><string>cze</string></value> |
| 127 | </member> |
| 128 | |
| 129 | ... more language detect results go here (if any) ... |
| 130 | |
| 131 | </struct> |
| 132 | </value> |
| 133 | </member> |
| 134 | <member> |
| 135 | <name>seconds</name> |
| 136 | <value><double>0.425</double></value> |
| 137 | </member> |
| 138 | </struct> |
| 139 | </value> |
| 140 | </param> |
| 141 | </params> |
| 142 | </methodResponse> |
| 143 | }}} |
| 144 | |
| 145 | |
| 146 | ---- |
| 147 | === Notes === |
| 148 | |
| 149 | * if you get a descriptive language name instead of the 3-letter language code please contact us with input/output parameters (for example scots) |
| 150 | * more info about language detection can be found at [http://www.boxoffice.ch/pseudo/ Statistical Text Analysis] |
| 151 | |
| 152 | |
| 153 | ---- |
| 154 | === See also === |
| 155 | |
| 156 | * [wiki:XmlRpcGetSubLanguages GetSubLanguages] |
| 157 | |
| 158 | |
| 159 | ---- |
| 160 | === Comments === |
| 161 | |
| 162 | add your comments, hints and suggestions here if you like ... |
| 163 | |
| 164 | |
| 165 | -------- |
| 166 | [Prev] [wiki:XmlRpcIntro Home] [Next] |