Hari lahir Pancasila 1 Juni 1945

Hari lahir Pancasila jatuh pada tanggal 1 Juni 1945 yang ditandai oleh pidato yang dilakukan Presiden pertama Indonesia, Ir. Soekarno, dalam sidang Dokuritsu Junbi Cosakai atau BPUPKI (Badan Penyelidik Usaha Persiapan Kemerdekaan Indonesia). Pidatonya pertama kali mengemukakan konsep awal Pancasila yang menjadi dasar negara Indonesia. Pidato yang tidak dipersiapkan secara tertulis terlebih dahulu itu diterima secara aklamasi oleh segenap anggota Dokuritsu Junbi Cosakai.

Dalam kata pengantar atas dibukukannya pidato tersebut, yang untuk pertama kali terbit pada tahun 1947, mantan Ketua BPUPKI Dr. Radjiman Wedyodiningrat menyebut pidato Ir. Soekarno itu berisi “Lahirnya Pancasila”.

Bila kita pelajari dan selidiki sungguh-sungguh “Lahirnya Pancasila” ini, akan ternyata bahwa ini adalah suatu Demokratisch Beginsel, suatu Beginsel yang menjadi dasar Negara kita, yang menjadi Rechtsideologie Negara kita; suatu Beginsel yang telah meresap dan berurat-berakar dalam jiwa Bung Karno, dan yang telah keluar dari jiwanya secara spontan, meskipun sidang ada dibawah penilikan yang keras dari Pemerintah Balatentara Jepang. Memang jiwa yang berhasrat merdeka, tak mungkin dikekang-kekang! Selama Fascisme Jepang berkuasa dinegeri kita, Demokratisch Idee tersebut tak pernah dilepaskan oleh Bung Karno, selalu dipegangnya teguh-teguh dan senantiasa dicarikannya jalan untuk mewujudkannya. Mudah-mudahan ”Lahirnya Pancasila” ini dapat dijadikan pedoman oleh nusa dan bangsa kita seluruhnya dalam usaha memperjuangkan dan menyempurnakan Kemerdekaan Negara.”

Catatan Khusus

Pada tulisan ini saya ingin mencoba melakukan teks analisis dari pidato Bung Karno tersebut dengan beberapa metode text analytics machine learning yaitu RWeka dan Udpipe.

1. Pertama-tama membersihkan memori pada komputer

rm(list=ls())

Memanggil library yang akan digunakan

library(tm)
## Loading required package: NLP
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library (readr)
library(tidytext)
options(scipen=999)
knitr::opts_chunk$set(echo=TRUE, warning=FALSE, message=FALSE)

Memanggil dokumen/naskah pidato

setwd("D:/R/textanalysis/udpipe")
d<-data.frame(text=read_lines("lahirpancasila.txt"))

2. Tampilkan dokumen dalam bentuk tabel

DT::datatable(d)

Selanjutnya Dokuritsu Junbi Cosakai membentuk Panitia Kecil untuk merumuskan dan menyusun Undang-Undang Dasar dengan berpedoman pada pidato Bung Karno tersebut. Dibentuklah Panitia Sembilan (terdiri dari Ir. Soekarno, Mohammad Hatta, Mr. AA Maramis, Abikoesno Tjokrosoejoso, Abdul Kahar Muzakir, Agus Salim, Achmad Soebardjo, Wahid Hasjim, dan Mohammad Yamin) yang ditugaskan untuk merumuskan kembali Pancasila sebagai Dasar Negara berdasar pidato yang diucapkan Bung Karno pada tanggal 1 Juni 1945, dan menjadikan dokumen tersebut sebagai teks untuk memproklamasikan kemerdekaan Indonesia.

2.1. Tampilkan dalam bentuk tabel data

d %>% filter(text != "") %>% mutate(text=as.character(text))->d

d %>% unnest_tokens(word, text)  %>% anti_join(stop_words) -> words

