Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

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

License

NotificationsYou must be signed in to change notification settings

Flight-School/Programming-Language-Classifier

Repository files navigation

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

letcode="""struct Plane: Codable {    var manufacturer: String    var model: String    var seats: Int}"""leturl=Bundle.main.url(forResource:"Classifier",                          withExtension:"mlmodelc")!letmodel=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 downloadathttps://developer.apple.com/download/

Usage

This project includes a pre-trained programming language classifier model.To see it in action, openClassifier 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
  • OpenTrainer.swift in an editor and fill in the placeholder valuesfordestinationPath andcorpusPath:
$ open ./Trainer.swift
  • RunTrainer.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 directoryofClassifier Demo.playground, replacing any existing resource.

License

MIT

Seecode-corporafor 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 ofiOS, 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 atmailto:info@flight.school.

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

    Packages

    No packages published

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp