Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

python - 根据先前定义的类型确定代码模式块的类型(Determining the type of code pattern block from previously defined types)

I need an example of a machine learning algorithm to find previously defined patterns of code block structures.

(我需要一个机器学习算法的示例来查找先前定义的代码块结构模式。)

That is, it is important that the algorithm can determine by structure which pattern the code block belongs to.

(即,重要的是算法可以通过结构确定代码块属于哪种模式。)

For example, we will teach the algorithm the pattern defined below:

(例如,我们将教算法以下定义的模式:)

void foo(String text) {
    foo(text, true);
}
void foo(String text, boolean isSelected) {
    // some code
}

And give this pattern a name.

(并为该模式命名。)

Now the pattern below should be determined by the algorithm as above, because they are of the same structure.

(现在,以下模式应该由上述算法确定,因为它们的结构相同。)

void someFunction(String entered) {
    someFunction(entered, true);
}
void someFunction(String entered, boolean bool) {
    if (bool) {
        print("entered");
    } else {
        print("");
    }
}

You can also feed the algorithm below loops and subsequently it should recognize loops in which we use (++{counter}).

(您还可以在循环下面提供算法,随后它应该识别我们使用的循环(++ {counter})。)

for (int i = 1; i <= rows; ++i) {
   // some code
}

for (int test = 1; test <= size; ++test) {
   // code
}

for (int count = 1; count <= size; ++count) {
   println("Hello " + count);
}

I tried to find something similar to make at least a simple implementation.

(我试图找到类似的东西,至少可以使之简单。)

On the site ( https://scikit-learn.org/stable/ ), the most suitable sections seemed to me classification and preprocessing.

(在该网站( https://scikit-learn.org/stable/ )上,最合适的部分在我看来是分类和预处理。)

But the examples seemed to me not suitable or unnecessarily complicated for me ..

(但是这些例子对我来说似乎不合适或不必要。)

I also saw that tensorflow is often used for similar tasks, the machine learning code for google collab is quite easy to use in this regard.

(我还看到tensorflow通常用于类似的任务,在这方面,google collab的机器学习代码非常容易使用。)

Maybe I should define patterns using algorithms that recognize blocks of text that include spam, but they do a search based on similar words, not a structure.

(也许我应该使用识别包括垃圾邮件的文本块的算法来定义模式,但是它们基于相似的单词而不是结构进行搜索。)

I would be very grateful if you tell me how to solve this problem!

(如果您告诉我如何解决此问题,我将不胜感激!)

  ask by Quateron translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...