turkishsuffix 0.2.1 - Implementation of Possessive Form

in #utopian-io6 years ago (edited)

What's New in 0.2.1?

New Features

  • Possessive form is finally implemented.
  • Dynamic loader for config is implemented.

Improvements

  • Class names are simpler now.
  • Code is seperated into 2 parts; loader.py and suffix.py.
  • Main class (suffix.py) is more modularised than before.
  • Documentation added for main class (suffix.py).

Bugfixes

  • Importing the library was little buggy, so you had to import whole path. Now, importing syntax is short and proper.

My Experience

Related commit: https://github.com/yokunjon/turkishsuffix/commit/b4718e2976c1f4d750dbc238231918232c2290f2#diff-e5a7a8ce8614a2ef28c2cbdfd51d93f9

turkishsuffix/config.ini -

  • I've added type (line 9), rule-set(line 13) and exception(line 18) for possessive (iyelik) form.

  • I've added a new option named possessive to make possessive rule-set.

turkishsuffix/loader.py -

  • I've changed loading from static to dynamic. To do that, I looped a list of options for "Settings" and defined them dynamically with the usage of setattr.

turkishsuffix/suffix.py -

  • I've modularised the main class. To do that I've split the main method (set_suffix) and created new methods named _check_hards and _check_vowels.

  • I've added the possessive suffix to the main method. It was hard to achieve because possessive suffix had lots of exceptions based on person state of the word. First, I checked ";" to make sure it's plural or not. In the rule-set, only the 6th possessive rule needs the plural suffix. To make it plural, code first gets the plural suffix by using the set_suffix method, then applies the possessive suffix of that pluralised word. If there is no pluralization, then code checks for each exception. Depending on the situation, suffix changes according to that.

  • I've added the get_possessive method to get possessive person state for the word.

What is turkishsuffix?

A library for adding complex suffixes to Turkish words. While doing that, the code uses rule set and python's string manipulation to enhance quality. There are similar libraries in both GitHub and PyPi, but most of them are not functioning right, and other's algorithm are too straightforward and because of that their efficiency is less than turkishsuffix.

turkishsuffix uses math and ordered data to dynamically calculate possibilities instead of checking every possibility statically. It has a config, which can easily be edited.

turkishsuffix has 3 main components:

  • suffix.py - Main class for turkishsuffix.
  • loader.py - Config loader for turkishsuffix.
  • config.ini - Config for turkishsuffix.

Which Features are Working Right Now?

  • These Turkish suffixes are functioning right now:

    • çokluk hali
    • ilgi hali
    • eşitlik hali
    • yönelme hali
    • belirtme hali
    • bulunma hali
    • ayrılma hali
    • iyelik hali
  • There are exceptions for "su" and "ne" words in ilgi hali. So exception system is functioning right now.

  • There is an option for apostrophe in proper names (like human names, city names etc.), that is functioning right now.

What are Missing?

All complex suffixes are added to the project. Some basic suffix types are missing at the moment.
Also, there are exceptions caused by some non-Turkish words. For example Arabic word for "dream/illusion"
is "hayâl". It has a carret, but as this feature is archaic, we don't write the carret (which
indicates it should sound soft or long) but pronounce like there is a carret. As suffixes in Turkish
depends on harmony, this causes system to be fooled. This can be fixed with proper exception dictionary.
I'll try to implement that in future (maybe a month later). If you can help, don't be shy. I would be happy.

Roadmap

  • Different exception types with improved exception config.

  • Adding non-confusing/basic suffix types. (mastar hali, geçmiş zaman hali etc.)

How to Use?

Installing:

pip install turkishsuffix

Importing:

from turkishsuffix import TurkishSuffix

TurkishSuffix construction:

suffix = TurkishSuffix(word, suffix type, possessive state)  # suffix type and posessive state is optional

TurkishSuffix methods:

suffix.get_word(type: string, proper: boolean, possessive: string) #  Main method for the most of
#  the situations. As this can return word with suffix, it can also create words with suffixes.
#  For possessive, use "1", "2", "3" as person and "t" or "ç" for plurality. As an example, "1t".
suffix.get_old_word()  # Public method that returns the unchanged word.
suffix.get_suffix()  # Public method that returns only the suffix.
suffix.get_type()  # Public method that returns the suffix type.
suffix.get_possessive()  # Public method that returns possessive state of the suffix.

Simple Example:

word = TurkishSuffix("Test")
print(word.get_word("çokluk", True))
word2 = TurkishSuffix("Test", "iyelik", "2t")
print(word2)

How Useful is turkishsuffix?

Programmers usually avoid using suffixes while coding in Turkish. The reason behind that is Turkish having a complex suffix system. For example, an easy one, plural form (çokluk hali) is done with lar or ler. If latest vowel of the word is soft, word's suffix must be ler, if not the suffix must be lar. If we delve deeper, it becomes more complicated. Sometimes some situations require extra letters, some require both hard/soft and rounded/unrounded to be calculated. Because of this complexity, as I said at start, programmers avoid using suffixes. Instead of "Bora'nın", "Deniz'in", "Umut'un" and etc., they simply add another word into sentence and add suffix to that word. For example they add "bey" and those became "Bora Bey'in", "Deniz ,Bey'in" and "Umut Bey'in". While this can be used in Turkish, we should encourage people to use formal ones more. If we can encourage people to use this, even Facebook may change how they approach into this issue.

You can check out the more examples at /example.

(Bilkent Üniversitesi'ne)

image.png



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @yokunjon I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Congratulations @yokunjon! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Congratulations @yokunjon! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got your First payout
Award for the total payout received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Congratulations @yokunjon! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @yokunjon! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the total payout received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @yokunjon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the number of comments received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemFest³ - SteemitBoard support the Travel Reimbursement Fund.

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @yokunjon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemFest³ - SteemitBoard support the Travel Reimbursement Fund.

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @yokunjon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the total payout received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - Resteem and Resteemed added

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @yokunjon! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - Resteem and Resteemed added

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.031
BTC 61906.25
ETH 2905.39
USDT 1.00
SBD 3.64