words %>%
  group_by(word) %>%
  count() %>% arrange(-n) ->word_count

2.2. Tampilkan jumlah kata-kata yang terdapat pada naskah

DT::datatable(word_count)

2.3. Tampilkan wordcloudnya

library(wordcloud)

set.seed(1234)
wordcloud(words = word_count$word, freq = word_count$n, min.freq = 3,
          max.words=1000, random.order=FALSE, rot.per=0.10, 
          colors=brewer.pal(5, "Dark2"))

Apabila dilihat tampilan wordcloud, yaitu gambar yang menunjukkan daftar kata-kata yang digunakan dalam sebuah teks belum dapat menginformasi hal-hal penting dari pidato tersebut. Kita perlu membersihkan kata-kata yang tidak penting dan membersihkan naskah tersebut.

2.4. Membersihkan naskah

corpus <- VCorpus(VectorSource(d), 
                  readerControl = list(language = "id", readPlain, load = T))
corpus <- tm_map(corpus, removePunctuation) # menghilangkan tanda baca
corpus <- tm_map(corpus, content_transformer(tolower)) # merubah ke huruf kecil
corpus <- tm_map(corpus, removeNumbers) # menghilangkan nomor
corpus <- tm_map(corpus, PlainTextDocument) # Ubah dokumen menjadi teks
corpus <- tm_map(corpus, stripWhitespace) # menghilangkan spasi

Gunakan library stopwords untuk menghilangkan kata-kata yang tidak penting.

library(stopwords)
myStopwords<-stopwords(language = "id", source = "stopwords-iso", simplify = TRUE)
corpus <- tm_map(corpus, removeWords, myStopwords)

2.5. Tampilkan wordcloudnya setelah dibersihkan

library(wordcloud)
library(tm)
#generate word cloud
set.seed(1234)
wordcloud(words = corpus, min.freq = 5,
          max.words=100, random.order=FALSE, rot.per=0.20, 
          colors=brewer.pal(8, "Dark2"))

Nah, sekarang kata-kata penting yang ditampilkan bisa kita lihat…

3. Analisis menggunakan RWeka

RWeka is a collection of machine learning algorithms for data mining tasks written in Java, containing tools for data pre-processing, classification, regression, clustering, association rules, and visualization. Package ‘RWeka’ contains the interface code, the Weka jar is in a separate package ‘RWekajars’. For more information on Weka see http://www.cs.waikato.ac.nz/ml/weka/.

library(RWeka)
library(ggplot2)

3.1. Barplot untuk 1 kata

tokenizer1 <- function(x) NGramTokenizer(x, Weka_control(min = 1, max = 1))
uni_gram <- TermDocumentMatrix(corpus, control = list(tokenize = tokenizer1))
uni_gram <- as.data.frame(as.matrix(uni_gram))
uni_gram <- rowSums(uni_gram)
uni_gram <- sort(uni_gram, decreasing = T)
uni_gram_frame<-data.frame(uni_gram)
barplot(uni_gram[1:10], main="Satu Kata",cex.names=.5, cex.axis=.1,las = 2,horiz=TRUE)

3.2. Barplot untuk 2 kata

tokenizer2 <- function(x) NGramTokenizer(x, Weka_control(min = 2, max = 2))
bi_gram <- TermDocumentMatrix(corpus, control = list(tokenize = tokenizer2))
bi_gram <- as.data.frame(as.matrix(bi_gram))
bi_gram <- rowSums(bi_gram)
bi_gram <- sort(bi_gram, decreasing = T)
barplot(bi_gram[1:10], main="Dua Kata", cex.names=.5,cex.axis=.1,las = 2,horiz=TRUE)

3.3. Barplot untuk 3 kata

