TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite by yokunjon

View this thread on steempeak.com
· @yokunjon ·
$38.43
TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite
#### Repository
 https://github.com/yokunjon/turkishsuffix

## New Features
**Major Vowel Exception:**
As Turkish has vowel harmony, words also have to preserve harmony with suffixes. For that reason, vowels in suffixes change depending on the last vowel of the word. The whole idea of this library is it. But, there is an exception. There are lots of non-Turkish words which are originated from Arabic, Persian, and French. For that reason, most of them get suffixes with their last vowel is soft. For example, "hayal" is an Arabic originated word. When it gets suffix, instead of a hard letter like "a", soft letter like "e" is used. So, this fools the algorithm. Major vowel exception solves this problem.

**(Mostly) Pythonic Rewrite:**
The whole library is rewritten from scratch. I'm not saying it is pure Pythonic, it has a complex algorithm and understanding how it is working is not easy. But it is better than before. I will explain what I changed and why I changed in the next section.

## Implementation

First things first, I wanted to rewrite config loader. It was using .ini files as config. But as I experimented and learned, it is easier to maintain a .py file as a config if there is no chance for user input. So changed the config according to that.

This time, instead of single file, I used a directory and split the config by two files. One is for algorithm settings and the other is for exceptions. I used exec to load config files. When I first used it, I didn't specify any codec, so that created some problems with Turkish letters. Later, I used "utf-8" in exec to solve the issue.

Then, I implemented the major vowel exception. Implementing major vowel exception was easy. I only had to include a dictionary of exceptions and check words are in it or not.

After than that, I started to rewrite the whole main class from scratch. First things first, I decided to use namedtuples in configs. Using dictionaries was easy, but using dictionaries inside dictionaries wasn't. I changed config loader according to that. Then, I erased the whole suffix class except config imports. 

First thing I reimplemented was obviously vowel harmony algorithm. I unpacked optional part of the rule_set with *. Then, instead of a list loop, I used a generator comprehension to find the last vowel. Lastly, I implemented the vowel algorithm which is working with rule_set. In the end, the program was returning the correct vowel.

Then, I felt like it is a mess and modularized it a bit. After the modularization, I did add the soft & hard check. I used guard clause to find hard & soft changes and returned changes if necessary. Later, I implemented the buffer letter. I used guard clause again. Also, I had to implement buffer letter exception to two of the suffixes for two words in Turkish, which are "su" and "ne". After than that, I simply reimplemented major vowel exception. It was quite easy.

And this is where it starts. It became complex because now it was time to add the possessive suffix. The algorithm could handle the rest, but possessive in Turkish is quite a challenge, especially for a computer. I did add possessive person states as a tuple to the settings file. As some of them change word different than the rest, I had to use rule_set to calculate possibilities. I did manage not to repeat myself in possessive method and used the main suffix method to handle suffix part. In the previous version, I was calculating them separately.

I decided to use namedtuple for the return value instead of using lots of getters or properties. By that way, the user of the library could easily select which part to work and wouldn't have to touch main class except suffix method. Then, I did raise several errors to inform what is wrong. I also reimplemented the apostrophe, it was also quite easy. 

Now, it was time for bug-testing. There were lots of bugs especially about possessive with "su" and "ne" exception. I did some workarounds to avoid it, tried many things and edited most of the methods like softs&hards to solve them. Also, there was an issue about dotted I, I did implement a turkish_lower function to solve it. To make config loader compatible with module location, I did change os methods with pkg_resources.

Lastly, I updated the examples and added the doctstring for suffix word.

## Roadmap

I want to make it more developer friendly. Firstly, I want to make a wrapper class for it. It is kinda hard to do repeated suffixes on the same word at the moment. Also, I plan to change the algorithm if possible or find shortcuts which might prevent issues I solved. I might or might not add other suffixes. My main focus on this library was complex suffixes with major vowels, so it depends.

## Contrubition

If you know Turkish language or know how to use python better, I'm open to suggestions. You can simply send a pull request with a proper explanation so I can merge it if it is applicable. I would like to hear some pythonic suggestions which probably I didn't follow, from some of you, python gurus.

#### GitHub Account
https://github.com/yokunjon
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 26 others
properties (23)
post_id65,988,196
authoryokunjon
permlinkturkishsuffix-0-3-1-major-vowel-exception-and-rewrite
categoryutopian-io
json_metadata{"tags":["utopian-io","development","opensource","turkish","turkishsuffix"],"format":"markdown","links":["https:\/\/github.com\/yokunjon\/turkishsuffix","https:\/\/github.com\/yokunjon"],"app":"steemit\/0.1"}
created2018-11-13 23:01:36
last_update2018-11-13 23:01:36
depth0
children9
net_rshares45,645,284,282,833
last_payout2018-11-20 23:01:36
cashout_time1969-12-31 23:59:59
total_payout_value28.969 SBD
curator_payout_value9.456 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length5,094
author_reputation14,981,508,863,374
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (90)
@emrebeyler · (edited)
$7.83
Great project.

