"ProgrammingLanguage" (Built-in Classifier)
-
See Also
- Classify
- TextCases
- Import
-
- Interpreter Types
- ComputedProgrammingLanguage
-
- Classifiers
- Language
- FacebookTopic
- Sentiment
- Related Guides
-
-
See Also
- Classify
- TextCases
- Import
-
- Interpreter Types
- ComputedProgrammingLanguage
-
- Classifiers
- Language
- FacebookTopic
- Sentiment
- Related Guides
-
See Also
"ProgrammingLanguage" (Built-in Classifier)
Recognize the programming language of a code snippet.
Classes
Examples
open all close allBasic Examples (2)
Determine the language of a given code:
Classify["ProgrammingLanguage",
"int main()
{
const char *p = \"Hello\";
while(*p++)
printf(\"%c\",*p);
return 0;
}"]Obtain the probabilities for the most likely classes:
Classify["ProgrammingLanguage", "/^.?$|^(..+?)\\1+$/", "TopProbabilities"]Obtain a ClassifierFunction for this classifier:
c = Classify["ProgrammingLanguage"]Apply the classifier to a code snippet:
c["def insert(self,k):
self.heapList.append(k)
self.currentSize = self.currentSize + 1
self.percUp(self.currentSize)"]Scope (1)
Load the ClassifierFunction corresponding to the built-in classifier:
c = Classify["ProgrammingLanguage"]Information[c, "Classes"]Options (2)
ClassPriors (1)
Use a custom ClassPriors to restrict the possible outputs:
Classify["ProgrammingLanguage",
"TrieNode *newNode()
{
TrieNode *temp = new TrieNode;
temp->value = 0;
temp->arr[0] = temp->arr[1] = NULL;
return temp;
}", ClassPriors -> <| Entity["ProgrammingLanguage", "C::p5vhv"] -> 0.25, Entity["ProgrammingLanguage", "C::5zm8v"] -> 0.25, Entity["ProgrammingLanguage", "C::y7pg6"] -> 0.5|>]IndeterminateThreshold (1)
Use a custom IndeterminateThreshold:
Classify["ProgrammingLanguage", "TrieNode *newNode()", IndeterminateThreshold -> 0.6]Neat Examples (1)
Obtain different possible languages with their corresponding probabilities:
possiblelanguages = Classify["ProgrammingLanguage",
"/^.?$|^(..+?)\\1+$/", "Probabilities"];Visualize the result using WordCloud:
WordCloud[possiblelanguages]See Also
Interpreter Types: ComputedProgrammingLanguage
Classifiers: Language FacebookTopic Sentiment
Related Guides
History
Introduced in 2018 (11.3)