tokenizer3 <- function(x) NGramTokenizer(x, Weka_control(min = 3, max = 3))
tri_gram <- TermDocumentMatrix(corpus, control = list(tokenize = tokenizer3))
tri_gram <- as.data.frame(as.matrix(tri_gram))
tri_gram <- rowSums(tri_gram)
tri_gram <- sort(tri_gram, decreasing = T)
tri_gram_frame<-data.frame(tri_gram)
barplot(tri_gram[1:10], main="Tiga Kata", cex.names=.5, cex.axis=.1,las = 2,horiz=TRUE)

Berdasarkan tampilan Grafik kita bisa melihat kata-kata yang dianggap memiliki makna dalam naskah tersebut.

4. Analisis menggunakan Udpipe

This natural language processing toolkit provides language-agnostic ‘tokenization’, ‘parts of speech tagging’, ‘lemmatization’ and ‘dependency parsing’ of raw text. Next to text parsing, the package also allows you to train annotation models based on data of ‘treebanks’ in ‘CoNLL-U’ format as provided at https://universaldependencies.org/format.html. The techniques are explained in detail in the paper: ‘Tokenizing, POS Tagging, Lemmatizing and Parsing UD 2.0 with UDPipe’, available at doi:10.18653/v1/K17-3009.

# Load Packages and Libraries
packages=c('dplyr', 'tidyverse', 'udpipe', 'ggplot2',
           'igraph', 'ggraph', 'knitr', 'textrank', 'wordcloud')

for (p in packages){
  if (! require (p,character.only = T)){
    install.packages(p)
  }
  library(p,character.only = T)
}

4.1. Memanggil model dan library bahasa Indonesia

setwd("D:/R/textanalysis/udpipe")


udmodel <- udpipe_load_model(file = 'indonesian-gsd-ud-2.5-191206.udpipe')
pidato <- read.table(file="lahirpancasila.txt", sep=";", quote="\n")

s <- udpipe_annotate(udmodel, x = pidato$V1)
x <- as.data.frame(s)

4.2. Memanggil model dan library bahasa Indonesia

Pengelompokkan Kata benda (Noun), Kata Sifat (Adj), Kata Kerja (Verb)

annot_plot <- x %>%
  filter(upos %in% c("NOUN","ADJ","VERB")) %>%
  group_by(upos) %>%
  count(lemma, sort=T)

library(ggwordcloud)
ggplot(annot_plot %>% filter(n>7), aes(label = lemma, size = n, color=n)) +
  geom_text_wordcloud(eccentricity = 1) +
  scale_size_area(max_size = 7) +
  theme_minimal() +
  facet_wrap(~upos)

4.3. Pengelompokkan berbagai jenis Kata

stats <- txt_freq(x$upos)
# stats

stats$key <- factor(stats$key, levels = rev(stats$key))
# Plot
stats %>% ggplot() + 
  geom_bar(aes(x = key, y = freq), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "UPOS (Universal Parts of Speech)",
       subtitle = "Frequency of occurrence",
       caption = "Pidato Bung Karno: lahirnya Pancasila")

4.4.Kata Benda (NOUNS)

stats <- subset(x, upos %in% c("NOUN")) 
stats <- txt_freq(stats$token)
# stats
stats$key <- factor(stats$key, levels = rev(stats$key))
# Plot
stats %>% head(20) %>% ggplot() + 
  geom_bar(aes(x = key, y = freq), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "UPOS (Universal Parts of Speech)",
       subtitle = "Most occurring nouns",
       caption = "Pidato Bung Karno: lahirnya Pancasila")

4.5.Kata Benda Spesifik (PROPER NOUNS)

stats <- subset(x, upos %in% c("NOUN", "PROPN")) 
stats <- txt_freq(stats$token)
# stats
stats$key <- factor(stats$key, levels = rev(stats$key))
# Plot
stats %>% head(20) %>% ggplot() + 
  geom_bar(aes(x = key, y = freq), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "UPOS (Universal Parts of Speech)",
       subtitle = "Most Occurring Nouns and Proper Nouns",
       caption = "Pidato Bung Karno: lahirnya Pancasila",
       y = "Frequency",
       x = "Keywords")        

