Last answered:

16 Oct 2023

Posted on:

13 Oct 2023

0

Resolved: Project Transposition cipher

In the optional part solution, I am unable to install PyDictionary through the command

"pip install pydictionary". It give some errors and finally this module is not installed. I am using python version 3.9.18. What is to be done?

9 answers ( 1 marked as helpful)
Instructor
Posted on:

13 Oct 2023

0

Hey Dhaivat,


Thank you for reaching out!


Unfortunately, I'm not familiar with this issue. I have found this stackoverflow thread where the user seems to be hitting the same problem. Try to implement any of the provided solutions:

https://stackoverflow.com/questions/71336856/error-pydictionary-would-not-install-on-python-3-10-2


Kind regards,

365 Hristina

Posted on:

13 Oct 2023

0

Hello Hristina,

I tried out each of the options mentioned in this link. None of them actually work. I even tried downloading the whl file from PyDictionary 2.0.1, it yields the same error. Has it got something to do with the Python version? I also tried installing Py-Dictionary. It installed, but then it does not run properly (for example if I try to find meaning of any word, it gives an error). wordhoard works for some words. But it does not contain meanings of words like 'is' 'fun'. So, the hack program of optional solution does not work. Please suggest something else to resolve. I feel there is some fundamental issue with installing of PyDictionary which I am unable to resolve on my own 

Posted on:

13 Oct 2023

0

I found some documentation regarding this. I had to install a lower version of futures using pip install futures==2.2.0 which is basically <3.0.0 since futures>=3.0.0 does not work with Python 3. I would suggest that you include this in your solution as well, since I am sure that others using Python 3 would not be able to install PyDictionary. Also, in the program statement PyDictionary.meaning(i), it would be helpful to include disabling errors generated due to PyDictionary by using PyDictionary(i,disable_errors=True) which will disable errors printed when PyDictionary does not find the word.

Instructor
Posted on:

16 Oct 2023

0

Hey again Dhaivat,


Given the insights from your contribution, we have decided to update the project as soon as possible by including an alternative English dictionary library; one solution would be to use english-dictionary.


In terms of code optimization, there's indeed a clear opportunity to improve its robustness. Implementing try-except blocks, for instance, would be a good strategy to handle potential errors during runtime. However, since this is a practice project of intermediate level and it comes before the Exception Handling section in the Python Programmer Bootcamp course, this exercise is left for the experienced and interested student to implement, if they wish.


Thank you again for your input.


Kind regards,

365 Hristina

Posted on:

16 Oct 2023

0

Thanks, Hristina. I will try with the suggested dictionary as well

Posted on:

16 Oct 2023

0

Sorry Hristina, unable to work with english-dictionary 1.0.24 mentioned in your link. Documentation shows to import get_dict. I carried out the following set of commands on the console:

from english_dictionary.scripts.read_pickle import get_dict

z = get_dict()

Above statements create a dictionary 'z' which has words as keys & their meanings as values contained in "English Dictionary" .

I tried to query with z.get('Learning'). It didn't return anything. So, I tried multiple words using z.get(<word>) format to return the value for the key <word>

Incidentally, 'Learning', 'Python', do not exist as keys. The word 'is' exists, but the meaning shows as 'island'. and not the true meaning of 'is'. The word 'fun' exists and shows the true meaning. So, I feel the english-dictionary 1.0.24 is unrealiable. Can you please experiment this and let me know if there is a different perspective to this solution? Attaching snapshot of the statements that I have tried

Instructor
Posted on:

16 Oct 2023

0

Hey Dhaivat,


Appreciate your efforts in exploring this alternative solution.


Note that english_dictionary is case-sensitive and all words there are stored in lowercase (just like the standard format in traditional paper dictionaries). That is why it's good practice to apply the .lower() function on messages you encrypt and decrypt to make sure they match the dictionary words.



Let me kow if you encounter other issues!


Kind regards,

365 Hristina

Posted on:

16 Oct 2023

0

Oh ok, thanks for the clarification. I tried with "Learning Python is fun" and it worked by converting to lower case first. However, another string, "It is raining today" does not work as it cannot find "raining". Am I correct or still making any mistake? Sorry to be interative in this case, but I am only trying to get past my errors. Incidentally, it works with PyDictionary. But using english-dictionary yields the results quicker. PyDictionary has a sluggish response, but pretty accurate.

Instructor
Posted on:

16 Oct 2023

0

Hacking a cipher doesn't come without difficulties. Having a complete list of all English words (with all their different forms, conjugations, etc) is one such difficulty. As mentioned in the solution notebook, the approach also assumes that the encrypted message contains no punctuation and that individual words are separated by a single space - those alone are very restrictive assumptions. At the end of the day, we can implement an algorithm that is only so good.


I think that getting a more reliable output with PyDictionary at the cost of slower runtime is a good bargain. :)


Kind regards,

365 Hristina

Submit an answer