Calculate similarity between 2 strings

Hello,
In my search help, I need to rank my result according to the similarity of my input parameter.
Ex : Input parameter = TOTO
My result :
1- TOTO
2- TOT
3- TOTO NEW
Do you know a function or a method to calculate the similarity between 2 strings?
I implemented this levenshtein algo [http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#Abap] but, the result is not appropriate.
Thanks in advance.
Best regards,
Xavier.

distance - Similarity Function finally arrived with release 7.02 . Please refer to http://help.sap.com/abapdocu_702/en/abendistance_functions.htm

Similar Messages

  • How to calculate hours between two dateTime node in BPEL.

    In my BPEL there's a requirement need calculate hours between two dateTime type..
    I tried 2 solutions, both of them failed:
    1. use xslt calculate duration(xml type, like PT12H) between two dateTime, and then use embedded java code to get the hours.. The problem is : I need to parse the xml duration format...(like this real one: -P80DT17H47M36S....), and to parse it in java , maybe have the same problem with solution 2..
    * [Subtracting 2 dateTime values into a duration using XPath 2.0|http://blogs.oracle.com/rammenon/2007/07/subtracting_2_datetime_values.html]
    2. use embed java code, but it seems we can't use some class in embedded java code:
    my code(input begin, end both dateTime in xml. output: diff, int in xml):
    1 System.out.println("\n\nTimeTestBegin");
    2 String begin=getVariableData("begin").toString();
    3 String end=getVariableData("end").toString();
    4 System.out.println(begin+"-----"+end);
    5 //Class c1=Class.forName("javax.xml.datatype.XMLGregorianCalendar");
    6 //Class c2=Class.forName("javax.xml.datatype.DatatypeFactory");
    7 //System.out.println(c1.getName());
    8 //System.out.println(c2.getName());
    9 javax.xml.datatype.XMLGregorianCalendar beginTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(begin);
    10 javax.xml.datatype.XMLGregorianCalendar endTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(end);
    11 long diff=beginTime.toGregorianCalendar().getTimeInMillis()-endTime.toGregorianCalendar().getTimeInMillis();
    12 setVariableData("diff",String.valueOf(diff/1000/3600));
    13 System.out.println("DIFF======"+diff/1000/3600);
    14 System.out.println("TimeTestEnd");
    it's said can't compile java class, but can't find the detail error, I think the problem is how to import java class to embedded java code activity(use full package name like above code don't work), when I remove line 9-13, no compile error..
    BTY: Jdeveloper is a IDE support java, but why the embedded java activity's edit window only have a simple "java code" editor, too simple that it can only edit you code snippet...
    3.There's another sulotion: extend BPEL xpath functions(add a new function), but in my project, modify BPEL server(soa server)'s config file is not allowed..
    Anyone know easy solution to my problem?
    Thanks.

    Hi, All,
    I found the cause. Sorry, it's my mistake..
    below line have a DatatypeConfigurationException:
    javax.xml.datatype.DatatypeFactory.newInstance()
    When I test my java code snippet, I coped the code snippet to one of my java class in eclipse, and put it in a method to check if there's compile error, but I didn't notice there's a "throws Exception"...
    the final java code snippet for test is :
    input: begin dateTime
    input: end dateTime
    output: diff int, how many hours in (begin-end)
    try{
    System.out.println("\n\nTimeTestBegin");
    String begin=getVariableData("begin").toString();
    String end=getVariableData("end").toString();
    System.out.println(begin+"-----"+end);
    javax.xml.datatype.XMLGregorianCalendar beginTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(begin);
    javax.xml.datatype.XMLGregorianCalendar endTime = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(end);
    long diff=beginTime.toGregorianCalendar().getTimeInMillis()-endTime.toGregorianCalendar().getTimeInMillis();
    setVariableData("diff",String.valueOf(diff/1000/3600));
    System.out.println("DIFF======"+diff/1000/3600);
    System.out.println("TimeTestEnd");
    }catch(Exception e){
    e.printStackTrace();
    }

  • Need Help to calculate difference between times

    Hello everyone,
    I have two fields which just stores the time in 24 hour format ex: 08:00 and 20:00 now I want to calculate difference between the two times
    Kindle help me
    Thanks for your help
    Thanks
    Ravi

    Are your fields of varchar2 datatype or...?
    Is 08:00 the start time or 20:00?
    Date arithmetic is pretty simple in Oracle if you use the right datatype.
    See:
    http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
    Assuming you are storing strings:
    SQL> -- generating sample data:
    SQL> with t as (
      2  select '08:00' btime, '20:00' etime from dual
      3  )
      4  --
      5  -- actual query:
      6  --
      7  select numtodsinterval(to_date(etime, 'hh24:mi') - to_date(btime, 'hh24:mi'), 'day') nti
      8  ,      (to_date(etime, 'hh24:mi') - to_date(btime, 'hh24:mi'))*24 dt
      9  from   t;
    NTI                                                                                 DT
    +000000000 12:00:00.000000000                                                       12
    1 row selected.
    SQL>

  • What's the difference between String() - as String - toString();

    Hello,
    I'm wondering what's the difference between this 3 ways of getting around.

    There is a great difference between String(), as String and toString() methods.
    String(param) -- the more general and safe method.
    Returns "null" (string!) if param is null;
    Returns result of param.toString() method if it is defined in class;
    Returns string representation of the param (returns "[object Object]" if param is Object);
    param asString --
    Returns string if param is a type of String;
    Returns null otherway (if param is custom class, int or other type);
    param.toString() -- call of toString() member function
    throws an exception if param is null;
    compile-time error if toString() method is not defined in param (if your custom class do not have or inherits this function);
    returns result of toString() function
    Exists also ""+param and param+"" ways. They are similar to ""+String(param) and String(param)+""
    Pay attention:
    var ss:String = null;
    trace(String(ss)==(ss as String)); // Returns false as "null" not equal to null

  • What is the difference between string != null and null !=string ?

    Hi,
    what is the difference between string != null and null != string ?
    which is the best option ?
    Thanks
    user8729783

    Like you've presented it, nothing.  There is no difference and neither is the "better option".

  • What is the difference between String Constant and Empty String Constant

    What is the difference between string constant which does not contain any value and the Empty string constant?
    While testing a VI which contain a normal string constant in VI analyzer, it gives error to change string constant with the empty string constant?
    Please Reply
    prabhakant
    Regards
    Prabhakant Patil

    Readability.
    Functionally, they are the same. From a coding standpoint, the Empty String Constant is unambiguous.
    It is empty and will always be; good for initialization. Also, because you can not type a value into and Empty String Constant, someone would need to conciously replace it to set a 'default' value that is something other than NULL.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Difference between String and final String

    Hi friends,
    This is Ramana. Can u suggest me in this Question
    What is the difference between String and final String? Means
    String str="hai";
    final String str="hai";
    Regards,
    Ramana.

    *******REPEAT POST***********
    We already answered your question why post in a different section?
    http://forum.java.sun.com/thread.jspa?threadID=5201549

  • Calculate distance between Latitude and Longitude

    Hi All,
    I have one Latitude and Longitude points. I need to calculate distance between them.
    Right now we are using HAVERSINE formula but the query takes longer time to complete.
    Reference: http://www.movable-type.co.uk/scripts/latlong.html
    Please assist on this.
    Thanks in advance.

    Check this link...
    http://www.mrexcel.com/forum/excel-questions/202255-calculating-distance-between-two-latitude-longitude-points.html
    I never did this before, but gave it a try using the formula mentioned in that link..
    Data:
                       Lat                      Long                               R =  6,371 (Radius of earth (approximated)) 
    Origin:        44.844263(B2)      -92.914803(C2) 
    Destination: 44.822075(B3)     -92.912498(C3)
    Formula used:
    A: =SIN(ABS(B3-B2)*PI()/180/2)^2+COS(B2*PI()/180)*COS(B3*PI()/180)*SIN(ABS(C3-C2)*PI()/180/2)^2
    B: =2*ATAN2(SQRT(1-A),SQRT(A))
    C: =R*B                  --->  DISTANCE!!!!
    WITH t AS
            (SELECT POWER (
                       SIN (ABS (44.822075 - 44.844263) * ( (22 / 7) / 180 / 2)),
                       2)
                    + COS (44.844263 * ( (22 / 7) / 180))
                      * COS (44.822075 * ( (22 / 7) / 180))
                      * POWER (
                           SIN (
                              ABS (-92.912498 - (-92.914803))
                              * ( (22 / 7) / 180 / 2)),
                           2)
                       E2
               FROM DUAL)
    SELECT (2 * ATAN2 (SQRT ( (1 - E2)), SQRT (E2))) * 6371
      FROM t;
    Check if this gives correct values... (I did not verify this properly.. ) And this is faster in my opinion..
    Please post your code for better suggestions from volunteers...
    Cheers,
    Manik.

  • How to calculate days between 2 dates excluding public holidays over SAP ?

    Hi
    Have a universe over SAP data. Trying to calculate days between 2 dates. SAP holds Public Holiday data in various tables e.g  Thol and data is updated via scal. Using my univeres as a source I want to run  reports for different countries so need to have various bank holidays not just UK. In SAP function modules handle this. Has anyone designed a solution to cater for this situation in a universe ?
    Thanks in advance
    M

    Hi,
    I assume you mean SAP R/3 (ECC) when you write SAP and SAP BW.
    Are you using BW? If so, I would load the data into SAP BW, create a query using customer exit variables and build your universe on top of that...
    -J

  • How to calculate difference between date in hours?

    Hi All.
    I need calculate difference between first and last date. I'm using the code below:
    int differenceDate = CalendarRule.elapsedDays(fromDate : myFirstDate, toDate : myLastDate);
    This code return an result in days. But I need that result was in hours.
    Has anybody help me?

    Interval dif;
    dif = myLastDate - myfirstDate;
    display((dif.hours));
    Hope it helps

  • Adding white spaces between strings during concatenation in JSTL

    Please provide a way to add white space between strings during concatenation in JSTL.
    I tried the following.
    eg:
    <c:set var="even_odd" value="odd">
    <c:out value="first ${even_odd}"/>
    I want the output string as "first odd ".
    Moreover i am using the above value for generating the class attribute of a row of a table like
    <tr class=<c:out value="first ${even_odd}"/>>
    while printing the value of <c:out value="first ${even_odd}"/> in the page,i am getting correctly as i needed as "first odd".
    But while taking the code of the page while rendering by the browser, it is showing like
    <tr class="first" odd="">
    I think the white space is the problem.
    Please provide any solution or hint.

    <tr class=<c:out value="first ${even_odd}"/>><tr class="first ${even_odd}">

  • Is there any Similar between Class.forName() and new operator ???

    Plz tel me is there any Similar between Class.forName() and new operator ??? i have been asked this ques in interview

    You probably should have used the other thread:
    http://forum.java.sun.com/thread.jspa?threadID=792678
    To add a little confusion to the matter...Class objects are in fact objects. They're objects representing classes. So, in a sense, I guess, you could say they're similar -- in each you get an object. But in practice Class objects and all other objects should be considered semantically different unless you're doing some pretty unusual stuff. Also Class.forName is more of a factory method than a constructor.

  • What Are the Differences Between String and StringBuffer?

    Both String and StringBuffer are final classes. StringBuffer grows in size dynamically. Could people help to detail other differences between String and StringBuffer?

    String is immutable. In other words, once it is made, the contents of that instance of String cannot be changed (easily). The size and characters cannot be changed, and code can take advantage of this fact to optimize space. Also, once you have a reference to a string, you do not need to worry about it changing at all, so you can eliminate constant tests to verify things such as size in another class that may want to hold onto the string.
    StringBuffer, as you noticed, can change dynamically. While this provides flexibility, it cannot be optimized and assumptions cannot be made as with strings. If a class holds a reference to a StringBuffer that it does not own, there is a possibility that it may change things such as size when the class tries to use it later. StringBuffer is also less efficient in handling space then an equivalent String. The character array to hold a String is exactly the length to hold all the characters. StringBuffer, on the other hand, adds a 16 character buffer of array space for possible expansions. Also, the size of the internal array doubles when its internal capacity is exceeded. So, unless you explicitly maintain the size, a StringBuffer will take up more memory then an equivalent String, and if your program needs thousands of instances of Strings (which is not uncommon), that space can add up.
    I hope this helps clarify some things for you.
    -JBoeing

  • Difference and similarity between SAP XI and MQ?

    Hi All,
    Difference and similarity between SAP XI and MQ?
    Pleas send docs if anybody has.
    Regards

    May be both has 2 letters!! XI, MQ.
    On a serious note, you cant compare a middleware with a Queue.

  • How to check similarity between two Databases 9i & 10g after imp in 10g

    Dear all,
    Source
    =======
    OS server     ==>     HP-UX
    Oracle version     ==>     Oracle 9.2.0.8
    DB Name          ==>     MSST
    DB total users     ==>     320
    Full export in     ==>     /u02/export/Jan09.dmp
    Tablespaces     ==>     SC, SC_I, SA, SA_I, PP, PP_I, AC, AC_I, SD
    Destination
    ============
    OS server          ==>     HP-UX
    DB Name               ==>     CHDB
    Existg DB users          ==>     20
    Oracle version          ==>     Oracle 10.2.0.4
    copied 9i dump file in     ==>     /u03/export
    Tablespaces created same as Oracle 9i i.e;          
    Tablespaces     ==>     SC, SC_I, SA, SA_I, PP, PP_I, AC, AC_I, SD
    I had run full import on Destination server i.e; Oracle 10g & following is the command i used:
    imp system/pwd@conn_string file=/u03/export/Jan09.dmp log=/u03/export/Jan09_imp.log full=y ignore=y statistics=none
    *=== Imported successfully with few errors like ====*
    IMP-00017: following statement failed with ORACLE error 2299:
    "ALTER TABLE "EMP_PROMOTIONS_ORD" ADD CONSTRAINT "EMP_PROMOTIONS_ORD_UK" UN"
    "IQUE ("EMP_NO", "RANK_NO_FOLLOW") USING INDEX PCTFREE 10 INITRANS 2 MAXTRAN"
    "S 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "PP" "
    "LOGGING ENABLE "
    IMP-00003: ORACLE error 2299 encountered
    ORA-02299: cannot validate (PP.EMP_PROMOTIONS_ORD_UK) - duplicate keys found
    ORA-02299: cannot validate (PP.EMP_PROMOTIONS_ORD_UK) - duplicate keys found
    . . importing table "EMP_PROMOTION_DETAILS" 13333 rows imported
    . . importing table "EMP_PROMOTION_MAST" 725 rows imported
    . . importing table "EMP_PUNISHMENT" 271 rows imported
    . . importing table "EMP_REPORT_BOOKS" 60528 rows imported
    . . importing table "EMP_SALARY_HISTORIES" 120871 rows imported
    . . importing table "EMP_SALARY_HISTORIES_TEMP" 77044 rows imported
    . . importing table "EMP_TRANSACTIONS" 96536 rows imported
    IMP-00017: following statement failed with ORACLE error 2299:
    "ALTER TABLE "EMP_TRANSACTIONS" ADD CONSTRAINT "TRANS_UK" UNIQUE ("EMP_NO","
    " "DIR_NO", "DIR_DATE", "TRN_CODE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRA"
    "NS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "PP_"
    "I" NOLOGGING ENABLE "
    IMP-00003: ORACLE error 2299 encountered
    ORA-02299: cannot validate (PP.TRANS_UK) - duplicate keys found
    Now my question is
    ===================
    How to check everything is same/similar like Oracle 9i database ( source ), for example ( i used this technique ):
    Can anyone tell me how to check similarity between two Databases 9i & 10g after import in 10g.
    MSST_DB>SHOW USER
    MSST_DB>SA
    MSST_DB>select object_type, count(*) from user_objects group by objects;
    OBJECT_TYPE     COUNT(*)
    DATABASE LINK     2
    FUNCTION     23
    INDEX          1795
    LOB          6
    PACKAGE          8
    PACKAGE BODY     8
    PROCEDURE     30
    SEQUENCE     67
    SYNONYM          60
    TABLE          644
    TRIGGER          3
    VIEW          20
    CHDB_DB>SHOW USER
    CHDB_DB>SA
    CHDB_DB>select object_type, count(*) from user_objects group by objects;
    OBJECT_TYPE     COUNT(*)
    INDEX          1794
    PROCEDURE     30
    TABLE          644
    TRIGGER          3
    VIEW          20
    FUNCTION     23
    SYNONYM          60
    PACKAGE BODY     8
    SEQUENCE     67
    PACKAGE          8
    LOB          6
    Edited by: VIKHARAHMED on Jan 10, 2012 3:02 AM

    [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_export.htm#sthref67]Guide.

Maybe you are looking for

  • ITunes 10 Not Working Properly on Windows 7 64-bit

    Hello all. I had installed iTunes 10 for Windows 7 64-bit on my Windows 7 64-bit system. After that, my computer would not recognize my iPhone at all, so I uninstalled everything Apple on my computer and reinstalled iTunes 10. Now after reinstallatio

  • ABAP Help: Dynamic Selection Screen

    Hi, I have a requirement to be able to pick the list of fields in a selection screen. (List processing) Similar to SE16 choosing "fields for selection". I've debugged SE16 and realized it deletes the report and regenerates a new report with the updat

  • The most difficult part in AP Payment

    Hello everyone Could you please share what is the most difficult part for AP payment in your opinion? As I am studying about it and I have no idea where to start. Please let's share your experience.

  • How do I convert a 25fps shot film into a 1920x1080px@50fps quicktime/photojpeg or h.264

    Hello, I shot a film with a canon 5d mark II (25fps) and cut it on Final Cut Pro. Now I've been told, they need 920x1080px@50fps as quicktime/photojpeg or h.264 with high Bitrate. How do I convert my video into that using either Final Cut or Compress

  • CC window pops up when switching desktops in Mac OS X 10.8.4

    I have just updated all my apps to CC. Everything looks fine so far. The only glaring annoyance I see is that the CC window pops up when switching desktops in Mission Control. I normally work with four to five desktops and switch frequently between t