4.6.Kata Sifat (ADJECTIVES)

stats <- subset(x, upos %in% c("ADJ")) 
stats <- txt_freq(stats$token)
# stats
stats$key <- factor(stats$key, levels = rev(stats$key))
# Plot
stats %>% head(20) %>% ggplot() + 
  geom_bar(aes(x = key, y = freq), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "UPOS (Universal Parts of Speech)",
       subtitle = "Most Occurring Adjectives",
       caption = "Pidato Bung Karno: lahirnya Pancasila",
       y = "Frequency",
       x = "Keywords")

4.7.Kata Kerja (VERBS)

stats <- subset(x, upos %in% c("VERB")) 
stats <- txt_freq(stats$token)
# stats
stats$key <- factor(stats$key, levels = rev(stats$key))
# Plot
stats %>% head(20) %>% ggplot() + 
  geom_bar(aes(x = key, y = freq), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "UPOS (Universal Parts of Speech)",
       subtitle = "Most Occurring Verbs",
       caption = "Pidato Bung Karno: lahirnya Pancasila",
       y = "Frequency",
       x = "Keywords")

4.8. Gabungan kata-kata

Kita ingin melihat seberapa sering kata benda (Nouns), kata benda yang proper (Proper Nouns), kata sifat (Adjectives). kata kerja (Verbs) dan kata keterangan yang digunakan untuk menjelaskan kata sifat (Adverbs)

cooccur <- cooccurrence(x = subset(x, upos %in% c("NOUN", "PROPN", "VERB",
                                                  "ADJ", "ADV")), 
                        term = "lemma", 
                        group = c("doc_id", "paragraph_id", "sentence_id"))
head(cooccur,20)
##         term1     term2 cooc
## 1   indonesia   merdeka   95
## 2   indonesia    negara   56
## 3      bangsa indonesia   46
## 4   menpunyai     sudah   38
## 5         ada    bangsa   36
## 6     merdeka    negara   36
## 7       hidup     ingin   31
## 8   indonesia     orang   31
## 9       islam    rakyat   31
## 10 mendirikan    negara   29
## 11        ada    rakyat   28
## 12  indonesia   menjadi   27
## 13  indonesia  sekarang   27
## 14    merdeka  sekarang   27
## 15        ada     sudah   25
## 16     bangsa  tionghoa   23
## 17        ada  tionghoa   22
## 18     paduka      tuan   21
## 19    merdeka    rakyat   20
## 20       akan indonesia   19

4.9. Korelasi antara kata-kata

Korelasi antara Kata-kata kunci menunjukkan seberapa besar tingkat hubungan yang disampaikan pada naskah/dokumen tersebut.

x$id <- unique_identifier(x, fields = c("sentence_id", "doc_id"))
dtm <- subset(x, upos %in% c("NOUN", "PROPN", "VERB", "ADV", "ADJ"))
dtm <- document_term_frequencies(dtm, document = "id", term = "lemma")
dtm <- document_term_matrix(dtm)
dtm <- dtm_remove_lowfreq(dtm, minfreq = 5)
termcorrelations <- dtm_cor(dtm)
y <- as_cooccurrence(termcorrelations)
y <- subset(y, term1 < term2 & abs(cooc) > 0.2)
y <- y[order(abs(y$cooc), decreasing = TRUE), ]
head(y, 20)
##                  term1     term2      cooc
## 9474             Bauer      otto 1.0000000
## 11399     independence political 1.0000000
## 13768              ibn      saud 1.0000000
## 21105        Tyoosakai    Zyunbi 1.0000000
## 13568              chu       san 1.0000000
## 20484              sun       Yat 1.0000000
## 9687             ketua    paduka 0.9724085
## 17195              Sen       sun 0.9480159
## 20475              Sen       Yat 0.9480159
## 12620           Ernest     Renan 0.9421963
## 7913               chu       Min 0.9230272
## 13656              Min       san 0.9230272
## 5396            d’etre        le 0.9118014
## 16267 rechtvaardigheid   sociale 0.9101971
## 17770              air     tanah 0.8884311
## 4719      Hadikoesoemo        ki 0.8805734
## 5277             benua    lautan 0.8696514
## 5405             desir        le 0.8639901
## 8352             ketua     mulia 0.8486293
## 14376           Arabia     saudi 0.8261869

