automata

Is it possible for a computer to “learn” a regular expression by user-provided examples?

随声附和 提交于 2020-01-18 04:48:07
问题 Is it possible for a computer to "learn" a regular expression by user-provided examples? To clarify: I do not want to learn regular expressions. I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers. Is it possible? Are there algorithms, keywords, etc. which I can Google for? EDIT : Thank you for the answers, but I'm not interested in tools which provide

Is it possible for a computer to “learn” a regular expression by user-provided examples?

情到浓时终转凉″ 提交于 2020-01-18 04:47:25
问题 Is it possible for a computer to "learn" a regular expression by user-provided examples? To clarify: I do not want to learn regular expressions. I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers. Is it possible? Are there algorithms, keywords, etc. which I can Google for? EDIT : Thank you for the answers, but I'm not interested in tools which provide

Finiteness of Regular Language

和自甴很熟 提交于 2019-12-28 06:27:42
问题 We all know that (a + b)* is a regular language for containing only symbols a and b . But (a + b)* is a string of infinite length and it is regular as we can build a finite automata, so it should be finite. Can anyone please explain this? 回答1: Finite automaton can be constructed for any regular language, and regular language can be a finite or an infinite set. Of-course there are infinite sets those are not regular sets. Check the Venn diagram below: Notes : 1. every finite set is a regular

How can I represent an automaton graphically from a list of int*char*int representing the transitions without using loops

穿精又带淫゛_ 提交于 2019-12-25 07:47:14
问题 I made a record called automaton containing the 5 fields required to represent an automaton I'm supposed to use graphics to represent every state and transition from the transitions list without using for or while loops only recursive functions transitions :(int*char*int) list; 回答1: It might be easiest to use graphviz to do the actual drawing. It automatically draws a graph from a list of nodes and edges, which is exactly what your input is. The function fmt_transition generates one edge, the

Does order not matter in regular expressions?

余生长醉 提交于 2019-12-23 16:11:59
问题 I was looking at the question posed in this stackoverflow link (Regular expression for odd number of a's) for which it is asked to find the regular expression for strings that have odd number of a over Σ = {a,b} . The answer given by the top comment which works is b*(ab*ab*)*ab* . I am quite confused - a was placed just before the last b* , does this ordering actually matter? Why can't it be b*a(ab*ab*)*b* instead (where a is placed after the first b* ), or any other permutation of it?

Converting NFA to DFA

本秂侑毒 提交于 2019-12-21 23:27:24
问题 I'm having trouble understanding how to convert. If 2 gets an input of 'a' would it become (1,4) or (1,2,4) because of the empty string? Thanks! 回答1: If state Q2 gets an input of 'a' next states may be either Q1 , Q2 , 0r Q4 . In your NFA your get final state Q4 Its equivalent DFA is as below: a- || ▼| --►(Q0)---a---►((Q1))---b----►((Qf)) ▲-----a--------| Where Q1 and Q2 are final state. And its Regular Expression is: a (a + ba)* (b + ε ) Where ε is null symbol (epsilon) 回答2: We begin to

Using finite automata as keys to a container

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 06:30:01
问题 I have a problem where I really need to be able to use finite automata as the keys to an associative container. Each key should actually represent an equivalence class of automata, so that when I search, I will find an equivalent automaton (if such a key exists), even if that automaton isn't structurally identical. An obvious last-resort approach is of course to use linear search with an equivalence test for each key checked. I'm hoping it's possible to do a lot better than this. I've been

Levenshtein DFA in .NET

情到浓时终转凉″ 提交于 2019-12-20 10:53:32
问题 Good afternoon, Does anyone know of an "out-of-the-box" implementation of Levenshtein DFA ( deterministic finite automata ) in .NET (or easily translatable to it)? I have a very big dictionary with more than 160000 different words, and I want to, given an inicial word w , find all known words at Levenshtein distance at most 2 of w in an efficient way. Of course, having a function which computes all possible edits at edit distance one of a given word and applying it again to each of these

Regular vs Context Free Grammars

丶灬走出姿态 提交于 2019-12-17 07:59:56
问题 I'm studying for my computing languages test, and there's one idea I'm having problems wrapping my head around. I understood that regular grammars are simpler and cannot contain ambiguity, but can't do a lot of tasks that are required for programming languages. I also understood that context-free grammars allow ambiguity, but allow for some things necessary for programming languages (like palindromes). What I'm having trouble with is understanding how I can derive all of the above by knowing

Example of Non-Linear, UnAmbiguous and Non-Deterministic CFL?

可紊 提交于 2019-12-17 06:51:42
问题 In the Chomsky classification of formal languages, I need some examples of Non-Linear, Unambiguous and also Non-Deterministic Context-Free-Language(N-CFL)? Linear Language : For which Linear grammar is possible( ⊆ CFG) e.g. L 1 = {a n b n | n ≥ 0 } Deterministic Context Free Language(D-CFG) : For which Deterministic Push-Down-Automata(D-PDA) is possible e.g. L 2 = {a n b n c m | n ≥ 0, m ≥ 0 } L 2 is unambiguous. A CF grammar that is not linear is nonlinear. L nl = {w: n a (w) = n b (w)} is