From e06aaa04b240354e125ad8919cd3332cb3c3bbf6 Mon Sep 17 00:00:00 2001 From: Damar Zaky Date: Mon, 11 Mar 2024 17:18:29 +0700 Subject: [PATCH] Update README.md --- README.md | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d7f66d5..a7a3ee2 100644 --- a/README.md +++ b/README.md @@ -28,40 +28,49 @@ Untuk node.js npm install sastrawijs ``` -Lalu di dalam file +## Import +### ECMAScript + +```javascript +import { Stemmer, Tokenizer } from 'sastrawijs' +``` + +### CommonJS ```javascript -var sastrawi = require("sastrawijs"); +var sastrawijs = require('sastrawijs'); ``` ## Contoh Penggunaan -Web/client +### ECMAScript ```javascript -var sentence = - "Perekonomian Indonesia sedang dalam pertumbuhan yang membanggakan"; -var stemmed = []; -var stemmer = new Stemmer(); -var tokenizer = new Tokenizer(); -words = tokenizer.tokenize(sentence); -for (word of words) { - stemmed.push(stemmer.stem(word)); +const sentence = 'Perekonomian Indonesia sedang dalam pertumbuhan yang membanggakan' +const stemmed = [] + +const stemmer = new Stemmer() +const tokenizer = new Tokenizer() +const words = tokenizer.tokenize(sentence) + +for (const word of words) { + stemmed.push(stemmer.stem(word)) } console.log(stemmed); ``` -Node +### CommonJS ```javascript -var sentence = - "Perekonomian Indonesia sedang dalam pertumbuhan yang membanggakan"; -var stemmed = []; -var stemmer = new sastrawi.Stemmer(); -var tokenizer = new sastrawi.Tokenizer(); -words = tokenizer.tokenize(sentence); -for (word of words) { - stemmed.push(stemmer.stem(word)); +const sentence = 'Perekonomian Indonesia sedang dalam pertumbuhan yang membanggakan' +const stemmed = [] + +const stemmer = new sastrawijs.Stemmer() +const tokenizer = new sastrawijs.Tokenizer() +const words = tokenizer.tokenize(sentence) + +for (const word of words) { + stemmed.push(stemmer.stem(word)) } console.log(stemmed); ```