GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Flight-School/Programming-Language-Classifier: An example of how to use CreateML in Xcode 10 to create a Core ML model for classifying text

This repository was archived by the owner on Nov 10, 2020. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
Classifier Demo.playground
Classifier Demo.playground
 
 
code-corpora @ 2317871
code-corpora @ 2317871
 
 
.gitmodules
.gitmodules
 
 
LICENSE.md
LICENSE.md
 
 
ProgrammingLanguageClassifier.mlmodel
ProgrammingLanguageClassifier.mlmodel
 
 
README.md
README.md
 
 
Trainer.swift
Trainer.swift
 
 

Repository files navigation

Programming Language Classifier

An example of how to use CreateML and Xcode 10 to train a CoreML model that is used by the Natural Language framework to classify the programming language of source code.

let code = """
struct Plane: Codable {
    var manufacturer: String
    var model: String
    var seats: Int
}
"""

let url = Bundle.main.url(forResource: "Classifier",
                          withExtension: "mlmodelc")!
let model = try! NLModel(contentsOf: url)
model.predictedLabel(for: code) // Swift

Requirements

  • macOS Mojave Beta
  • Xcode 10 Beta

These are available for Apple Developer account members to download at https://developer.apple.com/download/

Usage

This project includes a pre-trained programming language classifier model. To see it in action, open Classifier Demo.playground, run the playground with the Assistant editor showing the Live View, and then drag and drop a source code file. The model will predict the language of the file based on its contents.

Screenshot of Classifier Example

Training Instructions

  • Clone and setup the repository by running the following commands:
$ git clone https://github.com/flight-school/Programming-Language-Classifier.git`
$ cd Programming-Language-Classifier
$ git submodule update --init
  • Open Trainer.swift in an editor and fill in the placeholder values for destinationPath and corpusPath:
$ open ./Trainer.swift
  • Run Trainer.swift and wait for the model to be trained (on a 2017 MacBook Pro, this took a few minutes):
$ swift ./Trainer.swift
  • Compile the generated .mlmodel bundle using the following command:
$ xcrun coremlc compile path/to/ProgrammingLanguageClassifier.mlmodel .
  • Move the compiled .mlmodelc bundle into the Resources directory of Classifier Demo.playground, replacing any existing resource.

License

MIT

See code-corpora for licensing information of the included projects.

About Flight School

Flight School is a new book series for Swift developers. Each month, we'll explore an essential part of iOS, macOS, and Swift development through concise, focused books.

If you'd like to get in touch, feel free to message us on Twitter (@flightdotschool) or email us at mailto:[email protected].

About

An example of how to use CreateML in Xcode 10 to create a Core ML model for classifying text

flight.school/articles/classifying-programming-languages-with-createml/

Topics

classifiercoremlcreatemlnatural-languageswiftxcode10

Resources

Readme
MIT license

Security policy

Security policy
Activity
Custom properties

Stars

179 stars

Watchers

0 watching

Forks

12 forks
Report repository

Releases

Sponsor this project

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.