{"id":18556587,"url":"https://github.com/valkryst/vcodelanguagedetection","last_synced_at":"2025-11-01T10:30:30.366Z","repository":{"id":158170476,"uuid":"624535004","full_name":"Valkryst/VCodeLanguageDetection","owner":"Valkryst","description":"A lightweight Java library for automatic code language detection of an input text.","archived":false,"fork":false,"pushed_at":"2025-01-03T21:45:19.000Z","size":89,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T22:28:11.441Z","etag":null,"topics":["detection","hacktoberfest","language","language-detection","programming-language-detector","syntax-analysis"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Valkryst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Valkryst"}},"created_at":"2023-04-06T17:28:05.000Z","updated_at":"2025-01-03T21:45:16.000Z","dependencies_parsed_at":"2023-09-27T19:53:14.658Z","dependency_job_id":"1864d00d-bbb0-4393-ac1b-ecf4703a0560","html_url":"https://github.com/Valkryst/VCodeLanguageDetection","commit_stats":{"total_commits":90,"total_committers":2,"mean_commits":45.0,"dds":0.4666666666666667,"last_synced_commit":"15ac5308ef856b84d0f410f6d6225fcde66c3565"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Valkryst%2FVCodeLanguageDetection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Valkryst%2FVCodeLanguageDetection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Valkryst%2FVCodeLanguageDetection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Valkryst%2FVCodeLanguageDetection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Valkryst","download_url":"https://codeload.github.com/Valkryst/VCodeLanguageDetection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239281297,"owners_count":19612841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["detection","hacktoberfest","language","language-detection","programming-language-detector","syntax-analysis"],"created_at":"2024-11-06T21:32:01.473Z","updated_at":"2025-11-01T10:30:30.311Z","avatar_url":"https://github.com/Valkryst.png","language":"Java","readme":"[![Java CI with Maven](https://github.com/Valkryst/VCodeLanguageDetection/actions/workflows/maven.yml/badge.svg)](https://github.com/Valkryst/VCodeLanguageDetection/actions/workflows/maven.yml)\n[![CodeQL](https://github.com/Valkryst/VCodeLanguageDetection/actions/workflows/codeql.yml/badge.svg)](https://github.com/Valkryst/VCodeLanguageDetection/actions/workflows/codeql.yml)\n\nThis is a lightweight library that allows users to automatically detect the coding language of an\ninput text.\n\nThe current implementation is far from perfect, and will sometimes misidentify the language of a code snippet. Longer\ncode snippets are more likely to be correctly identified.\n\n## Table of Contents\n\n* [Installation](https://github.com/Valkryst/VCodeLanguageDetection#installation)\n    * [Gradle](https://github.com/Valkryst/VCodeLanguageDetection#-gradle)\n    * [Maven](https://github.com/Valkryst/VCodeLanguageDetection#-maven)\n    * [sbt](https://github.com/Valkryst/VCodeLanguageDetection#-scala-sbt)\n* [Usage](https://github.com/Valkryst/VCodeLanguageDetection#usage)\n* [Supported Languages](https://github.com/Valkryst/VCodeLanguageDetection#supported-languages)\n* [Credits \u0026 Inspiration](https://github.com/Valkryst/VCodeLanguageDetection#credits--inspiration)\n\n## Installation\n\n_VCodeLanguageDetection_ is hosted on the\n[JitPack package repository](https://jitpack.io/#Valkryst/VCodeLanguageDetection) which supports Gradle, Maven,\nand sbt.\n\n### ![Gradle](https://i.imgur.com/qtc6bXq.png?1) Gradle\n\nAdd JitPack to your `build.gradle` at the end of repositories.\n\n```\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\n\nAdd _VCodeLanguageDetection_ as a dependency.\n\n```\ndependencies {\n\timplementation 'com.github.Valkryst:VCodeLanguageDetection:1.0.0'\n}\n```\n\n### ![Maven](https://i.imgur.com/2TZzobp.png?1) Maven\n\nAdd JitPack as a repository.\n\n``` xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nAdd _VCodeLanguageDetection_ as a dependency.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.Valkryst\u003c/groupId\u003e\n    \u003cartifactId\u003eVCodeLanguageDetection\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### ![Scala SBT](https://i.imgur.com/Nqv3mVd.png?1) Scala SBT\n\nAdd JitPack as a resolver.\n\n```\nresolvers += \"jitpack\" at \"https://jitpack.io\"\n```\n\nAdd _VCodeLanguageDetection_ as a dependency.\n\n```\nlibraryDependencies += \"com.github.Valkryst\" % \"VCodeLanguageDetection\" % \"1.0.0\"\n```\n\n## Usage\n\nGet an instance of _LanguageDetector_, and then call the _detectLanguage_ method with the code whose language you wish\nto detect. You can then use `.entrySet().iterator().next()` to retrieve the first entry in the map, which will be the\nmost likely language.\n\n```java\npublic class Example {\n  public static void main(final String[] args) {\n    final var code = \"\"\"\n    public class Example {\n        public static void main(final String[] args) {\n            System.out.println(\"Hello, World!\");\n        }\n    }\n    \"\"\";\n\n    final var detector = LanguageDetector.getInstance();\n    final var language = detector.detect(code);\n\n    System.out.println(\"Probabilities:\");\n    for (final var entry : language.entrySet()) {\n      System.out.println(\"\\t\" + entry.getKey() + \": \" + entry.getValue());\n    }\n  }\n}\n```\n\nIf you're using [RSyntaxTextArea](https://github.com/bobbylight/RSyntaxTextArea), you can use the following method to\ndetect the language and return the appropriate syntax style.\n\n```java \nprivate String detectSyntaxStyle(final @NonNull String code) {\n  final var languages = LanguageDetector.getInstance().detect(code);\n  final var entry = languages.entrySet().iterator().next();\n\n  if (entry.getValue() == 0) {\n    return RSyntaxTextArea.SYNTAX_STYLE_NONE;\n  }\n\n  try {\n    final var styleName = \"SYNTAX_STYLE_\" + entry.getKey().toUpperCase();\n    final var field = SyntaxConstants.class.getDeclaredField(styleName);\n    return (String) field.get(null);\n  } catch (final NoSuchFieldException | IllegalAccessException e) {\n    return RSyntaxTextArea.SYNTAX_STYLE_NONE;\n  }\n}\n```\n\n## Supported Languages\n\n* C\n* C++\n* C#\n* Clojure\n* D\n* Dart\n* Delphi\n* Fortran\n* Go\n* Java\n* JavaScript\n* Lua\n* Perl\n* PHP\n* Python\n* Ruby\n* SQL\n\n# Credits \u0026 Inspiration\n\n* [highlight.js](https://github.com/highlightjs/highlight.js) - For the lists of keywords for each language.","funding_links":["https://github.com/sponsors/Valkryst"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalkryst%2Fvcodelanguagedetection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalkryst%2Fvcodelanguagedetection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalkryst%2Fvcodelanguagedetection/lists"}