Questions tagged [language-recognition]

13 questions
17
votes
10 answers

Code for identifying programming language in a text file

i'm supposed to write code which when given a text file (source code) as input will output which programming language is it. This is the most basic definition of the problem. More constraints follow: I must write this in C++. A wide variety of…
PeterK
  • 6,287
  • 5
  • 50
  • 86
9
votes
3 answers

Neural Networks For Generating New Programming Language Grammars

I have recently had the need to create an ANTLR language grammar for the purpose of a transpiler (Converting one scripting language to another). It occurs to me that Google Translate does a pretty good job translating natural language. We have all…
4
votes
4 answers

Identifying keywords of a (programming) language

this is a follow up to my recent question ( Code for identifying programming language in a text file ). I'm really thankful for all the answers I got, it helped me very much. My code for this task is complete and it works fairly well - quick and…
PeterK
  • 6,287
  • 5
  • 50
  • 86
4
votes
1 answer

How to check for nonsense or gibberish in a text?

I am getting a text string and I want to verify if the text is gibberish or not. By gibberish I mean text like "gfgsgsogjw" i.e. random keyboard presses. Currently I am using NTextCat to simply check if the language of the string matches the…
Haris
  • 778
  • 2
  • 9
  • 20
2
votes
1 answer

How ANTLR decides whether terminals should be separated with whitespaces or not?

I'm writing lexical analyzer in Swift for Swift. I used ANTLR's grammar, but I faced with problem that I don't understand how ANTLR decides whether terminals should be separated with whitespaces. Here's the grammar:…
1
vote
3 answers

Detect Language of a String

I need to detect the language of a string read from a pdf file the text is basically in English language, but "NLLanguageRecognizer" return that it is "Romanian" the function I am using is : class func detectedLangaugeFormat(for string: String) ->…
Awais Mobeen
  • 733
  • 11
  • 19
0
votes
1 answer

How to specify multiple lexer rules in a single rule?

I have the following parser rule: declaration : (KW_VARIABLE DT_IDENTIFIER) | (KW_VARIABLE DT_IDENTIFIER OP_ASSIGNMENT DT_DATA_TYPES) OP_SEMICOLON; and the following lexer rules: KW_VARIABLE : 'var'; OP_ASSIGNMENT :…
user10870702
0
votes
1 answer

Beginner: ANTLR4 Grammar doesn't handle negative numbers

I'm currently working on a simple ANTLR4 grammar for evaluating mathematical expressions. At the moment, my grammar should just be able to parse simple operations like multiplications, divisions, additions and subtractions ... Here's my grammar:…
Wecherowski
  • 818
  • 11
  • 24
0
votes
1 answer

language recognition in plain JS (en/ger) - improvements wanted

I wrote a simple code to identify weather a message is written in English or in German. "languageAnalysis()" will be called via "identifyLanguge()". See my answer for the latter. The code works, but I am looking for: English or German text examples…
maxischl
  • 579
  • 1
  • 11
  • 29
0
votes
1 answer

how to detect other languages (non-Latin) except in English in a text column in PostgreSQL?

I have a table with two columns: one is id and another one is a text column. I want to keep only the rows that the text value is in English. The languages I am talking about, are the ones that use non Latin alphabet such as Arabic, Chinese and…
GeoBeez
  • 920
  • 2
  • 12
  • 20
0
votes
1 answer

Joomla Start and Language Redirections

I have two questions with my Joomla! Project: I want to have a standard redirect for my domain, so when a user types in domain.com he will be redirected to domain.com/my-joomla-menu-item. This cannot be done with the standard Home Menu item…
M.Singer
  • 47
  • 8
0
votes
0 answers

Identify spoken language by creating spectrograms in python?

I'm practicing spoken language recognition code from 'https://github.com/YerevaNN/Spoken-language-identification'. Input 'csv' dataset is downloaded from 'https://gist.github.com/Harhro94/aa11fe6b454c614cdedea882fd00f8d7' First task is to convert…
user9341326
0
votes
0 answers

Reading code snippets from user-input (switch-case Java)

I am working on a small project on my compiler subject and was assigned on the switch-case(java) part.So here's how it goes:A user would enter a code snippet from a switch-case statement,and my program should be able to identify if the code from the…