Jump to content
umarzuki

Nak Buat Application Kamus Free

Recommended Posts

menarik juga kalau ada appliation kamus free tarik/view kamus/daftar kata dari PRPM DBP

ada 2 stage aku nak cuba, tak tau possible ke tak pasal aku bukan programmer, saje nak buat untuk refresh java aku

1- GUI untuk key in carian, papar output dari http://prpm.dbp.gov.my/

basically, bila cari "bola", akan pergi ke http://prpm.dbp.gov.my/Search.aspx?k=bola

prpm_zpsf28ced99.png

2- download daftar kata, semua dictionary dalam PRPM tu untuk offline view (macam impossible)

p/s: kalau aku nak google method yang aku nak guna ni, nak guna keyword apa? Edited by umarzuki

Share this post


Link to post
Share on other sites

uwhhh... huhuhu

dh tgk apps atas tu? lupa nak include kod... ni kodnya...

 

package com.putera.kamus;

/**
 * Created with IntelliJ IDEA.
 * User: Syahmi
 * Date: 16/11/2013
 * Time: 3:29
 * To change this template use File | Settings | File Templates.
 */
public class Kamus {

    public static void main(String[] args) {
        Scraper scraper = new Scraper();

        for (String arg : args) {
            String data[] = scraper.get(arg);
            if (data == null) {
                System.out.println("Ralat");
                return;
            }

            for (String s : data) {
                System.out.println(s);
            }
        }
    }
}
package com.putera.kamus;

import org.jsoup.Jsoup;
import org.jsoup.nodes.*;

import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * Created with IntelliJ IDEA.
 * User: Syahmi
 * Date: 16/11/2013
 * Time: 3:35
 * To change this template use File | Settings | File Templates.
 */
public class Scraper {
    private static final String QUERY_URL = "http://prpm.dbp.gov.my/Search.aspx?k=";

    public String[] get(String word) {
        URL url;
        ArrayList<String> list = new ArrayList<String>();

        try {
            url = new URL(QUERY_URL + URLEncoder.encode(word, "UTF-8"));
            Document doc = Jsoup.parse(url, 30000);
            String resp = "";

            Iterator<Element> it = doc.select(".alternate").iterator();

            while(it.hasNext()) {
                Element e = it.next();
                list.add(e.text());
            }

            String[] array = list.toArray(new String[list.size()]);

            return array;

        } catch (Exception e) {
            String[] error = new String[1];
            error[0] = e.getMessage();

            return error;
        }
    }
}

simple guna jsoup, takyah buat parser sendiri... tinggal nak select2 je...

Edited by syahmixp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...