Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 15 pages
Exam (elaborations)

COS4861 Assignment 3 Natural Language Processing Year Module 2026

Document preview thumbnail
Preview 2 out of 15 pages

Get a clear, reliable assignment with accurate answers and useful explanations. Choose us to help you stay on track and work towards better results.

Content preview

UNIVERSITY OF SOUTH AFRICA
School of Computing, College of Science, Engineering and Technology


⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄⋄


COS4861: Natural Language Processing

Assignment 3 | Semester 2, 2026

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄⋄




COS4861
Module Code:
Natural Language Processing
Module Name:
ND-RECOGNIZE Search Strategies & Text
Assignment Topic:
Preprocessing Pipeline
3
Assignment Number:
2, 2026
Semester:
Year Module 2026
Due Date:
50
Total Marks:




Submitted in partial fulfilment of the requirements for COS4861, UNISA 2026

, UNISA | COS4861 NLP: ND-RECOGNIZE & Preprocessing Pipeline



Question 1: ND-RECOGNIZE and Non-Deterministic Search Strategies

Chapter 2 of Jurafsky and Martin’s Speech and Language Processing formalises the equiva-
lence between regular expressions and finite-state automata, and shows that a non-deterministic
FSA (NFSA) needs an explicit search procedure, ND-RECOGNIZE, to resolve the multiple tran-
sition choices that determinism would otherwise remove (Jurafsky and Martin, 2024). The
implementation below builds an NFSA for the pattern baa*!, exercises it against the target
string "baaa!", and compares a stack-driven (DFS) agenda against a queue-driven (BFS)
agenda.


1.1 Automaton Representation (5 Marks)


The automaton is represented as a small class, NFSA, wrapping a nested dictionary keyed
first by state and then by input symbol. Each (state, symbol) pair maps to a list of desti-
nation states rather than a single state, which is precisely what makes the automaton non-
deterministic: on symbol a the state q2 can either loop back on itself (to consume another
a, modelling the Kleene star) or, via a separate transition, be reached again after an epsilon
move. Epsilon-moves are stored under the reserved symbol string ’eps’ and consume no
input, which is the second required source of non-determinism.

1 class NFSA :
2 """
3 A Non - deterministic Finite State Automaton .
4

5 transitions : dict mapping
6 state -> { symbol -> [ list of destination states ] }
7 A symbol of ’ eps ’ represents an epsilon - transition ( no input consumed ) .
8 Storing a LIST of destination states per ( state , symbol ) pair is what
9 allows the automaton to be non - deterministic .
10 """
11

12 def __init__ ( self , start_state , accept_states ) :
13 self . start_state = start_state
14 self . accept_states = set ( accept_states )
15 self . transitions = {}
16

17 def add_transition ( self , state , symbol , next_state ) :
18 " " " Registers one edge ; repeated calls with the same ( state , symbol )
19 accumulate a list of destinations , modelling non - determinism . " " "



Page 2 of 15

Connected book
 image
Publisher: 2013 ISBN: 9789380578774 Edition: Unknown

Document information

Uploaded on
August 25, 2026
Number of pages
15
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$4.91

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
BeeNotes
4.1
(40)
Sold
338
Followers
0
Items
981
Last sold
7 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions