Python Forum
Thai Text Segmentation Module
Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thai Text Segmentation Module
#3
One of the biggest changes in Python 3 was Unicode.
Not gone talk about,better to show it.
# Python 3.6
language = 'หลาม'
char = 'า'
if char in language:
    #print('Yes {} is in {}'.format(char, language))
    print(f'Yes {char} is in {language}') #The new way
Output:
Yes า is in หลาม
In and out is utf-8 okay?
>>> char = 'า'
>>> char
'า'
>>> e = char.encode()
>>> e
b'\xe0\xb8\xb2'
>>> e.decode('utf-8')
'า'
Yes it is,so out/in test.
language = 'หลาม'
with open('thai.txt', 'w', encoding='utf-8') as f_out:
    f_out.write(language)
with open('thai.txt', encoding='utf-8') as f_in:
    f = f_in.read()
    print(f) #--> หลาม
Reply


Messages In This Thread
Thai Text Segmentation Module - by draems - Feb-02-2017, 06:42 AM
RE: Thai Text Segmentation Module - by j.crater - Feb-02-2017, 06:56 AM
RE: Thai Text Segmentation Module - by snippsat - Feb-02-2017, 07:40 AM
RE: Thai Text Segmentation Module - by draems - Feb-02-2017, 08:40 PM
RE: Thai Text Segmentation Module - by snippsat - Feb-03-2017, 03:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use module docx to get text from a file with a table Pedroski55 8 6,712 Aug-30-2022, 10:52 PM
Last Post: Pedroski55
  make: *** [Makefile:29: all] Segmentation fault Anldra12 2 2,006 May-01-2022, 06:17 PM
Last Post: Anldra12
  Segmentation fault (core dumped) hobbyist 1 10,738 Jun-07-2021, 12:56 PM
Last Post: supuflounder
  Segmentation fault with large files kusal1 3 2,872 Oct-01-2019, 07:32 AM
Last Post: Gribouillis
  OpenCV - Segmentation fault samtwilliams 6 7,435 Sep-18-2019, 12:01 AM
Last Post: Larz60+
  Multiple calls to Python interpreter embedded in C++ application yield segmentation f mmoelle1 0 2,909 Mar-21-2019, 08:54 PM
Last Post: mmoelle1
  Segmentation fault when connecting to modbus device with Libmodbus alice 0 2,538 Dec-18-2018, 04:03 PM
Last Post: alice
  module requests, .text extension Truman 1 2,823 Jul-19-2018, 11:47 PM
Last Post: gontajones
  calling python function in c++ callback getting segmentation fault error Jotirling 3 7,277 Oct-26-2017, 08:55 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020