4.10. Analisis Teks menggunakan RAKE (Rapid Automatic Keyword Extraction)

RAKE is one of the most popular (unsupervised) algorithms for extracting keywords.RAKE is a domain independent keyword extraction algorithm which tries to determine key phrases in a body of text by analyzing the frequency of word appearances and its co-occurrence with other words in the text.

stats <- keywords_rake(x = x, term = "lemma", group = "doc_id", 
                       relevant = x$upos %in% c("NOUN", "PROPN", "VERB", "ADJ"))
# stats
stats$key <- factor(stats$keyword, levels = rev(stats$keyword))
head(subset(stats, freq > 2), 30) %>% ggplot() + 
  geom_bar(aes(x = key, y = rake), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "Keywords (NOUN, PROPN, VERB, ADJ) identified by RAKE",
       caption = "Pidato Bung Karno Lahirnya Pancasila, 1 Juni 1945",
       y = "Rake",
       x = "Keywords")

4.11. Analisis Teks menggunakan PMI (Pointwise Mutual Information Collocations)

Pointwise mutual information (PMI, 5) is a measure of how much the actual probability of a particular co-occurrence of events p(x, y) differs from what we would expect it to be on the basis of the probabilities of the individual events and the assumption of independence p(x)p(y).

x$word <- tolower(x$token)
stats <- keywords_collocation(x = x, term = "word", group = "doc_id")
stats$key <- factor(stats$keyword, levels = rev(stats$keyword))
# stats
head(subset(stats, freq > 2), 30) %>% ggplot() + 
  geom_bar(aes(x = key, y = pmi), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "Keywords identified by PMI Collocation",
       caption = "Pidato Bung Karno Lahirnya Pancasila, 1 Juni 1945",
       y = "PMI (Pointwise Mutual Information)",
       x = "Keywords")

4.12. Analisis Teks menggunakan gabungan POS tags (Part of Speech)

Another option is to extract phrases. In traditional grammar, a part of speech (POS) is a category of words that have similar grammatical properties. The part of speech explains how a word is used in a sentence. There are eight parts of speech in the English language: noun, pronoun, verb, adjective, adverb, preposition, conjunction, and interjection. - Noun (N) — John, London, Table, Teacher, Pen, City, Happiness, Hope - Pronoun(PRO) — I, We, They, You, He, She, It, Me, Us, Them, Him, Her, This, That - Verb (V) — Read, Eat, Go, Speak, Run, Play, Live, Have, Like, Are, Is - Adverb(ADV) — Slowly, Quietly, Very, Always, Never, Too, Well, Tomorrow - Adjective(ADJ) — Big, Happy, Green, Young, Fun, Crazy, Three - Preposition (P) — At, On, In, From, With, Near, Between, About, Under - Conjunction (CON) — And, Or,But, Because, So, Yet, Unless, Since, If - Interjection (INT) — Ouch! Wow! Great! Help! Oh! Hey! Hi!

x$phrase_tag <- as_phrasemachine(x$upos, type = "upos")
stats <- keywords_phrases(x = x$phrase_tag, term = tolower(x$token), 
                          pattern = "(A|N)*N(P+D*(A|N)*N)*", 
                          is_regex = TRUE, detailed = FALSE)
