top of page

Levenshtein Solution 4 source code 

 

public class solution {

 

                public static void main(String[] args) {

                                if (args.length != 2) {

                                                // use standard data

                                                args = new String[] { "Tuesday", "Workday" };

                                }

                                args[0] = " " + args[0];

                                args[1] = " " + args[1];

                                int n = args[0].length();

                                int m = args[1].length();

 

                                Integer leven[][] = new Integer[n][m];

 

                                // init first row and column

                                for (int i = 0; i < n; i++) {

                                                leven[i][0] = i;

                                }

                                for (int i = 0; i < m; i++) {

                                                leven[0][i] = i;

                                }

 

                                // calc other pos

                                for (int i = 1; i < n; i++) {

                                                for (int j = 1; j < m; j++) {

                                                                int a = leven[i - 1][j] + 1;

                                                                int b = leven[i][j - 1] + 1;

                                                                int c = leven[i - 1][j - 1];

                                                                if (args[0].charAt(i) != args[1].charAt(j)) {

                                                                                c++;

                                                                }

 

                                                                leven[i][j] = Math.min(Math.min(a, b), c);

                                                }

                                }

 

                                // print mat

                                System.out.print("\t");

                                for (int i = 0; i < n; i++) {

                                                System.out.print(args[0].charAt(i) + "\t");

                                }

                                System.out.println();

 

                                for (int j = 0; j < m; j++) {

                                                System.out.print(args[1].charAt(j) + "\t");

                                                for (int i = 0; i < n; i++) {

                                                                System.out.print(leven[i][j] + "\t");

                                                }

                                                System.out.println();

                                }

                }

 

}

 

Annotation in text format

 

File Name >> solution9.java

File Creation data >> 1425000729074

Java Classes --> solution

Method Name --> main

Method return type --> void

 

Annotation in RDF format

 

<rdf:RDF

    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

    xmlns:SEO="http://www.seontology.org/activeseo/seo/v1#"

    xmlns:DC="http://purl.org/dc/dcmitype/"

    xmlns:foaf="http://xmlns.com/foaf/0.1/">

  <DC:Software rdf:about="http://www.seontology.org/activeseo/seoanno/data/main/Parameter_1">

    <SEO:isParamArray>true</SEO:isParamArray>

    <SEO:paramType>java.lang.String</SEO:paramType>

    <SEO:paramName>args</SEO:paramName>

    <SEO:paramSeq>1</SEO:paramSeq>

    <foaf:name>args</foaf:name>

    <rdf:type rdf:resource="http://www.seontology.org/activeseo/seo/v1#PARAMETER"/>

  </DC:Software>

  <SEO:METHOD rdf:about="http://www.seontology.org/activeseo/seoanno/data/main">

    <SEO:methodHasParam rdf:resource="http://www.seontology.org/activeseo/seoanno/data/main/Parameter_1"/>

    <SEO:hasStaticModifier>true</SEO:hasStaticModifier>

    <SEO:hasAccessModifier rdf:resource="http://www.seontology.org/activeseo/seo/v1#Public"/>

    <foaf:name>main</foaf:name>

    <SEO:methodDeclarationSignature>void main(java.lang.String[] args)</SEO:methodDeclarationSignature>

    <rdf:type rdf:resource="http://purl.org/dc/dcmitype/Software"/>

    <SEO:returnType>void</SEO:returnType>

    <SEO:methodName>main</SEO:methodName>

    <SEO:isReturnPrimitive>true</SEO:isReturnPrimitive>

    <SEO:methodCallSignature>main(args)</SEO:methodCallSignature>

  </SEO:METHOD>

  <DC:Software rdf:about="http://www.seontology.org/activeseo/seoanno/data/solution">

    <SEO:hasMethod rdf:resource="http://www.seontology.org/activeseo/seoanno/data/main"/>

    <SEO:hasAccessModifier rdf:resource="http://www.seontology.org/activeseo/seo/v1#Public"/>

    <foaf:name>solution</foaf:name>

    <rdf:type rdf:resource="http://www.seontology.org/activeseo/seo/v1#CLASS"/>

  </DC:Software>

</rdf:RDF>

 

Annotation in graph format

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

bottom of page