Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Python help !
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="sp3co" data-source="post: 22710416" data-attributes="member: 559702"><p>Python වැඩ්ඩොන්ගෙන් උදව්වක් ඕනේ .. </p><p></p><p>UCSC Sinhala Corpus + NLTK project කරපු කවුද ඉන්නේ ? මම UCSC corpus එක use කරනවා project එකකට. එකේ NLTK වලින් custom corpus open කරන විදියට මේකත් open කරන්න බැලුවේ (NLTK functions use කරන්න නිසා) එත් unicode error එකක් එනවා මේ විදියට </p><p></p><p><em><span style="font-size: 12px">Traceback (most recent call last):</span></em></p><p><em><span style="font-size: 12px"> File "/home/xxxx/PycharmProjects/testing/readcorpus.py", line 13, in <module></span></em></p><p><em><span style="font-size: 12px"> file = read_file.read()</span></em></p><p><em><span style="font-size: 12px"> File "/home/xxxx/.virtualenvs/PycharmProjects/lib/python3.5/codecs.py", line 321, in decode</span></em></p><p><em><span style="font-size: 12px"> (result, consumed) = self._buffer_decode(data, self.errors, final)</span></em></p><p><em><span style="font-size: 12px">UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte</span></em></p><p></p><p>මගේ code එක මේක ... මේකේ readpath එකත් හරි ..ඒත් ඒ file එක read කරන්න යද්දී තමයි error එක එන්නේ </p><p><span style="font-size: 12px"><strong></strong></span></p><p><span style="font-size: 12px"><strong>from nltk.corpus import PlaintextCorpusReader</strong></span></p><p><span style="font-size: 12px"><strong></strong></span></p><p><span style="font-size: 12px"><strong>corpus_root = './resources/corpus/UCSC-Sinhala-News-Corpus/UCSC-Sinhala-News-Corpus-V1'</strong></span></p><p><span style="font-size: 12px"><strong></strong></span></p><p><span style="font-size: 12px"><strong>sinhala_corpus = PlaintextCorpusReader(corpus_root, '.*')</strong></span></p><p><span style="font-size: 12px"><strong></strong></span></p><p><span style="font-size: 12px"><strong>print(sinhala_corpus.fileids())</strong></span></p><p><span style="font-size: 12px"><strong></strong></span></p><p><span style="font-size: 12px"><strong>readpath = './resources/corpus/UCSC-Sinhala-News-Corpus/UCSC-Sinhala-News-Corpus-V1/News Corpus_V1/NPED0001.TXT'</strong></span></p><p><span style="font-size: 12px"><strong></strong></span></p><p><span style="font-size: 12px"><strong>read_file = open(readpath, 'r', encoding='utf-8')</strong></span></p><p><span style="font-size: 12px"><strong>file = read_file.read()</strong></span></p><p></p><p></p><p>මෙහෙම වෙන්නේ ඇයි මේක හදාගන්නේ කොහොමද ?</p><p><span style="color: Red"></span></p><p><span style="color: Red">ඔය text file එක notepad open කලාම type එක තියෙන්නේ unicode.. හැබැයි එක utf-8 කියල save කලාම error එක එන්නේ නෑ file එක read වෙනවා.. එහෙම file type වෙනස් නොකර මේක හදාගන්නේ කොහොමද ?</span></p><p></p><p>Stackoverflow එකේ බැලුව unicode file read කරන්නේ කොහොමද කියල.. ඒකෙ තියෙන්නෙ ඔය විදියට කලාම හරි කියලා</p></blockquote><p></p>
[QUOTE="sp3co, post: 22710416, member: 559702"] Python වැඩ්ඩොන්ගෙන් උදව්වක් ඕනේ .. UCSC Sinhala Corpus + NLTK project කරපු කවුද ඉන්නේ ? මම UCSC corpus එක use කරනවා project එකකට. එකේ NLTK වලින් custom corpus open කරන විදියට මේකත් open කරන්න බැලුවේ (NLTK functions use කරන්න නිසා) එත් unicode error එකක් එනවා මේ විදියට [I][SIZE="3"]Traceback (most recent call last): File "/home/xxxx/PycharmProjects/testing/readcorpus.py", line 13, in <module> file = read_file.read() File "/home/xxxx/.virtualenvs/PycharmProjects/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte[/SIZE][/I] මගේ code එක මේක ... මේකේ readpath එකත් හරි ..ඒත් ඒ file එක read කරන්න යද්දී තමයි error එක එන්නේ [SIZE="3"][B] from nltk.corpus import PlaintextCorpusReader corpus_root = './resources/corpus/UCSC-Sinhala-News-Corpus/UCSC-Sinhala-News-Corpus-V1' sinhala_corpus = PlaintextCorpusReader(corpus_root, '.*') print(sinhala_corpus.fileids()) readpath = './resources/corpus/UCSC-Sinhala-News-Corpus/UCSC-Sinhala-News-Corpus-V1/News Corpus_V1/NPED0001.TXT' read_file = open(readpath, 'r', encoding='utf-8') file = read_file.read()[/B][/SIZE] මෙහෙම වෙන්නේ ඇයි මේක හදාගන්නේ කොහොමද ? [COLOR="Red"] ඔය text file එක notepad open කලාම type එක තියෙන්නේ unicode.. හැබැයි එක utf-8 කියල save කලාම error එක එන්නේ නෑ file එක read වෙනවා.. එහෙම file type වෙනස් නොකර මේක හදාගන්නේ කොහොමද ?[/COLOR] Stackoverflow එකේ බැලුව unicode file read කරන්නේ කොහොමද කියල.. ඒකෙ තියෙන්නෙ ඔය විදියට කලාම හරි කියලා [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom