guillermobt / babelfish
一种文件编程语言检测器
dev-master
2023-03-19 11:11 UTC
Requires
- php: ^7.1
Requires (Dev)
- doctrine/coding-standard: ^8.0
- phpunit/phpunit: 7.5.20
- psalm/plugin-phpunit: ^0.5.5 || ^0.6.0 || ^0.7 || ^0.8 || ^0.9 || ^0.10 || ^0.11 || ^0.12
- symfony/yaml: ^4.1 || ^5.0
- vimeo/psalm: ^3.0
This package is auto-updated.
Last update: 2024-09-21 13:41:39 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 的工作原理。