![trsuffix.jpeg](https://cdn.steemitimages.com/DQmTVvkVQip1V1mLKVkRXpZuevVLFVguRXE7KzJV9pQdhpL/trsuffix.jpeg)

***

ConfigLoader seems like a little bit off the hook. I would use a default settings file or class in the package then let the user override values instead of using a loader like this. Is there a specific reason for using a loader like this?

Also, When I install the package on a python3.6 environment, I got an error about the config. [Here](https://gist.githubusercontent.com/emre/6840441daa245d9b4842c5db7539066f/raw/fd6784569655a4d5fe8576b3d768ac6c9e1acb4a/stacktrace) is the stack trace.

Steps to reproduce:


- create a python3.6 virtual environment
- install the package via pip
- open the Python repl
- try ```from turkishsuffix import turkishSuffix```.

Other than these, it looks like a great effort to a well known problem. Waiting to see it's progress.

***

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/2222223).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , ,
properties (23)
post_id66,021,532
authoremrebeyler
permlinkre-yokunjon-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t142959135z
categoryutopian-io
json_metadata{"image":["https:\/\/cdn.steemitimages.com\/DQmTVvkVQip1V1mLKVkRXpZuevVLFVguRXE7KzJV9pQdhpL\/trsuffix.jpeg"],"tags":["utopian-io"],"app":"steemit\/0.1","links":["https:\/\/gist.githubusercontent.com\/emre\/6840441daa245d9b4842c5db7539066f\/raw\/fd6784569655a4d5fe8576b3d768ac6c9e1acb4a\/stacktrace","https:\/\/join.utopian.io\/guidelines","https:\/\/review.utopian.io\/result\/3\/2222223","https:\/\/support.utopian.io\/","https:\/\/discord.gg\/uTyJkNm","https:\/\/join.utopian.io\/"]}
created2018-11-14 14:30:00
last_update2018-11-14 14:31:57
depth1
children3
net_rshares10,934,894,925,000
last_payout2018-11-21 14:30:00
cashout_time1969-12-31 23:59:59
total_payout_value5.921 SBD
curator_payout_value1.907 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,391
author_reputation319,480,565,467,431
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (9)
@oups ·
Commenting just to follow the convo.. 

And I'd like to learn any other suggestions for using/manipulating configs. I'm trying to build a script as well just for education purposes and I'm not sure what to use. I want to be able to change setting while script is running, so I know I need argparse and and edit the config file with parsed arguments and read the config file in an infinite while loop. I'm unsure if this is the effective way of doing this.
properties (22)
post_id66,023,239
authoroups
permlinkre-emrebeyler-re-yokunjon-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t150130477z
categoryutopian-io
json_metadata{"app":"steemit\/0.1","tags":["utopian-io"]}
created2018-11-14 15:01:30
last_update2018-11-14 15:01:30
depth2
children0
net_rshares0
last_payout2018-11-21 15:01:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length455
author_reputation20,680,239,095,011
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@yokunjon ·
$0.02
Thank you for the review. I did created the loader class for .ini files. There is no specific reason for it with .py file. So, you are right, its kinda overkill and unnecessary. I will remove it in the next version.

About the issue, I learned out I also have to add .py files in subdirectories to the MANIFEST file. So, in short, it wasn't including config directory. When I checked site-packages/turkishsuffix I found old config.ini there and got shocked. It was probably an artifact from older build folder. I did rebuild it with new MANIFEST file and checked dist\ folder before pushing it. It's working now. I wouldn't notice it without you, thank you.
πŸ‘  ,
properties (23)
post_id66,025,203
authoryokunjon
permlinkre-emrebeyler-re-yokunjon-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t153920945z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit\/0.1"}
created2018-11-14 15:39:18
last_update2018-11-14 15:39:18
depth2
children0
net_rshares29,241,863,476
last_payout2018-11-21 15:39:18
cashout_time1969-12-31 23:59:59
total_payout_value0.015 SBD
curator_payout_value0.004 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length657
author_reputation14,981,508,863,374
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (2)
@utopian-io ·
Thank you for your review, @emrebeyler! Keep up the good work!
πŸ‘  
properties (23)
post_id66,126,993
authorutopian-io
permlinkre-re-yokunjon-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t142959135z-20181116t145638z
categoryutopian-io
json_metadata{"app":"beem\/0.20.9"}
created2018-11-16 14:56:39
last_update2018-11-16 14:56:39
depth2
children0
net_rshares12,266,715,515
last_payout2018-11-23 14:56:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length62
author_reputation152,913,012,544,965
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@steem-ua ·
#### Hi @yokunjon!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
post_id66,026,438
authorsteem-ua
permlinkre-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t160648z
categoryutopian-io
json_metadata{"app":"beem\/0.20.9"}
created2018-11-14 16:06:51
last_update2018-11-14 16:06:51
depth1
children0
net_rshares0
last_payout2018-11-21 16:06:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length287
author_reputation23,203,609,903,979
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@trufflepig ·
**Congratulations!** Your post has been selected as a daily Steemit truffle! It is listed on **rank 21** of all contributions awarded today. You can find the [TOP DAILY TRUFFLE PICKS HERE.](https://steemit.com/@trufflepig/daily-truffle-picks-2018-11-14) 
    
I upvoted your contribution because to my mind your post is at least **5 SBD** worth and should receive **72 votes**. It's now up to the lovely Steemit community to make this come true.

I am `TrufflePig`, an Artificial Intelligence Bot that helps minnows and content curators using Machine Learning. If you are curious how I select content, [you can find an explanation here!](https://steemit.com/steemit/@trufflepig/weekly-truffle-updates-2018-45)
    
Have a nice day and sincerely yours,
![trufflepig](https://raw.githubusercontent.com/SmokinCaterpillar/TrufflePig/master/img/trufflepig17_small.png)
*`TrufflePig`*
    
properties (22)
post_id66,027,875
authortrufflepig
permlinkre-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t163853
categoryutopian-io
json_metadata{}
created2018-11-14 16:38:54
last_update2018-11-14 16:38:54
depth1
children0
net_rshares0
last_payout2018-11-21 16:38:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length883
author_reputation37,535,693,521,838
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@utopian-io ·
Hey, @yokunjon!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
πŸ‘  
properties (23)
post_id66,028,324
authorutopian-io
permlinkre-turkishsuffix-0-3-1-major-vowel-exception-and-rewrite-20181114t164910z
categoryutopian-io
json_metadata{"app":"beem\/0.20.9"}
created2018-11-14 16:49:12
last_update2018-11-14 16:49:12
depth1
children0
net_rshares12,266,715,515
last_payout2018-11-21 16:49:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length590
author_reputation152,913,012,544,965
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@steemitboard ·
Congratulations @yokunjon! You received a personal award!

<table><tr><td>https://steemitimages.com/70x70/http://steemitboard.com/@yokunjon/birthday1.png</td><td>1 Year on Steemit</td></tr></table>

<sub>_[Click here to view your Board](https://steemitboard.com/@yokunjon)_</sub>


**Do not miss the last post from @steemitboard:**
<table><tr><td><a href="https://steemit.com/steem/@steemitboard/steemwhales-has-officially-moved-to-steemitboard-ranking"><img src="https://steemitimages.com/64x128/https://cdn.steemitimages.com/DQmfRVpHQhLDhnjDtqck8GPv9NPvNKPfMsDaAFDE1D9Er2Z/header_ranking.png"></a></td><td><a href="https://steemit.com/steem/@steemitboard/steemwhales-has-officially-moved-to-steemitboard-ranking">SteemWhales has officially moved to SteemitBoard Ranking</a></td></tr><tr><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-witness-update-2019-01-07"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/7CiQEO.png"></a></td><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-witness-update-2019-01-07">SteemitBoard - Witness Update</a></td></tr></table>

> Support [SteemitBoard's project](https://steemit.com/@steemitboard)! **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
post_id68,560,928
authorsteemitboard
permlinksteemitboard-notify-yokunjon-20190108t214956000z
categoryutopian-io
json_metadata{"image":["https:\/\/steemitboard.com\/img\/notify.png"]}
created2019-01-08 21:49:57
last_update2019-01-08 21:49:57
depth1
children0
net_rshares0
last_payout2019-01-15 21:49:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,341
author_reputation38,705,954,145,809
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steemitboard ·
Congratulations @yokunjon! You received a personal award!

<table><tr><td>https://steemitimages.com/70x70/http://steemitboard.com/@yokunjon/birthday2.png</td><td>Happy Birthday! - You are on the Steem blockchain for 2 years!</td></tr></table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@yokunjon) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=yokunjon)_</sub>


###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
properties (22)
post_id83,260,892
authorsteemitboard
permlinksteemitboard-notify-yokunjon-20200108t205454000z
categoryutopian-io
json_metadata{"image":["https:\/\/steemitboard.com\/img\/notify.png"]}
created2020-01-08 20:54:54
last_update2020-01-08 20:54:54
depth1
children0
net_rshares0
last_payout2020-01-15 20:54:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length620
author_reputation38,705,954,145,809
root_title"TurkishSuffix 0.3.1 - Major Vowel Exception and Rewrite"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000