Community

JSON function not in Jscript on Flexicapture 11 Answered

Does anyone have a suggestion for adding or making a JSON function for Flexicapture 11.  We're using an API to name correct in Python and returning that data works well.  But parsing it is not working because the JSON function is not there. 

0

Comments

3 comments

  • Avatar
    Andrew Rhyne

    I got this working, it is really interesting. I need to find some old books on Jscript IE browser methods. That would seem to be the best scripting reference.  The JScript version on FC11 is not used by any web development and Javascript overwhelms all search returns, so when trying to find references online it is challenging. After an hour or so of reading on this history of JSON I found the method to use. See below. 

    http://www.jibbering.com/2002/4/httprequest.html

     var JSON = new Function("return "+xmlhttp.responseText)();  

     

     

    var search_name = this.Field("Name").Text;
    var url = 'http://yourapiserver/key&s='+search_name;
    var xhr = new ActiveXObject("MSXML2.XMLHTTP.6.0");
    xhr.open("GET",url,false);
    xhr.send(null);
    var data =  xhr.responseText;
    var JSON = new Function("return "+data)();
    
    //you can parse the var JSON using standard parsing.


    Why spend the time on this?

    Using GET to is a very powerful tool for integrating an API into FC.   I have been using FC for about 8 years or so. We have always scripted spell correcting because the database lookup tools in the box are very weak.  It is very bulky and slow to script in FC for this type of task.  

    Python has wonderful NL algorithms and using an API allows us to custom build a spell corrector in a language that is very commonly used for data processing and does not run a lot of overhead on the system. 


    If you process a lot of invoices and have descriptions, company names, etc or other data you want to verify and correct, this is a very power method. 

     

     

     

    0
  • Avatar
    Ekaterina

    Hello Andrew,

    Thank you for the provided information! We'll address it for the attention of the ABBYY HQ, as it seems to be a good feature request.

    0
  • Avatar
    Andrew Rhyne

    Ekaterina,

    I have been working for years to find better spell correctors.  I'd love to of assistance.  Most of the matching algorithms are pretty simple to program or there are libraries.  

    Levenshtein distance has been extremely helpful to us.  https://en.wikipedia.org/wiki/Levenshtein_distance 

    If you think about it, one of the biggest time syncs with validation is correcting small OCR errors and also spelling variations. I'd be happy to share my past 8 years of experience matching messy data. 

    0

Please sign in to leave a comment.