tgerbet / babelfish
一种文件编程语言检测器
0.1.0
2019-01-05 15:02 UTC
Requires
- php: ^7.2
Requires (Dev)
- doctrine/coding-standard: ^5.0
- phpunit/phpunit: ^7.3
- symfony/yaml: ^4.1
- vimeo/psalm: ^3.0
This package is auto-updated.
Last update: 2024-09-28 14:32:53 UTC
README
Babelfish 是一个基于 github/linguist 和 src-d/enry 的文件编程语言检测器。
示例
$source_file = new ContentFile('Babelfish.php', \file_get_contents(__DIR__ . '/src/Babelfish/Babelfish.php')); $language = Babelfish::getWithDefaultStrategies()->getLanguage($source_file); if ($language !== null) { echo 'Language detected: ' . $language->getName(); }
Babelfish 是如何工作的?
通过使用一系列有序的策略来确定语言。每个策略要么识别确切的编程语言,要么减少下一个策略可能语言的数目。默认的策略集包括:
另见 Linguist 是如何工作的。