0
私はこのコードを文章に使用しています。コードはjavaで利用できます。これはC#で使用します。私はC#の でこのコードを実行するC言語でJavaコードを変換する#
public static int getWordChanges(String s1, String s2) {
int similarityThreshold = 50;
int wordChanges = 0;
s1 = s1.toLowerCase().replace(".", "").replace(",", "").replace(";", "");
s2 = s2.toLowerCase().replace(".", "").replace(",", "").replace(";", "");
//Loop through each word in s1
for (int i = 0; i < s1.split(" ").length; i++) {
boolean exists = false;
//Search for i'th word in s1 in s2
for (int j = 0; j < s2.split(" ").length; j++) {
//Is the word misspelled?
if ((getLevenshteinDistance(s1.split(" ")[i], s2.split(" ")[j]) * 100/s1.split(" ")[i].length()) < similarityThreshold) {
exists = true;
break;
}
}
//If the word does not exist, increment wordChanges
if (!exists) {
wordChanges++;
}
}
return wordChanges;
}
これは、Javaコードで長エラーの後
public int getWordChanges(String s1, String s2)
{
int similarityThreshold = 50;
int wordChanges = 0;
s1 = s1.ToLower().Replace(".", "").Replace(",", "").Replace(";", "");
s2 = s2.ToLower().Replace(".", "").Replace(",", "").Replace(";", "");
//Loop through each word in s1
for (int i = 0; i < s1.Split(' ').Length; i++)
{
bool exists = false;
//Search for i'th word in s1 in s2
for (int j = 0; j < s2.Split(' ').Length; j++)
{
//Is the word misspelled?
if ((getLevenshteinDistance(s1.Split(' ')[i], s2.Split(' ')[j]) * 100/s1.Split(' ')[i].Length()) < similarityThreshold)
{
exists = true;
break;
}
}
//If the word does not exist, increment wordChanges
if (!exists)
{
wordChanges++;
}
}
return wordChanges;
}
}
}
C#でコードを変換エラーがこのラインであり
if ((getLevenshteinDistance(s1.Split(' ')[i], s2.Split(' ')[j]) * 100/s1.Split(' ')[i].Length()) < similarityThreshold)
がしますどのように私はこの1つを解決するかを示す
長さなので
.Length() to .Length
を変更するには、プロパティ、ではない方法です。それを '.Length() 'の代わりに' .Length'に変更してください。 – Rob