Difference between revisions of "SearchSegment"

From Wordfast Wiki
Jump to: navigation, search
(text)
 
 
Line 31: Line 31:
 
|untranslatable  
 
|untranslatable  
 
|boolean  
 
|boolean  
|'''optional''' - do not search small segment assumed untranslatable - default value is true
+
|'''optional''' - do not search small segment assumed untranslatable (return a build TU with an empty TM)- default value is false
 
|-
 
|-
 
|penaltyCase  
 
|penaltyCase  

Latest revision as of 15:40, 14 June 2018

Return to command list

searchSegment

searchSegment (string key, int cmd, string segment, int fuzzyThreshold, int timeout, boolean untranslatable, int penaltyCase, double penaltyTag, double penaltyNonLiteral, int penaltyAlign, int penaltyMT, int penaltyPublic, int penaltyPrivate, int penaltyMultiTrans, int penaltyAttribute, boolean custom1, boolean custom2, boolean custom3, boolean custom4)

Search a segment in the TM and return the list of found Translation Units in the Translation Memory, and if the joinTmGlo parameter of the Connect command is true, return also the list of terms found in the associated glossary.

Parameters

key string a valid API Key, generated by making a share at www.freetm.com
cmd int command number is 5
segment string source sentence to search in the TM
fuzzyThreshold int optional - percentage of similarity - default value is 70
timeout int optional - search timeout - default value is 5000 ms
untranslatable boolean optional - do not search small segment assumed untranslatable (return a build TU with an empty TM)- default value is false
penaltyCase int optional - case penalty - default value is 1
penaltyTag double optional - tag penalty - default value is 0.5 with sum of occurrences limited between 1 and 10
penaltyNonLiteral double optional - non literal penalty - default value is 0.5 with sum of occurrences limited between 1 and 10
penaltyAlign int optional - alignment penalty - default value is 3
penaltyMT int optional - Machine Translation penalty - default value is 15
penaltyPublic int optional - penalty for public TU - default value is 0
penaltyPrivate int optional - penalty for private TU - default value is 0
penaltyMultiTrans int optional - penalty for multiple full match translation - default value is 0
penaltyAttribute int optional - penalty for TU not having required attribute (custom1, 2, 3 or 4) - default value is 0
custom1 boolean optional - check custom1 attribute - default value is false
custom2 boolean optional - check custom2 attribute - default value is false
custom3 boolean optional - check custom3 attribute - default value is false
custom4 boolean optional - check custom4 attribute - default value is false

Returned value

tus array TU details
tmId int Translation Memory ID
tuId string Translation Unit ID - mandatory for deleteTu command
score string search score
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
terms array optional - Term details if the joinTmGlo parameter of the Connect command is true
gloId int glossary ID
termId string term ID - mandatory for deleteTerm command.
source string source term
target string target term
comment string first attribute
F1 string second attribute
F2 string third attribute
F3 string fourth attribute

Request example

json post with javascript

var data = {};
data["key"] = "example@key";
data["cmd"] = 5;
data["segment"] = "The brown fox is jumping over the lazy dog";
data["fuzzyThreshold"] = 70;
data["searchTimeout"] = 5000;
data["untranslatable"] = false;
data["penaltyCase"] = 1;
data["penaltyTag"] = 0.5;
data["penaltyNonLiteral"] = 0.5;
data["penaltyAlign"] = 3;
data["penaltyMT"] = 15;
data["penaltyPublic"] = 0;
data["penaltyPrivate"] = 0;
data["penaltyMultiTrans"] = 0;
data["penaltyAttribute"] = 1;
data["custom1"] = false;
data["custom2"] = false;
data["custom3"] = false;
data["custom4"] = false;
var xhr = new XMLHttpRequest();
xhr.open("POST", "www.freetm.com/wfa/api", true);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send(JSON.stringify(data));

post

<form action="www.freetm./wfa/api" method="post">
   Key: <input type="text" id="key" name="key" value="example@key"/>
   Command: <input type="text" id="cmd" name="cmd" value="5"/>	
   Segment: <textarea id="segment" name="segment" style="width: 500px; height: 60px;"/textarea>
   Fuzzy Threshold (optional): <input type="text" id="fuzzyThreshold" name="fuzzyThreshold" value="70" class="optional"/>
   Timeout (optional): <input type="text" id="searchTimeout" name="searchTimeout" value="5000" class="optional"/>
   Untranslatable (optional): <input type="checkbox" id="untranslatable" name="untranslatable" checked  class="optional"/>
   Penalty Case (optional): <input type="text" id="penaltyCase" name="penaltyCase" value="1" class="optional"/>
   Penalty Tag (optional): <input type="text" id="penaltyTag" name="penaltyTag" value="0.5" class="optional"/>
   Penalty Non Literal (optional): <input type="text" id="penaltyNonLiteral" name="penaltyNonLiteral" value="0.5" class="optional"/>
   Penalty Align (optional): <input type="text" id="penaltyAlign" name="penaltyAlign" value="3" class="optional"/>
   Penalty MT (optional): <input type="text" id="penaltyMT" name="penaltyMT" value="15" class="optional"/>
   Penalty Public (optional): <input type="text" id="penaltyPublic" name="penaltyPublic" value="0" class="optional"/>
   Penalty Private (optional): <input type="text" id="penaltyPrivate" name="penaltyPrivate" value="0" class="optional"/>
   Penalty MultiTrans (optional): <input type="text" id="penaltyMultiTrans" name="penaltyMultiTrans" value="0" class="optional"/>
   Penalty Attribute (optional): <input type="text" id="penaltyAttribute" name="penaltyAttribute" value="0" class="optional"/> 
   Custom1 (optional): <input type="checkbox" id="custom1" name="custom1" class="optional"/>
   Custom2 (optional): <input type="checkbox" id="custom2" name="custom2" class="optional"/>
   Custom3 (optional): <input type="checkbox" id="custom3" name="custom3" class="optional"/>
   Custom4 (optional): <input type="checkbox" id="custom4" name="custom4" class="optional"/>
   <input type="submit" value="Submit">
</form>

get

www.freetm.com/wfa/api?key=example@key&cmd=5&segment=the%20brown%20fox%20is%20jumping%20over%20the%lazy%dog

Response example

json

{ "tus": [    {
               "tmId": 1
               ,"tuId": "81444b70-5f70-11e4-aad0-5c514f6f39a2" 		 
		,"score": 100
		,"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": ""
	       }
	       ,{...}
  ]
  ,"terms": [{
              "gloId": 1
	        ,"termId": "88474b70-5f70-11e4-aad0-5c539f6f39a2"	 		 
		,"source": "fox"
		,"target": "renard"
		,"comment": ""
		,"F1": ""
		,"F2": ""
		,"F3": ""
	      }
	      ,{...}
  ]
}

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

text

1 tab 81444b70-5f70-11e4-aad0-5c514f6f39a2 tab 100 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
CR
1 tab 88474b70-5f70-11e4-aad0-5c539f6f39a2 tab fox tab renard 'tab tab tab tab LF

LF is Line Feed (\u000A)
CR is Carriage Return (\u000D)
tab is a tabulation (\u0009)

return 000 is nothing is found

Remarks