1
0
Fork
You've already forked bool_hyperpolyglot_fork
0
No description
  • Rust 82.7%
  • RenderScript 17.2%
  • Just 0.1%
2025年11月12日 13:28:55 +01:00
benchmarks update benchmarks 2020年04月23日 08:00:30 -04:00
crates Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
linguist @f101af52dc Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
src Fixed docs unit tests by using corrent root crate 2025年11月12日 13:24:27 +01:00
testing Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
.gitignore add classifier function 2020年04月03日 20:35:55 -04:00
.gitmodules Added update to none to rust crates are not fetching submodules from linguist 2025年11月12日 13:04:53 +01:00
Cargo.lock Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
Cargo.toml Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
CHANGELOG.md Fixed docs unit tests by using corrent root crate 2025年11月12日 13:24:27 +01:00
justfile Added git submodule init command 2025年11月12日 13:28:55 +01:00
LICENSE-APACHE Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
LICENSE-MIT Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00
README.md Removed cli and some cli dependencies 2025年11月12日 12:53:02 +01:00

Fork of hyperpolyglot for application please_code_count

This is fork of the following crate. This fork serves for the language detection library of the following please_code_count.

Purpose

Hyperpolyglot is a fast programming language detector written in Rust based on Github's Linguist Ruby library. It is a library which can be used for detecting the programming language of a file or detecting the programming language makeup of a directory. For more details on how the language detection is done, see the Linguist README.

Using this Library

Adding as a dependency

[dependencies]
hyperpolyglot = "0.1.0"

Detect

usehyperpolyglot;letdetection=hyperpolyglot::detect(Path::new("src/bin/main.rs"));assert_eq!(Ok(Some(Detection::Heuristics("Rust"))),detection);

Breakdown

usehyperpolyglot::{get_language_breakdown};letbreakdown: HashMap<&'staticstr,Vec<(Detection,PathBuf)>>=get_language_breakdown("src/");println!("{:?}",breakdown.get("Rust"));

Divergences from Linguist

  • An additional heuristic was added for .h files.

  • Vim and Emacs modelines are not considered in the detection process.

  • Linguist has duplicate file name entries. Example: HOSTS/hosts as file name for INI files and hosts files. This crate prioritize one languages over the others in this case. Might come up with something better in the future.

Accuracy

All of the programming language detectors are far from perfect and hyperpolyglot is no exception. It's language detections mirror Linguist and enry for most files with the biggest divergences coming from files that need to fall back on the classifier.

Supported Languages

Supported languages are currently based on the tag v9.3.0 of the linguist repository.

Changeslog and Differences between this fork and the original hyperpolyglot

See this changelog

License

Licensed under either of

at your option.

Contribution

Setup

  • run just git_submodules

Additional used tools for development

How to update supported languages

  1. Go into git submodule of linguist and checkout a newer commit or more preferably the latest tag
  2. Run just codegen
  3. Make sure all test pass. Aka just test goes through without failed tests

Note about codegen

Git will likely show changed file under the directory no matter if the listed languages have changed. Reason: The code generation produces random ordering of keys and values of the pdf generated hash maps.

How is your contribution licensed

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.