stats <- subset(stats, ngram > 1 & freq > 3)
stats$key <- factor(stats$keyword, levels = rev(stats$keyword))
# stats
head(stats, 30) %>% ggplot() + 
  geom_bar(aes(x = key, y = freq), stat = "identity", fill = "#6495ED") + 
  theme_minimal() + 
  coord_flip() +
  labs(title = "Keywords - simple noun phrases",
       caption = "Pidato Bung Karno Lahirnya Pancasila, 1 Juni 1945",
       y = "Frequency",
       x = "Keywords")

4.12. Analisis Teks menggunakan Textrank

Textrank is a word network ordered by Google Pagerank as implemented in the textrank R package. The algorithm allows to summarise text and extract keywords.This is done by constructing a word network by looking if words are following one another. On top of that network the ‘Google Pagerank’ algorithm is applied to extract relevant words after which the relevant words which are following one another are combined to get keywords. In the below example, we are interested in finding keywords using that algorithm of either “NOUN”, “PROPN”, “VERB”, “ADJ” following one another.

library(textrank)
stats <- textrank_keywords(x$lemma, 
                           relevant = x$upos %in% c("NOUN", "PROPN", "VERB", "ADJ"), 
                           ngram_max = 20, sep = " ")
stats <- subset(stats$keywords, ngram > 1 & freq >= 2)
stats
##                                 keyword ngram freq
## 3                     indonesia merdeka     2   44
## 23                     negara indonesia     2   17
## 27                    paduka tuan ketua     3   15
## 28                           tuan ketua     2   15
## 31                     bangsa indonesia     2   14
## 34                      nationale staat     2   13
## 47                    perwakilan rakyat     2   10
## 49             negara indonesia merdeka     3    9
## 55                            tanah air     2    9
## 72              badan perwakilan rakyat     3    8
## 76                          san Min chu     3    7
## 77                              Min chu     2    7
## 81                 kebangsaan indonesia     2    7
## 84             sociale rechtvaardigheid     2    7
## 87               political independence     2    6
## 90                   tuan-tuan sekalian     2    6
## 91  mendirikan negara indonesia merdeka     4    6
## 94                         Ernest Renan     2    6
## 96                           otto Bauer     2    6
## 100                    Zyunbi Tyoosakai     2    5
## 106                           sama lain     2    5
## 108                saudi Arabia merdeka     3    5
## 109                      Arabia merdeka     2    5
## 110                            ibn saud     2    5
## 113                        saudi Arabia     2    5
## 119                        berani kawin     2    5
## 120         mendirikan negara indonesia     3    5
## 123                         sun Yat Sen     3    5
## 124                             Yat Sen     2    5
## 127                         orang islam     2    5
## 130                          anak kecil     2    5
## 132                          Panca Sila     2    5
## 134           Dokuritu Zyunbi Tyoosakai     3    4
## 139                   seberang jembatan     2    4
## 142                      baru menadakan     2    4
## 143                     orang indonesia     2    4
## 144                berpuluh-puluh tahun     2    4
## 145              ki Bagoes Hadikoesoemo     3    4
## 146                 Bagoes Hadikoesoemo     2    4
## 147                    dasar kebangsaan     2    4
## 150                         allah s.w.t     2    4
## 151                          peta dunia     2    4
## 152                     bangsa tionghoa     2    4
## 157                   menjadi realiteit     2    4
## 158             dasar indonesia merdeka     3    3
## 159                      negara merdeka     2    3
## 160                        soviet rusia     2    3
## 166          indonesia merdeka sekarang     3    3
## 167                    merdeka sekarang     2    3
## 172                          orang lain     2    3
## 176                   mendirikan negara     2    3
## 177                           the three     2    3
## 181      saudara ki Bagoes Hadikoesoemo     4    3
## 182                       syarat bangsa     2    3
## 183            le desir d’etre ensemble     4    3
## 184               desir d’etre ensemble     3    3
## 185                     d’etre ensemble     2    3
## 186                 definisi otto Bauer     3    3
## 197                          ada bangsa     2    3
## 201                    badan perwakilan     2    3
## 202                      ada perjoangan     2    3
## 203                      kaum kapitalis     2    3
## 206                 dinamakan politieke     2    2
## 207      berani mennyatakan kemerdekaan     3    2
## 208             mennyatakan kemerdekaan     2    2
## 210                       rusia merdeka     2    2
## 211                       rakyat Arabia     2    2
## 212      Lenin mendirikan negara soviet     4    2
## 213            mendirikan negara soviet     3    2
## 214                       negara soviet     2    2
## 215                        rakyat rusia     2    2
## 217                   dinamakan merdeka     2    2
## 220                           one night     2    2
## 222                Soviet-Rusia merdeka     2    2
## 223                        sungai dnepr     2    2
## 225          semboyan indonesia merdeka     3    2
## 227                          Dai nippon     2    2
## 228                       urusan negara     2    2
## 231                      ada orang lain     3    2
## 232                          sang Ndoro     2    2
## 235            saudara-saudara sekalian     2    2
## 237                            ada bumi     2    2
## 238                          ada rakyat     2    2
## 240                        dasar negara     2    2
## 242                         negara baru     2    2
## 244                   menberi kekuasaan     2    2
## 247               tuan bangsa indonesia     3    2
## 248               definisi Ernest Renan     3    2
## 251                          benua asia     2    2
## 253                     le desir d’etre     3    2
## 254                        desir d’etre     2    2
## 256                     Nationale staat     2    2
## 258                        sultan agung     2    2
## 260                    perrasaan hormat     2    2
## 264               dasar permusyawaratan     2    2
## 265                          hati islam     2    2
## 266                        rakyat islam     2    2
## 267                         agama islam     2    2
## 268             prinsip permusyawaratan     2    2
## 269                       orang kristen     2    2
## 271                         jean Jaures     2    2
## 273                politieke democratie     2    2
## 274            Parlementaire Democratie     2    2
## 276                menjatuhkan minister     2    2
## 280                kesejahteraan sosial     2    2
## 281                    rakyat indonesia     2    2
## 282               badan permusyawaratan     2    2
## 283                     ki Hadikoesoemo     2    2
## 284                            Maha esa     2    2
## 287                       nabi muhammad     2    2
## 289                       namakan socio     2    2
## 292                   zonder perjoangan     2    2
## 293           zonder perjoangan manusia     3    2
## 294                  perjoangan manusia     2    2
## 295                          minta maaf     2    2
# library(wordcloud)
wordcloud(words = stats$keyword, freq = stats$freq, random.order=FALSE, colors=brewer.pal(8, "Dark2"))

