Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Pseudocode for tag replacement in import call:

TAG_REPLACEMENT PSEUDO CODE

This is the pseudo code, that was used as a discussion base for finding the right algorithm for implementation. It was not exactly implemented like this, but it's logic should be valid and can be used to understand, what should be going on. PSEUDOCODE 
                    

Pseudocode for tag replacement in import call:

...

 !!!CONSIDER THAT WE SHOULD HAVE IN SOURCE SEGMENT ONLY 3 TYPES OF TAGS - PH_ELEMENT, BPT_ELEMENT and EPT_ELEMENT, because all of them was regenerated with their attributes at import stage
    At this point we read the source and target segments "as is", without any tag replacement in lists. so original_id would be id, that was generated_id at import stage. 
        
        SOURCE_SEGMENT{            
            <ph x="1" />{  
                search for matching tag in saved tags: 
                    looking in REQUEST_TAGS in REVERSE for matchingTag which have  
                                                                          matchingTag.generated_tagType == PH_ELEMENT //or our_tag.original_tagType
                                                                      AND matchingTag.generated_id  ==   our_tag.original_id
                                                                    ]
                if found
                    set our_tag.generated_tagType = matchingTag.original_tagType
                    set our_tag.generated_id = matchingTag.original_id
                    use that that data to generate tag like <our_tag.generated_tagType id="{our_tag.generated_id}" />                 
                else 
                    maybe just return <x/> tag? 
                        
                   save tag in SOURCE_TAGS
                
            }
            
            <bpt i="1" x="2"/> {
                search for matching tag in saved tags: 
                    looking in REQUEST_TAGS in REVERSE for matchingTag which have  
                                                                    [        matchingTag.generated_tagType == BPT_ELEMENT //or our_tag.original_tagType
                                                                      AND  matchingTag.generated_id  ==   our_tag.original_id
                                                                    ]
                if found
                    set our_tag.generated_tagType = matchingTag.original_tagType
                    set our_tag.generated_id = matchingTag.original_id
                    set our_tag.generated_i  = matchingTag.original_i
                    
                    if matchingTag.original_tagType == BX_ELEMENT // do BX_ELEMENT always have id and rid attributes provided?
                        use that that data to generate tag like <our_tag.generated_tagType id="{our_tag.generated_id}" rid="{our_tag.generated_id}" />
                    else: 
                        [rid="{our_tag.generated_id}"] - means optional, so for example if it's bigger than 0, then we should add this attribute
                        use that that data to generate tag like <our_tag.generated_tagType [id="{our_tag.generated_id}"] [rid="{our_tag.generated_id}"] >
                else 
                    maybe just return <bx/> tag? 
                        
                 save tag in SOURCE_TAGS              
            }
            
            <ept i="1" /> {
                search for matching tag in saved tags: 
                    looking in REQUEST_TAGS in REVERSE for matchingTag which have  
                                                                    [        matchingTag.generated_tagType == EPT_ELEMENT //or our_tag.original_tagType
                                                                      AND  matchingTag.generated_id  ==   our_tag.original_id  // id should hold information about paired BPT_ELEMENT, or it's absence
                                                                    ]
                if found
                    set our_tag.generated_tagType = matchingTag.original_tagType
                    set our_tag.generated_id = matchingTag.original_id
                    set our_tag.generated_i  = matchingTag.original_i
                    use that that data to generate tag like <our_tag.generated_tagType id="{our_tag.generated_id}" rid="{our_tag.generated_id}" />
                    
                    if matchingTag.original_tagType == EX_ELEMENT // do EX_ELEMENT always have id and rid attributes provided?
                        use that that data to generate tag like <our_tag.generated_tagType id="{our_tag.generated_id}" rid="{our_tag.generated_id}" />
                    else: 
                        [rid="{our_tag.generated_id}"] - means optional, so for example if it's bigger than 0, then we should add this attribute
                        use that that data to generate tag like </our_tag.generated_tagType>    
                else 
                    maybe just return <ex/> tag? or add some specific attributes?
                        
                 save tag in SOURCE_TAGS    
            }  
        }   

}                 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////NEW PSEUDO CODE//////////////////////////////////////////////////////////////////////////////////////////////////

NEW PSEUDO CODE

This is the code, actually implemented///////////////////////////////////////////////////////

Tag replacement feature implementation is splited into 2 functions: 
GenerateReplacingTag -     input  - tagType, attributeList
                        output - tagInfo
    this function would generate tagInfo data structure that saves original data(tagType, attributes(i\rid and x\id only) and would generate new data that suits context\segment 
PrintTag - input  - tagInfo
         - output - text representation of tag with attributes depending on context 
    this function would print tag with attributes(if they exist(bigger than 0). If it's fuzzy call, would replace for source and target segments tags with matching tags from fuzzy search request. 
        If matching tag not found - would generate new tag in xliff format with id or rid attributes that rising starting from biggest id and rid values +1 that was present in requested segment 
        for fuzzy search request segment this function would pring tag with generated data - that is never used in production, but can be used to find out how mechanism normalized input fuzzy search request segment
            (we base tag matching on this normalization.)

...