This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| class Token: | |
| """Class to represent a root or IG token.""" | |
| def __init__(self, word): | |
| """ | |
| Constructor. | |
| :rtype : Token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Calculate root bigrams | |
| root_counts = { | |
| 'ел': {'ел': 1, 'саяси': 17, 'билік': 19, 'аятолла': 50, 'қол': 45, '.': 19}, | |
| 'саяси': {'ел': 32, 'саяси': 1, 'билік': 100, 'аятолла': 18, 'қол': 4, '.': 38}, | |
| 'билік': {'ел': 47, 'саяси': 5, 'билік': 1, 'аятолла': 21, 'қол': 53, '.': 23}, | |
| 'аятолла': {'ел': 44, 'саяси': 32, 'билік': 4, 'аятолла': 1, 'қол': 73, '.': 17}, | |
| 'қол': {'ел': 13, 'саяси': 81, 'билік': 31, 'аятолла': 20, 'қол': 1, '.': 15}, | |
| '.': {'ел': 64, 'саяси': 75, 'билік': 46, 'аятолла': 13, 'қол': 54, '.': 1} | |
| } | |
| roots = ['ел', 'саяси', 'билік', 'аятолла', 'қол', '.'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Number given: 13.875 | |
| 1. The number is positive -> sign bit is 0 | |
| 2. Now convert part before decimal point to binary, 13 -> 1101 | |
| 3. Convert part after decimal point to binary | |
| 0.875 * 2 = 1.75 -> 1 | |
| 0.75 * 2 = 1.5 -> 1 | |
| 0.5 *2 = 1.0 -> 1 |