5. COOCCURENCE

Kita ingin melihat seberapa sering kata benda (Nouns), kata benda yang proper (proper nouns), kata sifat (adjectives). kata kerja (verbs) dan kata keterangan yang digunakan untuk menjelaskan kata sifat (adverbs)

cooccur <- cooccurrence(x = subset(x, upos %in% c("NOUN", "PROPN", "VERB",
                                                  "ADJ", "ADV")), 
                        term = "lemma", 
                        group = c("doc_id", "paragraph_id", "sentence_id"))
head(cooccur,20)
##         term1     term2 cooc
## 1   indonesia   merdeka   95
## 2   indonesia    negara   56
## 3      bangsa indonesia   46
## 4   menpunyai     sudah   38
## 5         ada    bangsa   36
## 6     merdeka    negara   36
## 7       hidup     ingin   31
## 8   indonesia     orang   31
## 9       islam    rakyat   31
## 10 mendirikan    negara   29
## 11        ada    rakyat   28
## 12  indonesia   menjadi   27
## 13  indonesia  sekarang   27
## 14    merdeka  sekarang   27
## 15        ada     sudah   25
## 16     bangsa  tionghoa   23
## 17        ada  tionghoa   22
## 18     paduka      tuan   21
## 19    merdeka    rakyat   20
## 20       akan indonesia   19

