Symbol | frequency |
a | .3 |
b | .24 |
c | .2 |
d | .16 |
e | .1 |
First combine d and e yielding a cumulative Frequency of .26 Next combine b and c yielding a cumulative Frequency of .44 Next combine a and (d e) yielding a cumulative Frequency of .56 Next combine (a d e) and (b c) yielding a cumulative Frequency of 1.00 This yields the tree in list notation (1.00 (.56 (.3=a) (.26 (.16=d)(.1=e))) (.44 (.24=b) (.2=c)) ) And then using the convention of 0 to the left 1 to the right Symbol Huffman-code a 00 b 10 c 11 d 010 e 011 There are other solutions based on the convention for labeling left and right but all of them will have the lengths of the ones above.
The rank is used to choose from the set of matching rules when more than one ELIZA rule matches.
Word | Rank | Pattern | Outputs |
---|---|---|---|
birthday | 9 | ?X | Oh, was there a party? |
brother | 2 | ?X | Tell me more about your family |
S -> NP VP NP -> art ADJL noun | art noun ADJL -> adj ADJL | adj VP -> verb NP | verb
(S (NP (art) (ADJL (adj) (ADJL (adj)) (noun))) (VP (verb) (NP (art) (noun))) )
Just a noun as in "john" or "girls Compound noun phrases as in "girls and boys"
NP -> noun for the simple noun NP -> NP and noun // This is not a good solution. why?
father(sam, bill) father(ben, bill) father(bill, joe) father(mary, joe) mother(ralph, mary) parent(X,P) :- father(X,P). parent(X,P) :- mother(X,P). sibling(X,Y) :- parent(X,P), parent(Y,P).
X = sam; X = ben
cousin(X,C) :- parent(X,PX), parent(C,PC), sibling(PX,PC).
an alphabetical list of words in a document with a list of locations where the words occur
This requires some efficient search structure such as a search tree or a hash table for the words. Each node needs to have a linked list of locations. The locations need to be kept up with so that the current page and current line need to be maintained. Algorithm: Read the words one at a time. Search the structure and insert the word if not already there. Add the location to the entry for this word.
Using statistical techniques to try to attribute a document to an author.
Analyzing word usage frequency patterns and compare with other works by this author and other potential authors. Structure separation patterns is another aspect.
ZXH
Match up the most frequent characters in the cipher text with the frequencies for English. i.e., map the most frequent character to SPACE, the next to `T', and the next to `A' etc.
waters can be both a noun and a verb
Step | Current | Alternatives |
---|---|---|
((S) 1) | () | |
1 | ((NP VP) 1) | () |
2 | ((art ADJL noun VP) 1) | ((art noun VP) 1) |
3 | ((ADJL noun VP) 2) | (((art noun VP) 1)) |
4 | ((adj ADJL noun VP) 2) | (((adj noun VP) 2)((art noun VP) 1)) |
5 | ((ADJL noun VP) 3) | (((adj noun VP) 2)((art noun VP) 1)) |
6 | ((adj ADJL noun VP) 3) | (((adj noun VP) 3)((adj noun VP) 2)((art noun VP) 1)) |
for test stop here | ||
Fails to match adj | Backup to previous state | |
7 | ((adj noun VP) 3) | (((adj noun VP) 2)((art noun VP) 1)) |
Fails to match adj | Backup to previous state | |
8 | ((adj noun VP) 2) | (((art noun VP) 1)) |
9 | (( noun VP) 3) | (((art noun VP) 1)) |
10 | (( VP) 4) | (((art noun VP) 1)) |
n = 7 * 11 = 77
phi(n) = (7-1)*(11-1) = 60
(77,13)
d = 6
Calculate c = me mod n = m13 mod 77
Calculate decoded = cd mod n = c6 mod 77