代写 algorithm Haskell prolog ruby software 􏰇􏰈􏰉􏰊􏰋􏰌􏰍􏰎􏰏􏰐􏰑􏰒Confluence􏰓􏰔􏰕􏰖􏰗 􏰘􏰙􏰚􏰛􏰜􏰕􏰖

􏰇􏰈􏰉􏰊􏰋􏰌􏰍􏰎􏰏􏰐􏰑􏰒Confluence􏰓􏰔􏰕􏰖􏰗 􏰘􏰙􏰚􏰛􏰜􏰕􏰖
/ 􏰝􏰞! 􏰀􏰁 􏰂􏰃􏰄 􏰅􏰆 􏰟􏰠 ” #
$
􏰡􏰔 􏱙􏱚 􏰂􏰃􏰄
􏰡􏰔􏱛􏱜􏱑
! Course Announcements 2019 􏰱January 2019 Calendar
Discussion of Final Exam
Erlang task due in course git reposit Haskell task due in course git reposi
, How to use git
Keeping Up With The Wiki
, OLD Course Announcements from J
, Prolog task due in course git reposit
! Ruby task due in course git reposito
How to start a program
Ruby Task Laundry List
The Making of Phase 1 of Ruby ta The Making of Phase 2 of Ruby ta The Making of Phase 3 of Ruby
Software environment of CS3342 co
, Standard setup for course BitBucket
Warmup task due in course git repo
, Week 01: Jan 9􏰣 10 of 2019
, Week 02: Jan 16􏰣 17 of 2019
Week 03: Jan 23􏰣 24 of 2019
, Week 04: Jan 30􏰣 31 of 2019
, Week 05: Feb 6􏰣 7 of 2019
, Week 06: Feb 13􏰣 14 of 2019
, Ruby material Prolog Material Erlang Material
, Haskell Material
, Implementing Language Interpreters a
, Static Code Analysis and CASE Tools
, Misc
– 􏰝􏰞􏱝􏱞
.
􏰡􏰔 /… ⋆F􏰳􏰴 &W􏰵􏰶􏰷 ‘S􏰸􏰹 (
/ Ruby task due in course git repository by end of day on 14 Feb 2019
The Making of Phase 3 of Ruby task due in course
git repository by end of day on 14 Feb 2019
􏰢 Robert Webber􏰅􏰆􏰨􏰩􏰪 02􏰣 2019 thru April􏰲
Continuing from The Making of Phase 2 of Ruby task due in course git repository by end of day on 14 Feb 2019 􏰣 created app/phase_3_sample_tests.rb
ory by enrdeqoufidraey_orne9laAtpirv2e01″9phase_1_helpers” require_relative “phase_2_helpers” require_relative “phase_3_helpers” require_relative “../lib/due190214”
n 2018 @total = 0
ry by en@dpoafsdsay=on07 Mar 2019
ry by end of day on 21 Mar 2019
)
def assert(message, test) y by end of day on 14 Feb 2019
@total = @total + 1 if test then
@pass = @pass + 1
puts “success: ” + message
k due in couerslesgeit repository by end of day on 14 Feb 2019
puts “failed: ” + message
k due in course git repository by end of day on 14 Feb 2019
end
ask dueeindcourse git repository by end of day on 14 Feb 2019
mpute server used for marking
@total = 0 repositor@iepsass = 0
itory by end of day on 24 Jan 2019
test_case = “(.(|LD)D(|LD(.DQ)))”
test_case_tree = PrefixToTree.new(test_case).to_tree assert(“can handle (.(|LD)D(|LD(.DQ)))”,
TreeHolder.new(test_case_tree).to_s == test_case)
test_case = “(+D)”
target = “111”
test_case_tree = PrefixToTree.new(test_case).to_tree test_case_nfa = TreeToNFA.new(test_case_tree).to_nfa assert(“NFA can match 111 against (+D)”,
NFAScanner.new(test_case_nfa).match(target))
test_case = “(+D)”
target = “111”
test_case_tree = PrefixToTree.new(test_case).to_tree test_case_nfa = TreeToNFA.new(test_case_tree).to_nfa
d Compitlerst_case_dfa = NFAToDFA.new(test_case_nfa).to_dfa assert(“DFA can match 111 against (+D)”,
DFAScanner.new(test_case_dfa).match(target))
puts @pass.to_s + ” passed out of ” + @total.to_s + ” tests.”
which shows how the third piece of this assignment will be tested.
Again we make use of your PrefixToTree class from the first phase. However􏰣 now we are also using a TreeToNFA classfrom the second phase. And finally􏰣 we are using the NFAToDFA class that you have to write for this phase. The NFAToDFA class supports new and to_dfa . The question again arises of how to test that the DFA produced is correct.
The approach taken here is the same as was taken to test the NFA from phase 2􏰣 i.e.􏰣 to use it to try and see if various regular expressions match various strings. This is done by a class DFAScanner which I write 􏰱in app/phase_3_helpers.rb􏰲. The implementation of DFAScanner provided􏰣 imposes further constraints on how NFAToDFA works. DFAScanner looks like:
# classes useful for running test cases

class DFAScanner
def initialize(dfa)
@dfa = dfa end
def match(string)
state = @dfa.start
match_helper(state, string)
end
private
def match_helper(state, string)
current_state = state
return accepting?(current_state) if string.empty? next_state = move_forward(string[0].category, current_state) match_helper_try(next_state, string[1..-1])
end
def accepting?(state)
state.accepting?
end
def move_forward(category, state)
forward = @dfa.next(state,category)
end
def match_helper_try(state, string)
return false if state == NullState
match_helper(state, string)
end
end
as you can see􏰣 DFAScanner is simpler than NFAScanner was 􏰱since there is no backtracking in the DFA􏰲.
Looking at the code to DFAScanner􏰣 we find that the object to_dfa returns must meet the requirements:
R. a DFA accepts message start and returns something I will refer to as a state 􏰱see method match􏰲
S. a state must accept the accepting? message 􏰱see method accepting?􏰲
U. a DFA accepts the message next with parameters state and category to return
something that is either a state or the class NullState
V. there is a class named NullState that is defined and exists for the sole purpose of
having something to return when there is not a transition from the current state on the current input character according to the method next.
In addition to this `type information’􏰣 there is the overall semantic constraint that if these various messages are implemented correctly􏰣 then the match method in my DFAScanner class should be able to correctly determine from the DFA whether or not the DFA would match a particular string 􏰱with the answer being the same as would be expected from the question of whether or not the original regular expression would match that same string􏰲.
As with the first and second phases􏰣 the test data that will be used to evaluate the correctness of your solution will not be limited to that that appears
in app/phase_3_sample_tests.rb .
* 􏰫 􏰬􏰭􏰮􏰊􏰋􏰫􏰯􏰰 􏰺􏰻􏰼 + 2􏰽􏰾
Xiaoou Li 􏱁􏰄􏱂 Hi sir
I have passed some tests on phase 2􏰣 and i found an interesting thing when i tired to do phase 3.
In fact􏰣 i used KMP search algorithm which turns trie tree into AC automation􏰣 and AC auto already is a DFA 􏰱in my phase 2 code􏰣 method epsilon_closure􏰱state􏰲 only returns empty set 􏰲􏰣 so in phase 3 i do not need to do anything􏰣 except calling phase 2 code.
and it works􏰣 so can i get marks on phase 3? 􏰿􏱀 􏰫 􏰩􏰪 11􏰣 2019
Robert Webber 􏱁􏰄􏱂
Re: The Making of Phase 2 of Ruby task due in course git repository by end
of day on 14 Feb 2019
􏰿􏱀 􏰫 􏰩􏰪 11􏰣 2019 􏱃􏱄􏰽􏰾…
􏱅􏰒􏰊􏰋􏱆􏱇Department of Computer Science􏰣 The University of Western Ontario􏱈􏱉􏱊Atlassian Confluence Community License􏰗􏱋􏱌􏰽􏱍Confluence􏰗
􏱎􏰨 Atlassian Confluence 6.13.0 􏱏􏱐􏱑􏰆 􏱒 􏱓􏱔􏱕􏱖 􏱒 Atlassian 􏱗􏱘
o t
a o r
s s
t
s
n