5.1. Hasilnya capat divisualisasikan sebagai berikut

library(igraph)
library(ggraph)
library(ggplot2)
word_visual <- head(cooccur, 100)
word_visual <- graph_from_data_frame(word_visual)
ggraph(word_visual, layout = "fr") +
  geom_edge_link(aes(width = cooc, edge_alpha = cooc), edge_colour = "#6495ED") +
  geom_node_point(aes(size = igraph::degree(word_visual)), shape = 1, color = "black") +
  geom_node_text(aes(label = name), col = "darkblue", size = 3) +
  labs(title = "Co-occurrences within sentence",
       subtitle = "Top 100 Nouns, Names, Adjectives, Verbs, Adverbs",
       caption = "Pidato Bung Karno: lahirnya Pancasila")

5.2 Cooccurences with POS

Words which follow one another Visualising which words follow one another can be done by calculating word cooccurrences of a specific POS type which follow one another and specify how far away we want to look regarding ‘following one another’ (in the example below we indicate skipgram = 1 which means look to the next word and the word after that). Here we include the major POS.

cooccur <- cooccurrence(x$lemma,
                        relevant = x$upos %in% c("NOUN", "PROPN", "VERB", "ADV", "ADJ"),
                        skipgram = 1)

head(cooccur, 20)
##         term1        term2 cooc
## 1   indonesia      merdeka   49
## 2      negara    indonesia   27
## 3  mendirikan       negara   24
## 4      paduka         tuan   17
## 5        tuan        ketua   16
## 6      negara      merdeka   16
## 7      paduka        ketua   16
## 8      bangsa    indonesia   15
## 9  mendirikan    indonesia   13
## 10  nationale        staat   13
## 11      badan   perwakilan   12
## 12        ibn         saud   11
## 13 perwakilan       rakyat   11
## 14      ketua        mulia   11
## 15      saudi       Arabia   10
## 16      tanah          air    9
## 17         ki Hadikoesoemo    8
## 18      badan       rakyat    8
## 19      sudah    menpunyai    7
## 20        san          Min    7

5.3. Hasilnya capat divisualisasikan sebagai berikut

word_visual <- head(cooccur, 100)
word_visual <- graph_from_data_frame(word_visual)
ggraph(word_visual, layout = "fr") +
  geom_edge_link(aes(width = cooc, edge_alpha = cooc), edge_colour = "#6495ED") +
  geom_node_text(aes(label = name), col = "darkblue", size = 3, repel = TRUE) +
  labs(title = "Kata-kata yang saling mengikuti satu dengan lainnya",
       caption = "Pidato Bung Karno Lahirnya Pancasila, 1 Juni 1945")

5. Kesimpulan

Berdasarkan hasil teks analisis menggunakan beberapa model machine learning (RWeka dan Udpipe), ada beberapa hal yang menarik dari pidato Bung Karno tersebut, kata-kata: indonesia, merdeka, saudarasaudara, negara, rakyat, bangsa, orang, islam, mendirikan berulang-ulang diucapkan beliau. Dua kata yang bermakna dalam pidatonya yaitu indonesia merdeka, negara indonesia, mendirikan negara, nationale staat, paduka tuan, bangsa indonesia, tuan ketua, badan perwakilan, ibn saud, ketua mulia.

Kita juga bisa menangkap jenis-jenis kata benda, kata sifat dan kata kerja yang banyak digunakan dalam pidato tersebut.

Dari analisis teks menggunakan RAKE dan PIM kita juga bisa mengetahui makna yang populer dan siapa-siapa saja menginspirasi Bung Karno dalam menyampaikan konsep negara Indonesia, Kemerdekaan dan Pancasila.

Analisis menggunakan textrank menunjukkan berbagai pasangan kata penting yang menjadi frasa dalam pidato tersebut.

Referensi

Semoga bermanfaat.