Difference between revisions of "SearchTuExt"

From Wordfast Wiki
Jump to: navigation, search
(= Remarks)
 
(searchTuExt)
 
Line 144: Line 144:
 
  data["attr4"] = "";  
 
  data["attr4"] = "";  
 
  var xhr = new XMLHttpRequest();
 
  var xhr = new XMLHttpRequest();
  xhr.open("POST", "www.freetm.com/wfa/api", true);
+
  xhr.open("POST", "anywhere.wordfast.com/wfa/api", true);
 
  xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
 
  xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
 
  xhr.send(JSON.stringify(data));
 
  xhr.send(JSON.stringify(data));
  
 
==== post ====
 
==== post ====
  <form action="www.freetm./wfa/api" method="post">
+
  <form action="anywhere.wordfast.com/wfa/api" method="post">
 
     <input type="text" id="key" name="key" value="example@key"/>
 
     <input type="text" id="key" name="key" value="example@key"/>
 
     <input type="text" id="cmd" name="cmd" value="15"/>
 
     <input type="text" id="cmd" name="cmd" value="15"/>
Line 168: Line 168:
  
 
==== get ====
 
==== get ====
  www.freetm.com/wfa/api?key=example@key&cmd=66&query=+"brown fox"&pageOffset=0&pageLength=50&caseSensitive=0&matchWholeWords=0
+
  anywhere.wordfast.com/wfa/api?key=example@key&cmd=66&query=+"brown fox"&pageOffset=0&pageLength=50&caseSensitive=0&matchWholeWords=0
 
  &onlyPublicTus=0&creationUser=Foobar&dateFilter=&attr1=&attr2=&attr3=&attr4=
 
  &onlyPublicTus=0&creationUser=Foobar&dateFilter=&attr1=&attr2=&attr3=&attr4=
  

Latest revision as of 09:57, 17 January 2024

Return to command list

searchTuExt

searchTuExt (string key, int cmd, string query, int pageOffset, int pageLength, boolean caseSensitive, boolean matchWholeWords, boolean onlyPublicTus, string creationUser, string dateFilter, string attr1, string attr2, string attr3, string attr4)

Search a word or phrase in the Translation Memory with Lucene-compatible format and with extended parameters and return a list of Translation Units containing this word or phrase. The matches are not scored.

Parameters

key string a valid API Key, generated by making a share at www.freetm.com
cmd int command number is 66
query string word or phrase in Lucene-compatible string format:

The query consists of keywords (or groups of keywords) surrounded by wildcards (+) (-), (*), which refine the search. A group of keywords is framed in quotation marks "". The symbols (+), (-) in front of a keyword (or group) indicate that the keyword must (+) or should not (-) appear. (*) when placed at the end of keyword this symbol indicates that all the terms with identical root accepted. Examples: +token -token* +"phrase token" -"phrase* token*"

pageOffset int optional search options - Page offset from 0 to 32767 default is 0.
pageLength int optional search options - Page length from 0 to 32767 default is 250.
caseSensitive boolean optional search options - Case sensitive - default value is false
matchWholeWords boolean optional search options - Match whole words - default value is false
onlyPublicTus boolean optional filter conditions - Only public Translation units - default value is false
creationUser string optional filter conditions - Filter on TU user ID like "Foobar" - default value an empty string
dateFilter string optional filter conditions - Filter on TU date, the format is [20131111~102010:20131111~101010] []-included true, {}-included false - default value an empty string
attr1 string optional filter conditions - Filter on the value of TU attribute 1 - default value an empty string
attr2 string optional filter conditions - Filter on the value of TU attribute 2 - default value an empty string
attr3 string optional filter conditions - Filter on the value of TU attribute 3 - default value an empty string
attr4 string optional filter conditions - Filter on the value of TU attribute 4 - default value an empty string

Returned value

tus array TU details
tmId int Translation Memory ID
tuId string Translation Unit ID
date string
userId string user ID
srcLang string source language
source string source segment
trgLang string target language
target string target segment
attribute1 string first attribute
attribute2 string second attribute
attribute3 string third attribute
attribute4 string fourth attribute

Request example

json post with javascript

var data = {};
data["key"] = "example@key"; 
data["cmd"] = 66;
data["query"] = "+\"brown fox\"";
data["pageOffset"] = 0;
data["pageLength"] = 250;
data["caseSensitive"] = false;
data["matchWholeWords"] = false;
data["onlyPublicTus"] = false;
data["creationUser"] = "Foobar";
data["dateFilter"] = "";
data["attr1"] = "";
data["attr2"] = "";
data["attr3"] = "";
data["attr4"] = ""; 
var xhr = new XMLHttpRequest();
xhr.open("POST", "anywhere.wordfast.com/wfa/api", true);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send(JSON.stringify(data));

post

<form action="anywhere.wordfast.com/wfa/api" method="post">
   <input type="text" id="key" name="key" value="example@key"/>
   <input type="text" id="cmd" name="cmd" value="15"/>	
   <textarea id="segment" name="query" style="width: 500px; height: 60px;">+"brown fox"</textarea>
   <input type="text" id="pageOffset" name="pageOffset" value="0"/>
   <input type="text" id="pageLength" name="pageLength" value="250"/>
   <input type="text" id="caseSensitive" name="caseSensitive" value="0"/>
   <input type="text" id="matchWholeWords" name="matchWholeWords" value="0"/>
   <input type="text" id="onlyPublicTus" name="onlyPublicTus" value="0"/>
   <input type="text" id="creationUser" name="creationUser" value="Foobar"/>
   <input type="text" id="dateFilter" name="dateFilter" value=""/>
   <input type="text" id="attr1" name="attr1" value=""/>
   <input type="text" id="attr2" name="attr2" value=""/>
   <input type="text" id="attr3" name="attr3" value=""/>
   <input type="text" id="attr4" name="attr4" value=""/>
   <input type="submit" value="Submit">
</form>

get

anywhere.wordfast.com/wfa/api?key=example@key&cmd=66&query=+"brown fox"&pageOffset=0&pageLength=50&caseSensitive=0&matchWholeWords=0
&onlyPublicTus=0&creationUser=Foobar&dateFilter=&attr1=&attr2=&attr3=&attr4=

Response example

json

{ "tus": [    {
               "tmId": 1
               ,"tuId": "81444b70-5f70-11e4-aad0-5c514f6f39a2" 
		,"date": "0140725~174345"
		,"userId": "DGfMDw"
               ,"usageCount": 0
		,"srcLang": "EN"
		,"source": "The brown fox is jumping over the lazy dog"
		,"trgLang": "FR"
		,"target": "Le renard brun saute par dessus le chien paresseux"
		,"attribute1": ""
		,"attribute2": ""
		,"attribute3": ""
		,"attribute4": ""
	       }
	       ,{...}
  ]
}

without white space (new line, carriage return or tabulation).

text

1 tab 81444b70-5f70-11e4-aad0-5c514f6f39a2 tab 0140725~174345 tab DGfMDw tab 0 tab EN tab The brown fox is jumping over the lazy dog. tab FR tab Le renard brun saute par dessus le chien paresseux. tab tab tab LF

LF is Line Feed (\u000A)
tab is a tabulation (\u0009)

return 000 is nothing is found

Remarks

The following operators can be used in the filter expressions: "=", "<", ">", "<=", ">=", "<>", "Э", "Є","!=", "!<", "!>", "!Э",!Є"