Skip to content

Instantly share code, notes, and snippets.

View wannaphong's full-sized avatar

Wannaphong Phatthiyaphaibun wannaphong

View GitHub Profile
#Apache License 2.0
file_name="data" # ชื่อไฟล์คลังข้อมูล
import codecs
from pythainlp.tokenize import word_tokenize
from pythainlp.tag import pos_tag
from nltk.tokenize import RegexpTokenizer
import glob
import nltk
import re
#จัดการประโยคซ้ำ
This file has been truncated, but you can view the full file.
1 “ _ PUNCT PUNCT_`` _ 27 punct _ _
2 แม้ _ ADP ADP_IN _ 10 mark _ _
3 ว่า _ ADP ADP_IN _ 2 fixed _ _
4 การเปลี่ยน _ VERB VERB_VV _ 10 csubj _ _
5 ไป _ PART PART_RP _ 4 compound:prt _ _
6 ใช้ _ VERB VERB_VV _ 4 xcomp _ _
7 ระบบ _ NOUN NOUN_NN _ 6 obj _ _
8 ดิจิตัล _ ADJ ADJ_JJ _ 7 amod _ _
9 เป็น _ AUX AUX_VC _ 10 cop _ _
10 สิ่ง _ NOUN NOUN_NN _ 27 advcl _ _
สวัสดีชาวโลก
ผมเป็นคนไทย
สบายดีไหม
ทำอะไรอยู่อ่ะ
หิวข้าวแล้ว
เธอชอบกินข้าวมันไก่
เขาเพิ่งกลับจากโรงเรียน
พรุ่งนี้เป็นวันอะไร
มือถือของนายรุ่นอะไรอ่ะ
เราไปสั่งข้าวที่ร้านอาหารกันไหม
import sys
from subprocess import call
def play(name):
if sys.platform == 'linux':
call(["ffplay",name])
elif sys.platform == 'darwin':
call(["afplay",name])
elif sys.platform == 'win32':
call(['start',name])
else:
def hi():
print("สวัสดีชาวโลก")
from openpyxl import load_workbook
wb = load_workbook(filename = 'sample.xlsx') #อ่านไฟล์ sample.xlsx
sheet_ranges = wb['hello'] #เรียกใช้ worksheet ที่ชื่อว่า hello
print(sheet_ranges['A1'].value) #อ่านค่าจากเซลส์ A1 ใน worksheet ของ hello
using System;
public class MyProgram
{
public static void Main(String[] args)
{
int n;
int[] A = new int[4];
int[] B = new int[4];
int[] C = new int[4];
print("Hi")
@wannaphong
wannaphong / icu_word_segmentation.java
Last active March 21, 2018 13:37
โค้ดตัดคำภาษาไทยด้วย ICU ใน Java ใช้งานได้ตั้งแต่ Java 1.4 เป็นต้นไป เดติดต้นฉบับ http://vuthi.blogspot.com.au/2004/08/java.html
// เดติดต้นฉบับจาก http://vuthi.blogspot.com.au/2004/08/java.html
public String icu_word_segmentation(String txt){
Locale thaiLocale = new Locale("th");
BreakIterator boundary = BreakIterator.getWordInstance(thaiLocale);
boundary.setText(txt);
StringBuffer strout = new StringBuffer();
int start = boundary.first();
for (int end = boundary.next();
end != BreakIterator.DONE;
start = end, end = boundary.next()) {
# -*- coding: utf-8 -*-
"""Implementation of Rapid Automatic Keyword Extraction algorithm.
As described in the paper `Automatic keyword extraction from individual
documents` by Stuart Rose, Dave Engel, Nick Cramer and Wendy Cowley.
Thai language by Mr.Wannaphong Phatthiyaphaibun <wannaphong@kkumail.com>
"""
import string