Monday, June 8, 2020

Extracting information from a dynamic webpage with RSelenium - I


The COVID-19 Contact Tracing and Reporting webpage of the Ministry of Health and Sports (MOHS). Myanmar is available here.
knitr::include_graphics("caseSelection.png")
Here, information on the last reported case-151 is displayed by default, and case-150 is displayed by clicking the tab in the middle. To get other cases you can open the dropdown list of case numbers at “View More” and make a selection. The dropdown list is quite long and you can see that it would be inconvenient to scroll down the list and click “Case-1” at the very end. But a blinking cursor invites you to enter case number, for example, “120” and you get case highlighted in black. Now you click on it and information for case-120 is displayed. But entering “1” and it highlights “Case 151” for you. If you try " 1" or “001” you get the message “No results found”.
In the context of learning to do NLP on Myanmar language, my last three posts reported on the results of exploring the COVID-19 surveillance reports of MOHS. In this post, I’ll try to scrape the contact tracing information on the confirmed Covid-19 infected cases.

Requirements for scraping a dynamic webpage

Web scraping/web mining/web harvesting means extracting data from websites. “… websites contain wealth of useful data but designed for human consumption and not data analysis. The goal of web scraping is to take advantage of the pattern or structure of web pages to extract and store data in a format suitable for data analysis.”
The webpages like the MOHS COVID-19 Contact Tracing and Reporting webpage are dynamically generated webpages. They require user interaction to display results. I learned that in such contexts web scraping couldn’t be handled by a tool like rvest. The reason is that such webpages typically use Java scripts to produce dynamic content and rvest is not designed to handle them. Looking for a solution, I found that I could use RSelenium package, among others.
The RSelenium package “… can be used to automate those interactions and extract page contents. It provides a set of bindings for the Selenium 2.0 webdriver using the JsonWireProtocol. It can also aid in automated application testing, load testing, and web scraping.”

Using RSelenium

I’ve installed the RSelenium ver. 1.7.7 package which also took care of installing the required Selenium Server software. The recommended practice is to run RSelenium in a Docker container and I’ve also installed the docker desktop ver. 2.3.0.3(45519). I am using a laptop with Intel i7 processor, 16GB RAM and running Windows 10. This post has been created with R Notebook in RStudio ver. 1.2.5042.

Start the Selenium server and chrome browser

With windows startup, the Doker Desktop is also started. In the RStudio Terminal you would start Selenium server in docker container with: “docker run -d -p 4445:4444 selenium/standalone-chrome”. Then you start the server and browser and navigate to the MOHS webpage:
# Load the Library
library(RSelenium)
# start the server and browser(you can use other browsers here)
rD <- remoteDriver(remoteServerAddr = "localhost",
                      port = 4445L,
                      browserName = "chrome")
rD$open()
[1] "Connecting to remote server"
$acceptInsecureCerts
[1] FALSE

$browserName
[1] "chrome"

$browserVersion
[1] "81.0.4044.138"

$chrome
$chrome$chromedriverVersion
[1] "81.0.4044.138 (8c6c7ba89cc9453625af54f11fd83179e23450fa-refs/branch-heads/4044@{#999})"

$chrome$userDataDir
[1] "/tmp/.com.google.Chrome.nFtAQN"


$`goog:chromeOptions`
$`goog:chromeOptions`$debuggerAddress
[1] "localhost:46211"


$networkConnectionEnabled
[1] FALSE

$pageLoadStrategy
[1] "normal"

$platformName
[1] "linux"

$proxy
named list()

$setWindowRect
[1] TRUE

$strictFileInteractability
[1] FALSE

$timeouts
$timeouts$implicit
[1] 0

$timeouts$pageLoad
[1] 300000

$timeouts$script
[1] 30000


$unhandledPromptBehavior
[1] "dismiss and notify"

$`webauthn:virtualAuthenticators`
[1] TRUE

$webdriver.remote.sessionid
[1] "0782f983bf5db88192ae2e4fb29cc3cf"

$id
[1] "0782f983bf5db88192ae2e4fb29cc3cf"
# navigate to URL for MOHS contact tracing and reporting
rD$navigate("https://mohs.gov.mm/page/8509")
You can view the screen shot of the web page. It is shown in the RStudio viewer:
rD$screenshot(display = TRUE)

Retrieving information on case-151 and 150

On the webpage, Case-151, case-150, and all other cases are represented dynamically by three separate elements. I learnt later that they are displayed via three aria-controls. You could retrieve Case-151 and case-150 like this:
caseTexts <- list()
case151 <- rD$findElement(using="css selector", ".nav-tabs > li:nth-child(1) > a:nth-child(1)")
case151$clickElement()
ct151 <- rD$findElement(using="css selector", "#Post_10137")
caseTexts <- append(caseTexts,ct151$getElementText())
cat(caseTexts[[1]])
C - 151 ဓာတ်ခွဲအတည်ပြုလူနာ
အသက် - (၂၅) နှစ်၊ မ
နေရပ်လိပ်စာ - အင်းစိန်မြို့နယ်၊ ရန်ကုန်တိုင်းဒေသကြီး
ရောဂါလက္ခဏာဖြစ်ပွားခြင်း - နှာစေးခြင်း၊ အနံ့ပျောက်ခြင်း
ရောဂါလက္ခဏာစတင်ဖြစ်ပွားသည့်ရက် - ၂၄-၄-၂၀၂၀
ပြသခဲ့သည့်ဆေးရုံ - Fever clinic မှတဆင့် အင်းစိန်အထွေထွေရောဂါကုဆေးရုံကြီး
ဓာတ်ခွဲအတည်ပြုလူနာနှင့်ထိတွေ့ခြင်း - မရှိ
ဓာတ်ခွဲအတည်ပြုသည့်ရက်စွဲ - ၁-၅-၂၀၂၀
ပြည်ပခရီးသွားရာဇဝင် - မရှိ
အတူနေမိသားစုဝင် - (၆) ဦး
ဓာတ်ခွဲအတည်ပြုစစ်ဆေးတွေ့ရှိပြီးချိန်မှစ၍ အဆိုပါလူနာအား တောင်ဥက္ကလာပအထူးကုဆေးရုံကြီးတွင် သီးခြားထားရှိကုသမှုပေးလျက်ရှိပါသည်။
လူနာနှင့်အနီးကပ်ထိတွေ့သူများအား အသွားအလာတားမြစ်ပိတ်ပင်၍ ဓာတ်ခွဲနမူနာ ရယူစစ်ဆေးပြီးဖြစ်ပါသည်။
ခရီးသွားရာဇဝင်
ရောဂါလက္ခဏာာမပေါ်မီ (၂) ရက်နှင့် ရောဂါလက္ခဏာပေါ်ပြီးနောက် Fever clinic (အင်းစိန်) သို့သွားခြင်းမှအပ ပြင်ပသို့ သွားရောက်ခဲ့ခြင်းမရှိကြောင်းသိရှိရပါသည်။
 
case150 <- rD$findElement(using="css selector", ".nav-tabs > li:nth-child(2) > a:nth-child(1)")
case150$clickElement()
ct150 <- rD$findElement(using="css selector", "#Post_10135")
caseTexts <- append(caseTexts,ct150$getElementText())
cat(caseTexts[[2]])
C - 150 ဓာတ်ခွဲအတည်ပြုလူနာ
အသက် - (၁၈) နှစ်၊ မ
နေရပ်လိပ်စာ - ဟားခါးမြို့နယ်၊ ချင်းပြည်နယ်  
ရောဂါလက္ခဏာဖြစ်ပွားခြင်း - မရှိ
ပြသခဲ့သည့်ဆေးရုံ - မရှိ
ဓာတ်ခွဲအတည်ပြုလူနာနှင့်ထိတွေ့ခြင်း - မရှိ
အသွားအလာကန့်သတ်သည့်ရက်စွဲ - ၁၆-၄-၂၀၂၀ (ဟားခါးမြို့)
ဓာတ်ခွဲအတည်ပြုသည့်ရက်စွဲ - ၂၉-၄-၂၀၂၀
ပြည်ပခရီးသွားရာဇဝင် - ရှိ (တရုတ်နိုင်ငံ)
ဓာတ်ခွဲအတည်ပြုစစ်ဆေးတွေ့ရှိပြီးချိန်မှစ၍ အဆိုပါလူနာအား ဟားခါးပြည်သူ့ဆေးရုံကြီးတွင် သီးခြားထားရှိကုသမှုပေးလျက်ရှိပါသည်။
အနီးကပ်ထိတွေ့ခဲ့သူများအား အသွားအလာတားမြစ် ပိတ်ပင်၍ ဓာတ်ခွဲနမူနာ ရယူစစ်ဆေးပြီးဖြစ်ပါသည်။
ခရီးသွားရာဇဝင်
ရက်စွဲ သွားရောက်ခဲ့သည့်နေရာ အသုံးပြုသည့်ယာဉ် မှတ်ချက်
၂၀-၃-၂၀၂၀ တရုတ်နိုင်ငံမှ ရှမ်းပြည်နယ်၊ မူဆယ်မြို့ မူဆယ်မြို့ရှိတည်းခိုးခန်း တစ်ခုတွင် တည်းခိုခဲ့ပါသည်။
၂၁-၃-၂၀၂၀ မနက် (၈:၀၀) နာရီ မန္တလေး ရွှေမန္တလာ အဝေးပြေးယာဉ် မန္တလေးမြို့သို့ (၂၃-၃-၂၀၂၀) ရက်နေ့ မနက် (၁:၀၀) နာရီတွင် ရောက်ရှိခဲ့ပါသည်။
၂၄-၃-၂၀၂၀ မနက် (၈:၀၀) နာရီ ကလေးမြို့ ရွှေမန္တလာ အဝေးပြေးယာဉ် (၂၅-၃-၂၀၂၀) ရက်နေ့ မနက် (၁:၀၀) နာရီတွင် ကလေးမြို့ သို့ရောက်ရှိခဲ့ပါသည်။
၂၄-၃-၂၀၂၀ မှ ၅-၄-၂၀၂၀ ထိ ကလေးမြို့ သူငယ်ချင်းဖြစ်သူ၏နေအိမ်တွင် တည်းခိုနေထိုင်ခဲ့ပါသည်။
၅-၄-၂၀၂၀ ညနေ (၄:၀၀) နာရီ ဟားခါးမြို့ တောင်ဇလပ်ယာဉ်(အသေး) ဟားခါးမြို့ကားဂိတ်သို့ (၆-၄-၂၀၂၀) ရက်နေ့ နေ့လည် (၁:၃၀) နာရီတွင်ရောက်ရှိခဲ့ပါသည်။
(၆-၄-၂၀၂၀) ရက်နေ့ နေ့လည်(၁:၄၅) နာရီ သီဖူးလ်ကျေးရွာ၊ ဟာခါးမြို့နယ် တောင်ဇလပ်ယာဉ်(အသေး) (၆-၄-၂၀၂၀) ရက်နေ့ နေ့လည် (၃:၃၀) နာရီတွင် ၎င်း၏ဖခင် အိမ်သို့ ရောက်ရှိခဲ့ပါသည်။ (၁၃-၄-၂၀၂၀) ရက်နေ့ထိ နေထိုင်ခဲ့ပါသည်။
၁၃-၄-၂၀၂၀ ဟားခါးမြို့ သီဖူးလ်ကျေးရွာမှ ဟာခါးမြို့သို့ ပြန်လည်ထွက်ခွာခဲ့ပါသည်။
                   

Retrieving information on case-1

To try retrieving information for other cases, I have to locate the “View More” tab, and click on it to open the select case dropdown list.
# find element view more
casey <- rD$findElement(using="css selector", "#recentcase li:nth-child(3) a")
rD$screenshot(display = TRUE)
# click view more and "select the case box" is opened
casey$clickElement()
rD$screenshot(display = TRUE)
# after clicking  view more  find "#select2-slcase-container"
caseM <- rD$findElement(using="css selector","#select2-slcase-container") 
caseM$clickElement()      # need to click caseM to open
rD$screenshot(display = TRUE)
Up to the previous step it was fine. Then I was stuck with entering the case number at the cursor and then to find the highlighted case number, which when clicked would retrieve the information for the case in question. The problem was with locating the highlighted text of selected case-number. I tried using the Selector Gadget as well as the “Inspect” option on the page source to find the right locator for that purpose.
I tried with Chrome as well as Firefox browser and also looked and tried out solutions from Selenium tutorials and the StackOverflow Q/A site. I struggled with that for more than a week. Finally, I got the clue that I have to look for some solution to find the web element associated with some dropdown list. Also, from the inspection of the page-source of the MOHS webpage I found how a given case-number is associated with an appropriate case-code:
knitr::include_graphics("caseOption.png")
Then I was lucky to hit upon the right xpath specification, for example, to find the web element for case-1, whose code is “528”. When this element is located and clicked, information on case-1 should be displayed on the webpage at the web element with id = “OtherCase_Info”.
case_1 <- rD$findElement(using = 'xpath', "//*[@value = '528']")
# Sys.sleep(2)
case_1$clickElement()
To able to see that information we may have to scroll down the page once and view the screen shot:
# find the webpage body
bodelement <- rD$findElement("css", "body")
#scroll down once
bodelement$sendKeysToElement(list(key = "page_down"))
rD$screenshot(display = TRUE)
You can locate the element on the webpage where this information is displayed and view the information with cat() function:
case1_text <- rD$findElement(using = 'css selector', "#OtherCase_Info")
cat(paste0(case1_text$getElementText()))
C-1 ဓာတ်ခွဲအတည်ပြုလူနာ
  အဆိုပါလူနာသည် ၎င်း၏မိခင်နှင့်အတူ အမေရိကန်နိုင်ငံ၊ ဝါရှင်တန်မြို့မှ (၁၃-၃-၂၀၂၀) ရက်နေ့မှ American Airways (AA 3269) ဖြင့် Chicago သို့လည်းကောင်း၊ Chicago မှ Doha သို့ Qatar Airways (Qatar 726) ဖြင့်လည်းကောင်းထွက်ခွာခဲ့ပါသည်။
(၁၄-၃-၂၀၂၀) ရက်နေ့တွင် ဒိုဟာမြို့မှ Qatar Airways (QR-916) ဖြင့် ထွက်ခွာလာခဲ့ရာ ရန်ကုန်အပြည်ပြည်ဆိုင်ရာလေဆိပ်သို့ (၁၅-၃-၂၀၂၀) ရက်နေ့ နံနက် (၅:၃၅) တွင် ရောက်ရှိခဲ့ပါသည်။
ရန်ကုန်အပြည်ပြည်ဆိုင်ရာလေဆိပ်မှ စစ်ကိုင်းတိုင်းဒေသကြီး၊ ကလေးမြို့လေဆိပ်သို့ မြန်မာအမျိုးသားလေကြောင်းလိုင်း (UB – 503) ဖြင့် ထွက်ခွာလာခဲ့ရာ (၁၅-၃-၂၀၂၀) ရက်နေ့ နေ့လည် (၂:၃၀) နာရီအချိန်တွင် ရောက်ရှိခဲ့ပါသည်။
ကလေးမြို့တွင် (၁၅-၃-၂၀၂၀) ရက်နေ့မှ (၁၇-၃-၂၀၂၀) ရက်နေ့ထိ တပ်ဦးသီတာ၊ ရတနာပုံလမ်း၌ တည်းခိုနေထိုင်ခဲ့ပြီး (၁၅-၃-၂၀၂၀) ရက်နေ့ ညနေပိုင်းတွင် လမ်းဆုံရှိ ရွှေဆိုင်သို့ သွားရောက်ခဲ့ကြောင်းနှင့် (၁၆-၃-၂၀၂၀) ရက်နေ့တွင် Cherry Photo Studio တွင် Pre-wedding photo ရိုက်ကူးခဲ့ကြောင်း သိရှိရပါသည်။
(၁၇-၃-၂၀၂၀) ရက်နေ့တွင် ကလေးမြို့မှ တီးတိန်မြို့သို့ ပြည်ချစ်သားလိုင်းကားဖြင့် ထွက်ခွာ လာခဲ့ကြောင်းနှင့် ကားပေါ်တွင် လူ (၁၂) ဦးပါရှိကြောင်းသိရှိရပါသည်။
တီးတိန်မြို့တွင် လွယ်ဘွားရပ်ကွက်တွင် တစ်ညအိပ် တည်းခိုနေထိုင်ခဲ့ပြီး (၁၈-၃-၂၀၂၀) ရက်နေ့တွင် ကပ်တဲလ်ကျေးရွာသို့ AG အသင်းတော်ကားဖြင့် ထွက်ခွာခဲ့ကြောင်းသိရှိရပါ သည်။
(၁၉-၃-၂၀၂၀) ရက်နေ့တွင် နံနက်ပိုင်းတွင် ဖျားခြင်းစတင်ခံစားခဲ့ရသဖြင့် ကပ်တဲလ် ကျေးရွာရှိ PSI ဆေးခန်းသို့ နံနက် (၈:၀၀) နာရီတွင် သွားရောက်ပြသခဲ့ကြောင်း သိရှိရပါသည်။
PSI ဆေးခန်းမှ ဆရာဝန်သည် တီးတိန်မြို့နယ်၊ ပြည်သူ့ဆေးရုံမှ တာဝန်ရှိသူများနှင့် ဆက်သွယ်တိုင်ပင်၍ ပြည်သူဆေးရုံဝင်းအတွင်းရှိ (၈) ခန်းတွဲ၊ (၂) ထပ် ဆောင်သစ်၊ အပေါ် ထပ်တွင် စနစ်တကျ အသွားအလာ ကန့်သတ်ခြင်း (Quarantine) ပြုလုပ်ခဲ့ပါသည်။

Getting to extract information for all the remaining cases

You’ll have to find way to automate the task of extracting those cases like I’ve done for case-1. Vectorized calculation is the strength of R. But RSelenium doesn’t support it. So you need to use for loops or some other method to get it done. I’ll try to do that with my next post.

Thursday, May 14, 2020

Reshaping the corpus to sentence level


For my last post, I’d created a corpus from the text of the COVID-19 surveillance reports for Myanmar for April 2020 using the quanteda package and tried out its kwic() function. That corpus was created at the surveillance report level, that is, the document units of the corpus is an entire surveillance report. Using the corpus_reshape() function we may change the present corpus at the “document” level to either “sentences” or “paragraphs” level.

(1) Add period mark at the end of the Myanmar language sentence

First I tried to trick quanteda by adding a period mark (full stop) after the Myanmar major section ending mark “။”, so as to become “\u104b\u002e”, that is, “။.”.Then I tried reshaping to sentences level. That didn’t work; I got 999 sentences while the correct number is just 403!

(2) Add paragraph mark “\n\n” at the end of the Myanmar language sentence

This works! This way, I was able to trick quanteda to give the corpus at the desired sentences level. But then I found that the next approach is more natural.

(3) Try reshaping without any additional mark

When I tried using the method (1) I noticed that some of the segmentation into “sentence” correctly used the Myanmar sentence ending mark “။”. So I tried reshaping the corpus of my last post directly into “sentences” without adding anything. That gave mostly correct segmentation into sentences, though there were some errors, such as: (i) considering “၊” in addition to “။” as sentence ending mark, (ii) considering the sentence number at the beginning of sentence such as “၁။” as a sentence, and (iii) considering “မှတ်ချက်။ ။” as two sentences. After appropriate modification of such texts, the reshaping succeded. I was happy and suprised, because I didn’t think quanteda would recognize the sentence ending of the Myanmar language!
Here’s how it was done.
First I removed “၊” and change sentence numbering “၁။” to “<၁>”. Then I modified “မှတ်ချက်။ ။” to “မှတ်ချက် -”.
Then there was this mysterious character “သည\u103a ။” in one sentence which gave me a lot of trouble eliminating. Finally I found the right pattern for detecting it: “သည\u103a.{1}။”, and was able to remove it!
Recall that the vector of of the texts of surveillance reports for April 2020, xMc.v had been created (see my last post).
xMc.v1.0 <- gsub("ဓာတ်ခွဲအတည်ပြု လူနာဟောင်း (old confirmed case)", "old confirmed case", xMc.v, fixed = TRUE) %>%
  gsub("ဆေးသုတေသနဦးစီးဌာန (DMR)", "DMR", . , fixed = TRUE) %>%
  gsub("အမျိုးသားကျန်းမာရေးဓာတ်ခွဲမှုဆိုင်ရာဌာန (ရန်ကုန်) (NHL)", "NHL", ., fixed = TRUE) %>%
  gsub("အမျိုးသားကျန်းမာရေးဓာတ်ခွဲမှုဆိုင်ရာဌာန\\(ရန်ကုန်\\)|အမျိုးသားကျန်းမာရေးဓာတ်ခွဲမှုဆိုင်ရာဌာန \\(ရန်ကုန်\\)", "NHL", .) %>%
  gsub("([\u1040-\u1049]?[\u1040-\u1049])\u104b", "<\\1>", .) %>%
  gsub("\u104a", " ", .) %>% gsub("(မှတ်ချက်)။ ။", "\\1 - ",. ) %>%
  sub("သည\u103a.{1}။","", .)

# create data frame
xMc.v1.0df <- data.frame(Z1 = names(xMc.v1.0),Z2 = xMc.v1.0, stringsAsFactors = FALSE)

# create corpus at document level
library(quanteda)
xsenMP0_apr <- xMc.v1.0df %>%
  corpus(.,docid_field = "Z1", text_field = "Z2", )
summary(xsenMP0_apr)
Corpus consisting of 60 documents:

                  Text Types Tokens Sentences
  (30-4-2020, 8:00 PM)   114    311         7
  (30-4-2020, 7:00 AM)    94    183         4
   (29-4-2020, 8:00PM)   133    323         8
  (29-4-2020, 7:00 AM)    88    160         3
  (28-4-2020, 8:00 PM)   105    232         5
  (28-4-2020, 7:00 AM)    67    152         4
  (27-4-2020, 8:00 PM)    84    176         5
  (27-4-2020, 7:00 AM)    82    187         3
  (26-4-2020, 8:00 pm)   110    258         6
  (26-4-2020, 7:00 AM)    83    190         4
  (25-4-2020, 8:00 pm)   127    302         6
 (25-4-2020, 10:00 am)    57     92         2
 (24-4-2020, 11:00 pm)    86    236         6
  (24-4-2020, 8:00 pm)   112    298         7
 (24-4-2020, 10:00 am)    99    272         5
  (24-4-2020, 9:00 am)    93    206         5
 (24-4-2020, 00:30 am)    50     75         2
  (23-4-2020, 8:00 pm)   119    334         8
 (23-4-2020, 10:00 am)    83    196         4
  (23-4-2020, 7:00 AM)    69    139         3
  (22-4-2020, 8:00 PM)   114    305         8
 (22-4-2020, 10:00 AM)    76    154         4
  (21-4-2020, 10:00PM)    57     94         3
   (21-4-2020, 8:00PM)    88    203         5
 (20-4-2020, 11:00 PM)    83    195         6
  (20-4-2020, 8:00 PM)   114    244         6
 (20-4-2020, 10:00 AM)    99    181         3
 (19-4-2020, 11:15 PM)    82    190         6
  (19-4-2020, 8:00 PM)   143    349         9
  (19-4-2020, 7:00 am)    76    164         5
  (18-4-2020, 9:00 PM)    70    146         4
  (18-4-2020, 8:00 pm)    88    205         4
 (18-4-2020, 10:00 am)   164    511         8
  (18-4-2020, 8:00 am)   157    439         9
  (17-4-2020, 8:00 pm)   143    534         7
 (17-4-2020, 10:00 am)   121    273         5
  (16-4-2020, 8:00 pm)   101    213         4
 (16-4-2020, 10:00 AM)   101    220         4
  (15-4-2020, 8:00 pm)   103    216         4
 (15-4-2020, 10:30 AM)   110    216         4
  (14-4-2020, 8:00 pm)   170    437         6
  (14-4-2020, 4:00 pm)    58     99         2
 (14-4-2020, 00:15 am)    97    220         6
 (13-4-2020, 10:15 pm)   102    216         6
  (13-4-2020, 8:00 pm)    78    118         4
 (13-4-2020, 00:30 am)   237    813        15
  (12-4-2020, 8:00 pm)   224    573        11
  (12-4-2020, 2:00 AM)   238   1262        22
   (11-4-2020, 8:00PM)   208    727        13
  (10-4-2020, 10:15PM)   192    564         9
   (10-4-2020, 8:00PM)   186    490         7
   (10-4-2020, 3:00AM)   256   1016        14
   (9-4-2020, 8:00 PM)   321   1191        17
   (8-4-2020, 8:00 PM)   223    693         9
    (6-4-2020, 8:00PM)   241    712        11
   (5-4-2020, 8:00 PM)   188    491         7
   (4-4-2020, 8:00 PM)   261    748        11
   (3-4-2020, 8:00 PM)   192    493         7
    (2-4-2020, 8:00PM)   214    590        10
    (1-4-2020, 8:00PM)   226    636        11

Source: C:/DATA/GITA_EX/* on x86-64 by mtnn
Created: Thu May 14 23:12:40 2020
Notes: 
# Reshape corpus to sentence level
xsenMP_apr <- corpus_reshape(xsenMP0_apr, "sentences")
View first two and last two sentences of (12-4-2020, 2:00 AM) report. Note that they have been truncated. Compare it with the whole report of that date.
utf8::utf8_print(texts(xsenMP_apr)[which(grepl("(12-4-2020, 8:00 pm)", names(texts(xsenMP_apr))))][c(1:2,10:11)])
(12-4-2020, 8:00 pm).1                                                                    
"<၁> NHL မှ ယနေ့ COVID-19 ရောဂါအတွက်ဓာတ်ခွဲစစ်ဆေးမှု ပထမအသုတ်အား စစ်ဆေးမှုတွင် စောင့်ကြည့်လူနာများ  ဆေးရုံများနှင့်…"
(12-4-2020, 8:00 pm).2                                                                    
"(COVID-19 ရောဂါပိုး တွေ့ရှိ (တွေ့ရှိ) မှု သတင်းကို ယနေ့  ညနေ (၆:၃၀) တွင် သတင်းအကျဉ်း ထုတ်ပြန်ပြီးဖြစ်ပါသည်။)"      
(12-4-2020, 8:00 pm).10                                                                   
"<၅> အဆိုပါ ဓာတ်ခွဲအတည်ပြုလူနာများနှင့် ထိတွေ့ခဲ့သူများအားလုံးကို စုံစမ်းဖော်ထုတ်၍ အသွားအလာကန့်သတ်ကာ စောင့်ကြပ်ကြည့်ရှုသွားမည်ဖြ…"
(12-4-2020, 8:00 pm).11                                                                   
"သို့ဖြစ်ပါ၍ အဆိုပါ ဓာတ်ခွဲအတည်ပြုလူနာများနှင့် အနီးကပ်ထိတွေ့ခဲ့သည့် ပြည်သူလူထုအနေဖြင့် နီးစပ်ရာ ကျန်းမာရေးဌာနသို့ ဆက်သွယ်အကြော…"
cat(texts(xsenMP_apr)[which(grepl("(12-4-2020, 8:00 pm)", names(texts(xsenMP_apr))))])
<၁> NHL မှ ယနေ့ COVID-19 ရောဂါအတွက်ဓာတ်ခွဲစစ်ဆေးမှု ပထမအသုတ်အား စစ်ဆေးမှုတွင် စောင့်ကြည့်လူနာများ  ဆေးရုံများနှင့် သက်ဆိုင်ရာ နေရာများ၌ အသွားအလာကန့်သတ်၍ စောင့်ကြပ်ကြည့်ရှုခံနေသူများ စုစုပေါင်း (၉၃) ဦး ၏ ဓာတ်ခွဲ နမူနာများအား စစ်ဆေးခဲ့ရာ (ဇယား-၁) ၌ ဖော်ပြထားရှိသော လူနာ (၁) ဦး၏ ဓာတ်ခွဲအဖြေတွင် COVID-19 ရောဂါပိုး တွေ့ရှိ (တွေ့ရှိ) ရပြီး ကျန်လူနာများနှင့် စောင့်ကြပ် ကြည့်ရှုမှုခံနေသူ (၉၂)ဦး၏ ဓာတ်ခွဲအဖြေများတွင် COVID-19 ရောဂါပိုးမရှိကြောင်း တွေ့ရှိရပါ သည်။ (COVID-19 ရောဂါပိုး တွေ့ရှိ (တွေ့ရှိ) မှု သတင်းကို ယနေ့  ညနေ (၆:၃၀) တွင် သတင်းအကျဉ်း ထုတ်ပြန်ပြီးဖြစ်ပါသည်။) <၂> ဓာတ်ခွဲအတည်ပြုလူနာ (Case-039) သည် ရန်ကုန်တိုင်းဒေသကြီး  ပန်းဘဲတန်းမြိို့နယ် တွင်နေထိုင်သူ အသက် (၈၅) နှစ်အရွယ် အမျိုးသားတစ်ဦးသည် (၉-၄-၂၀၂၀) ရက်နေ့တွင် ဖျားခြင်း  ချောင်းဆိုးခြင်းလက္ခဏာများစတင်ခံစားခဲ့ရသဖြင့် ရန်ကုန်ပြည်သူ့ဆေးရုံကြီးသို့ (၁၁-၄-၂၀၂၀) ရက်နေ့တွင် သွားရောက်ပြသခဲ့ရာစောင့်ကြည့်လူနာအဖြစ် သတ်မှတ်၍ ဓာတ်ခွဲ နမူနာရယူစစ်ဆေးခဲ့ခြင်းဖြစ်ပါသည်။ အဆိုပါလူနာသည် လွန်ခဲ့သော (၁၄)ရက်အတွင်း ပြည်ပ နိုင်ငံများသို့ ခရီးသွားလာသော ရာဇဝင်မရှိခဲ့ကြောင်း သိရှိရပြီး ဆီးချိုရောဂါနှင့် နှလုံးသွေး ကြောကျဉ်းရောဂါအခံရှိကြောင်း သိရှိရပါသည်။ လူနာမှာ ဆေးရုံ စတင်တက်ရောက်သည့် အချိန်တွင် အလွန်မောပန်းလျက်ရှိပြီး သွေးတွင်း အောက်စီဂျင်ဓာတ်များ ကျဆင်းလျက် ရှိရာ လိုအပ်သော ကုသမှုများပေးခဲ့သော်လည်း (၁၂-၄-၂၀၂၀)ရက်နေ့  နံနက် (၆:၀၀) နာရီအချိန်ခန့် တွင် သေဆုံးသွားခဲ့ကြောင်း သိရှိရပါသည်။ သေဆုံးရသည့် အကြောင်းအရင်းမှာ ပြင်းထန် အဆုတ်ရောင်ရောဂါ  ဆီးချိုရောဂါ  သွေးတိုးရောဂါနှင့် နှလုံးသွေးကြောကျဉ်းရောဂါအခံ ရှိခြင်းတို့ကြောင့် ဖြစ်ပါသည်။ <၃> ယခုအခါ (၂၃-၃-၂၀၂၀)ရက်နေ့မှ (၁၂-၄-၂၀၂၀)ရက်နေ့  ည (၈:၀၀)နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြုလူနာ (၃၉)ဦး တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။ <၄> သို့ဖြစ်ရာ COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြုလူနာများမှာ ချင်းပြည်နယ်  တီးတိန် ပြည်သူ့ဆေးရုံတွင် (၃)ဦး  ရန်ကုန်မြို့  ဝေဘာဂီအထူးကုဆေးရုံကြီးတွင် လူနာ (၂၆)ဦး  ရှမ်း ပြည်နယ် (မြောက်ပိုင်း)  လားရှိုးပြည်သူ့ဆေးရုံကြီးတွင် (၁)ဦး  မော်လမြိုင်ပြည်သူ့ဆေးရုံကြီး တွင် လူနာ (၁)ဦး  စဝ်စံထွန်းပြည်သူ့ဆေးရုံကြီးတွင် လူနာ (၁)ဦး  စုစုပေါင်း (၃၂)ဦးတို့ဖြစ်ပြီး ၎င်းတို့၏ ကျန်းမာရေးအခြေအနေမှာ တည်ငြိမ်လျက်ရှိပါသည်။ ဝေဘာဂီအထူးကုဆေးရုံကြီး ရှိ လူနာ (၁) ဦးအား အထူးကြပ်မတ်ခန်း၌ သီးခြားထားရှိ ဆေးကုသမှုပေးလျက်ရှိပါသည်။ <၅> အဆိုပါ ဓာတ်ခွဲအတည်ပြုလူနာများနှင့် ထိတွေ့ခဲ့သူများအားလုံးကို စုံစမ်းဖော်ထုတ်၍ အသွားအလာကန့်သတ်ကာ စောင့်ကြပ်ကြည့်ရှုသွားမည်ဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍ အဆိုပါ ဓာတ်ခွဲအတည်ပြုလူနာများနှင့် အနီးကပ်ထိတွေ့ခဲ့သည့် ပြည်သူလူထုအနေဖြင့် နီးစပ်ရာ ကျန်းမာရေးဌာနသို့ ဆက်သွယ်အကြောင်းကြားစေလိုကြောင်း တိုက်တွန်းအပ်ပါသည်။

Now we know that leaving only the major section mark (“။”) WORKS!!!!

It was done, but I don’t know if that was due to quanteda or the Unicode system. Anyway that’s wonderful for sure.

Wednesday, May 6, 2020

Exploring information on COVID-19 confirmed cases


With my last post I had shared the text of COVID-19 surveillance reports for Myanmar for the month of April, 2020. It was, however incomplete as I couldn’t find the way to read-in some of the reports from the MOHS website. In the meantime, I’d manually accessed the missing webpages, copy and paste their text to some text files and read-in their contents into R, and created the file of complete reports. This file is shared here.
For the purpose of this post, I’d used the quanteda R-package to, (i) Create a corpus of the complete set of surveillance reports for the month of April, 2020, (ii) Start exploring this corpus, particularly with kwic() function to extract information on the laboratory confirmed cases for COVID-19 infection.

Corpus creation

Prior to the present exercise, I’d created the text of the surveillance reports in the xM_aprAll dataframe.
library(quanteda)
xMc_apr <- xM_aprAll[, 1:2] %>%
  corpus(.,docid_field = "X1", text_field = "X2")
xMc_apr$heading <- xM_aprAll$X1 

Shortening some texts for use as identifiers

In processing the reports and for the purpose of extracting information, the report headings would be too and I would therefore be replacing them with their date and time. Also, I am shortening some long names with only the English acronyms.
ap <- "COVID-19 ရောဂါစောင့်ကြပ်ကြည့်ရှုမှုနှင့်ပတ်သက်၍ သတင်းထုတ်ပြန်ခြင်း\\s"
bp <- "COVID-19 ရောဂါ စောင့်ကြပ်ကြည့်ရှုမှုနှင့်ပတ်သက်၍ သတင်းထုတ်ပြန်ခြင်း\\s"
cp <- "COVID-19 ရောဂါစောင့်ကြပ်ကြည့်ရှုမှုနှင့်ပတ်သက်၍ သတင်းထုတ်ပြန်ခြင်း\\s"
patt <- paste(c(ap,bp,cp), collapse = "|")
xMc.v <- texts(xMc_apr) %>%   
  gsub("ဓာတ်ခွဲအတည်ပြု လူနာဟောင်း (old confirmed case) များ၏ ဓာတ်ခွဲနမူနာများ၌", "old confirmed case", ., fixed = TRUE) %>%
  gsub("ဆေးသုတေသနဦးစီးဌာန (DMR)", "DMR", ., fixed = TRUE ) %>%
  gsub("အမျိုးသားကျန်းမာရေးဓာတ်ခွဲမှုဆိုင်ရာဌာန (ရန်ကုန်) (NHL)", "NHL", ., fixed = TRUE)
names(xMc.v) <- gsub(patt, "", names(xMc.v))

Tokenizing the report texts

I am using the spacing of the text in the original report for tokenization. This would segment the reports into pieces of text that are more like phrases than words in English language. For that, we use the tokens() function with the option, what = fastestword"This would split text on the space character, using stringi::stri_split_fixed(x, " ").
ctoks <- tokens(xMc.v, "fastestword")

Finding the search pattern for laboratory confirmed patients

Inspection of the reports shows three different ways of writing the same item:
ဓာတ်ခွဲ အတည်ပြုလူနာ (၁၅၀) ဦး
ဓာတ်ခွဲအတည်ပြုလူနာ (၁၄၉)ဦး
ဓာတ်ခွဲအတည်ပြု လူနာ (၁၂၇)ဦး
They could, however, be reduced into a single regex pattern: “လူနာ ([၀-၉]+)”
The search results using the kwic() function. “The kwic function (keywords-in-context) performs a search for a word and allows us to view the contexts in which it occurs.” Since Myanmar language doesn’t have words as such, we used the groups of text (groups of syllables) or phrases delimited by space as it is found in the original text for tokenization. From the kwic() function, we asked for three phrases preceding (pre) and (post) in addition to the keyword in the output.

Finding information relating to confirmed cases

cPatients <- data.frame(kwic(ctoks, phrase("လူနာ ([၀-၉]+)"), window = 3, "regex"))
nrow(cPatients)
[1] 228
You can see the first 10 and last 10 outputs from a total of 228.
utf8::utf8_print(sapply(cPatients[c(1:10,219:228),], paste))
      docname                from  to    pre                                                  
 [1,] "(30-4-2020, 8:00 PM)" "8"   "9"   "DMR မှ စစ်ဆေးပြီးစီးခဲ့သော"                               
 [2,] "(30-4-2020, 8:00 PM)" "16"  "17"  "COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြု"                           
 [3,] "(30-4-2020, 8:00 PM)" "27"  "28"  "COVID-19 ရောဂါ ဓာတ်ခွဲ"                                
 [4,] "(30-4-2020, 8:00 PM)" "79"  "80"  "ဦး ရှိပါသည်။၆။ ယနေ့အထိ"                                  
 [5,] "(30-4-2020, 8:00 PM)" "100" "101" "(၁၂:၀၀) နာရီအတွင်း တွေ့ရှိရသော"                            
 [6,] "(30-4-2020, 7:00 AM)" "15"  "16"  "-• COVID-19 ရောဂါဓာတ်ခွဲအတည်ပြု"                         
 [7,] "(30-4-2020, 7:00 AM)" "25"  "26"  "COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြု"                           
 [8,] "(29-4-2020, 8:00PM)"  "11"  "12"  "အဖြစ် စစ်ဆေးပြီးစီးခဲ့သော အသွားအလာကန့်သတ်ခံရသူနှင့်"               
 [9,] "(29-4-2020, 8:00PM)"  "17"  "18"  "ဓာတ်ခွဲနမူနာများနှင့် DMRမှ စစ်ဆေးပြီးစီးခဲ့သော"                 
[10,] "(29-4-2020, 8:00PM)"  "27"  "28"  "COVID-19 ရောဂါပိုး မတွေ့ရှိပါ။(ဓာတ်ခွဲအတည်ပြု"                 
[11,] "(1-4-2020, 8:00PM)"   "37"  "38"  "ညနေ (၆) နာရီအထိ"                                      
[12,] "(1-4-2020, 8:00PM)"   "62"  "63"  "ခဲ့ရာ (ဇယား-၁) တွင်ဖော်ပြထားရှိသော"                        
[13,] "(1-4-2020, 8:00PM)"   "72"  "73"  "တွေ့ရှိ (တွေ့ရှိ) ရပြီး"                                     
[14,] "(1-4-2020, 8:00PM)"   "136" "137" "ပေးလျက်ရှိပါသည်။၅။ COVID-19 ရောဂါ"                      
[15,] "(1-4-2020, 8:00PM)"   "142" "143" "ချင်းပြည်နယ်၊ တီးတိန် ပြည်သူ့ဆေးရုံတွင်"                         
[16,] "(1-4-2020, 8:00PM)"   "147" "148" "ဦး၊ ရန်ကုန်မြို့၊ ဝေဘာဂီအထူးကုဆေးရုံကြီးတွင်"                     
[17,] "(1-4-2020, 8:00PM)"   "153" "154" "နှင့် မန္တလေးမြို့၊ ကန်တော်နဒီဆေးရုံတွင်"                         
[18,] "(1-4-2020, 8:00PM)"   "157" "158" "(၁) ဦး၊ နေပြည်တော်ပြည်သူ့ဆေးရုံကြီးတွင်"                      
[19,] "(1-4-2020, 8:00PM)"   "166" "167" "လားရှိုးမြို့တွင် ကျောက်မဲမြို့ ပြည်သူ့ဆေးရုံမှ"                       
[20,] "(1-4-2020, 8:00PM)"   "176" "177" "ကျန်းမာရေးအခြေအနေမှာ တည်ငြိမ်လျက်ရှိပါသည်။ ဝေဘာဂီအထူးကုဆေးရုံကြီးရှိ"
      keyword                post                                       pattern       
 [1,] "စောင့်ကြည့်လူနာ (၂၉)"      "ဦး၏ ဓာတ်ခွဲနမူနာများတွင် -•"                    "လူနာ ([၀-၉]+)"
 [2,] "လူနာသစ် မတွေ့ရှိပါ။၂။"      "သို့ဖြစ်ပါ၍ (၃၀-၄-၂၀၂၀) ရက်နေ့၊"                "လူနာ ([၀-၉]+)"
 [3,] "အတည်ပြုလူနာ (၁၅၀)"       "ဦးရှိပြီဖြစ်ပါသည်။၃။ (၃၀-၄-၂၀၂၀) ရက်နေ့တွင်"       "လူနာ ([၀-၉]+)"
 [4,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၂၇)"   "ဦးအား သက်ဆိုင်ရာဆေးရုံများတွင် ဆေးကုသမှု"            "လူနာ ([၀-၉]+)"
 [5,] "စောင့်ကြည့်လူနာအသစ် (၆၀)ဦး" "ရှိပါသည်။"                                   "လူနာ ([၀-၉]+)"
 [6,] "လူနာသစ် မတွေ့ရှိပါ။၂။"      "သို့ဖြစ်ပါ၍ (၃၀-၄-၂၀၂၀)ရက်နေ့၊ နံနက်"             "လူနာ ([၀-၉]+)"
 [7,] "လူနာ (၁၅၀)"            "ဦးရှိပြီဖြစ်ပါသည်။၃။ (၂၉-၄-၂၀၂၀) ရက်နေ့အတွက်"      "လူနာ ([၀-၉]+)"
 [8,] "စောင့်ကြည့်လူနာ (၈၉)"      "ဦး၏ ဓာတ်ခွဲနမူနာများနှင့် DMRမှ"                  "လူနာ ([၀-၉]+)"
 [9,] "စောင့်ကြည့်လူနာ (၂၁)"      "ဦး၏ ဓာတ်ခွဲနမူနာများ၊ စုစုပေါင်း"                "လူနာ ([၀-၉]+)"
[10,] "လူနာသစ် မရှိပါ။)၂။"       "သို့ဖြစ်ပါ၍ (၂၉-၄-၂၀၂၀)ရက်နေ့၊ ည"               "လူနာ ([၀-၉]+)"
[11,] "စောင့်ကြည့်လူနာအသစ် (၃၆)"   "ဦး ရှိပါသည်။၃။ အမျိုးသားကျန်းမာရေးဓာတ်ခွဲမှုဆိုင်ရာဌာန" "လူနာ ([၀-၉]+)"
[12,] "လူနာ (၁)"              "ဦး၏ ဓာတ်ခွဲအဖြေတွင် COVID-19"                  "လူနာ ([၀-၉]+)"
[13,] "ကျန်လူနာ (၅၅)"          "ဦး၏ ဓာတ်ခွဲအဖြေများတွင် COVID-19"              "လူနာ ([၀-၉]+)"
[14,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၅)"    "ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်"                    "လူနာ ([၀-၉]+)"
[15,] "လူနာ (၁)"              "ဦး၊ ရန်ကုန်မြို့၊ ဝေဘာဂီအထူးကုဆေးရုံကြီးတွင်"           "လူနာ ([၀-၉]+)"
[16,] "လူနာ (၁၀)"             "ဦး နှင့် မန္တလေးမြို့၊"                          "လူနာ ([၀-၉]+)"
[17,] "လူနာ (၁)"              "ဦး၊ နေပြည်တော်ပြည်သူ့ဆေးရုံကြီးတွင် လူနာ"            "လူနာ ([၀-၉]+)"
[18,] "လူနာ (၁)"              "ဦး၊ ရှမ်းပြည်နယ် (မြောက်ပိုင်း)၊"                 "လူနာ ([၀-၉]+)"
[19,] "ပြောင်းရွှေ့လူနာ (၁)"      "ဦး၊ စုစုပေါင်း (၁၄)"                         "လူနာ ([၀-၉]+)"
[20,] "လူနာ (၁)"              "ဦးအား အထူးကြပ်မတ် ခန်း၌"                      "လူနာ ([၀-၉]+)"

Filtering the confirmed cases

We filter the output in order to get only the results that contain the term for laboratory confirmed infections. We identified three different group of wordings for the same term which are combined into a single regex pattern (q123).
q1 <- "ဓာတ်ခွဲ အတည်ပြုလူနာ \\([၀-၉]+\\)"
q2 <- "ဓာတ်ခွဲအတည်ပြုလူနာ \\([၀-၉]+\\)"
q3 <- "ဓာတ်ခွဲအတည်ပြု လူနာ \\([၀-၉]+\\)"
q123 <- paste0(c(q1,q2,q3), collapse = "|")
Filtering for the desired results, we obtain 53 lines of output, that are quite easy to understand.
tsel <- paste(cPatients$pre,cPatients$keyword) %>%
  grepl(q123, .)   # %>% cPatients[.,]
utf8::utf8_print(sapply(cPatients[tsel,], paste))
      docname                 from  to    pre                                             
 [1,] "(30-4-2020, 8:00 PM)"  "27"  "28"  "COVID-19 ရောဂါ ဓာတ်ခွဲ"                           
 [2,] "(30-4-2020, 8:00 PM)"  "79"  "80"  "ဦး ရှိပါသည်။၆။ ယနေ့အထိ"                             
 [3,] "(30-4-2020, 7:00 AM)"  "25"  "26"  "COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြု"                      
 [4,] "(29-4-2020, 8:00PM)"   "37"  "38"  "COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြု"                      
 [5,] "(28-4-2020, 8:00 PM)"  "32"  "33"  "နာရီ အထိ မြန်မာနိုင်ငံတွင်"                             
 [6,] "(27-4-2020, 8:00 PM)"  "21"  "22"  "ည (၈:၀၀)နာရီအထိ မြန်မာနိုင်ငံတွင်"                      
 [7,] "(26-4-2020, 8:00 pm)"  "31"  "32"  "ည (၈:၀၀)နာရီအထိ မြန်မာနိုင်ငံတွင်"                      
 [8,] "(25-4-2020, 8:00 pm)"  "32"  "33"  "ည (၈:၀၀)နာရီအထိ မြန်မာနိုင်ငံတွင်"                      
 [9,] "(25-4-2020, 10:00 am)" "10"  "11"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် COVID-19"                 
[10,] "(24-4-2020, 9:00 am)"  "35"  "36"  "အချိန်အထိ COVID-19 ရောဂါ"                         
[11,] "(24-4-2020, 00:30 am)" "23"  "24"  "နံနက် (၀၀:၃၀)နာရီအထိ မြန်မာနိုင်ငံတွင်"                   
[12,] "(23-4-2020, 8:00 pm)"  "34"  "35"  "ည (၈:၀၀)နာရီအထိ မြန်မာနိုင်ငံတွင်"                      
[13,] "(23-4-2020, 10:00 am)" "8"   "9"   "(၁၀:၀၀)နာရီအချိန်ထိ မြန်မာနိုင်ငံတွင် COVID-19"           
[14,] "(23-4-2020, 10:00 am)" "11"  "12"  "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၁၂၇)ဦး တွေ့ရှိခဲ့ပြီး"             
[15,] "(23-4-2020, 7:00 AM)"  "35"  "36"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် ဓာတ်ခွဲအတည်ပြု"                
[16,] "(22-4-2020, 8:00 PM)"  "35"  "36"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် ဓာတ်ခွဲအတည်ပြု"                
[17,] "(22-4-2020, 10:00 AM)" "9"   "10"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် COVID-19"                 
[18,] "(21-4-2020, 10:00PM)"  "22"  "23"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် ဓာတ်ခွဲအတည်ပြု"                
[19,] "(21-4-2020, 8:00PM)"   "42"  "43"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် ဓာတ်ခွဲအတည်ပြု"                
[20,] "(20-4-2020, 10:00 AM)" "39"  "40"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် COVID-19"                 
[21,] "(18-4-2020, 8:00 pm)"  "26"  "27"  "ရောဂါပိုးမတွေ့ရှိ (မတွေ့ရှိ)ပါ။၂။ ယခုအထိ"                  
[22,] "(18-4-2020, 8:00 pm)"  "37"  "38"  "ဆင်းခွင့်ရရှိခဲ့ပြီးဖြစ်ပါသည်။၃။ COVID-19 ရောဂါ"          
[23,] "(18-4-2020, 10:00 am)" "89"  "90"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် COVID-19"                 
[24,] "(18-4-2020, 8:00 am)"  "69"  "70"  "ယခုအချိန်အထိ COVID-19 ရောဂါ"                       
[25,] "(17-4-2020, 8:00 pm)"  "29"  "30"  "တွေ့ရှိခဲ့ရပါသည်။၂။ COVID-19 ရောဂါ"                   
[26,] "(17-4-2020, 10:00 am)" "55"  "56"  "တွေ့ရှိခဲ့ရပါသည်။၃။ COVID-19 ရောဂါ"                   
[27,] "(16-4-2020, 8:00 pm)"  "28"  "29"  "တွေ့ရှိခဲ့ရပါသည်။၂။ COVID-19 ရောဂါ"                   
[28,] "(16-4-2020, 10:00 AM)" "74"  "75"  "ယခုအချိန်အထိ COVID-19 ရောဂါ"                       
[29,] "(15-4-2020, 8:00 pm)"  "27"  "28"  "တွေ့ရှိခဲ့ရပါသည်။၂။ COVID-19 ရောဂါ"                   
[30,] "(15-4-2020, 10:30 AM)" "49"  "50"  "နာရီအချိန်အထိ မြန်မာနိုင်ငံတွင် COVID-19"                 
[31,] "(14-4-2020, 8:00 pm)"  "64"  "65"  "ယခုအချိန်အထိ COVID-19 ရောဂါ"                       
[32,] "(14-4-2020, 4:00 pm)"  "31"  "32"  "ဖော်ပြခဲ့ပြီး ဖြစ်ပါသည်။၂။ အဆိုပါ"                     
[33,] "(13-4-2020, 00:30 am)" "173" "174" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[34,] "(12-4-2020, 8:00 pm)"  "124" "125" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[35,] "(12-4-2020, 2:00 AM)"  "281" "282" "ရာဇဝင်ရှိကြောင်း သိရှိရပါသည်။ ထပ်မံတွေ့ရှိရသော"              
[36,] "(12-4-2020, 2:00 AM)"  "299" "300" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[37,] "(11-4-2020, 8:00PM)"   "153" "154" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[38,] "(10-4-2020, 10:15PM)"  "94"  "95"  "တွင် COVID-19 ရောဂါ"                             
[39,] "(10-4-2020, 8:00PM)"   "116" "117" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[40,] "(10-4-2020, 3:00AM)"   "227" "228" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[41,] "(9-4-2020, 8:00 PM)"   "51"  "52"  "မတွေ့ရှိရဘဲ COVID-19 ရောဂါ"                         
[42,] "(9-4-2020, 8:00 PM)"   "304" "305" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[43,] "(8-4-2020, 8:00 PM)"   "197" "198" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[44,] "(6-4-2020, 8:00PM)"    "126" "127" "ကောင်းမွန်လျက်ရှိပါသည်။၅။ COVID-19 ရောဂါ"             
[45,] "(6-4-2020, 8:00PM)"    "175" "176" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[46,] "(5-4-2020, 8:00 PM)"   "79"  "80"  "တွေ့ရှိရပါသည်။၄။ COVID-19 ရောဂါ"                    
[47,] "(5-4-2020, 8:00 PM)"   "139" "140" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[48,] "(4-4-2020, 8:00 PM)"   "153" "154" "ကျန်းမာရေးအခြေအနေမှာ ကောင်းမွန်လျက်ရှိပါသည်။၅။ COVID-19"
[49,] "(4-4-2020, 8:00 PM)"   "214" "215" "ရက်နေ့အထိ မြန်မာနိုင်ငံတွင် COVID-19"                    
[50,] "(3-4-2020, 8:00 PM)"   "82"  "83"  "၄။ COVID-19 ရောဂါ"                             
[51,] "(3-4-2020, 8:00 PM)"   "145" "146" "မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ"                     
[52,] "(2-4-2020, 8:00PM)"    "117" "118" "ဖြစ်ပါသည်။၅။ COVID-19 ရောဂါ"                     
[53,] "(1-4-2020, 8:00PM)"    "136" "137" "ပေးလျက်ရှိပါသည်။၅။ COVID-19 ရောဂါ"                 
      keyword                     post                                               pattern       
 [1,] "အတည်ပြုလူနာ (၁၅၀)"            "ဦးရှိပြီဖြစ်ပါသည်။၃။ (၃၀-၄-၂၀၂၀) ရက်နေ့တွင်"               "လူနာ ([၀-၉]+)"
 [2,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၂၇)"        "ဦးအား သက်ဆိုင်ရာဆေးရုံများတွင် ဆေးကုသမှု"                    "လူနာ ([၀-၉]+)"
 [3,] "လူနာ (၁၅၀)"                 "ဦးရှိပြီဖြစ်ပါသည်။၃။ (၂၉-၄-၂၀၂၀) ရက်နေ့အတွက်"              "လူနာ ([၀-၉]+)"
 [4,] "လူနာ (၁၅၀)"                 "ဦးရှိပြီဖြစ်ပါသည်။၃။ NHL အနေဖြင့်"                       "လူနာ ([၀-၉]+)"
 [5,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၄၉)ဦး"      "ရှိပြီဖြစ်ပါသည်။၃။ ဓာတ်ခွဲနမူနာများတွင် (၂)"                 "လူနာ ([၀-၉]+)"
 [6,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၄၆)"        "ဦး ရှိပြီဖြစ်ပါသည်။၃။ ယခုအခါ"                           "လူနာ ([၀-၉]+)"
 [7,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၄၆)"        "ဦးရှိပြီဖြစ်ပါသည်။၃။ ယနေ့အထိ ဓာတ်ခွဲအတည်ပြုလူနာ"               "လူနာ ([၀-၉]+)"
 [8,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၄၄)"        "ဦး ရှိပြီဖြစ်ပါသည်။၃။ ပြည်သူ့ဆေးရုံကြီး၊"                    "လူနာ ([၀-၉]+)"
 [9,] "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၁၄၄)"   "ဦး တွေ့ရှိခဲ့ပြီး သေဆုံးလူနာ"                               "လူနာ ([၀-၉]+)"
[10,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၃၉)"        "ဦးရှိပြီဖြစ်ပါသည်။၃။ အဆိုပါလူနာသစ်များအား သက်ဆိုင်ရာဆေးရုံများသို့" "လူနာ ([၀-၉]+)"
[11,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၃၂)"        "ဦး ရှိပြီဖြစ်ပါသည်။"                                   "လူနာ ([၀-၉]+)"
[12,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၃၂)"        "ဦး ရှိပြီဖြစ်ပါသည်။၃။ ယခုအခါ"                           "လူနာ ([၀-၉]+)"
[13,] "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၁၂၇)ဦး" "တွေ့ရှိခဲ့ပြီး သေဆုံးလူနာ (၅)"                              "လူနာ ([၀-၉]+)"
[14,] "သေဆုံးလူနာ (၅)"               "ဦးနှင့် ရောဂါသက်သာ၍ ဆေးရုံမှ"                            "လူနာ ([၀-၉]+)"
[15,] "လူနာ (၁၂၇)ဦး"               "ရှိပြီ ဖြစ်ပါသည်။၃။ (၂၂-၄-၂၀၂၀)"                       "လူနာ ([၀-၉]+)"
[16,] "လူနာ (၁၂၃)ဦးရှိပြီ"            "ဖြစ်ပါသည်။၃။ ယခုအခါ မြန်မာနိုင်ငံရှိ"                       "လူနာ ([၀-၉]+)"
[17,] "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၁၂၁)"   "ဦး တွေ့ရှိခဲ့ပြီး သေဆုံးလူနာ"                               "လူနာ ([၀-၉]+)"
[18,] "လူနာ (၁၂၁)ဦး"               "တွေ့ရှိခဲ့ပြီ ဖြစ်ပါသည်။၃။ ယနေ့ည"                           "လူနာ ([၀-၉]+)"
[19,] "လူနာ (၁၂၁)ဦးရှိပြီ"            "ဖြစ်ပါသည်။၄။ ယခုအခါ မြန်မာနိုင်ငံရှိ"                       "လူနာ ([၀-၉]+)"
[20,] "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၁၁၁)"   "ဦး တွေ့ရှိခဲ့ပြီး သေဆုံးလူနာ"                               "လူနာ ([၀-၉]+)"
[21,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၉၆)"         "ဦးအနက် (၅) ဦးမှာသေဆုံးခဲ့ပြီး၊"                          "လူနာ ([၀-၉]+)"
[22,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၈၄)ဦးအား"    "အောက်ပါဇယားအတိုင်း သက်ဆိုင်ရာ ဆေးရုံများတွင်"                 "လူနာ ([၀-၉]+)"
[23,] "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၉၄)"    "ဦး တွေ့ရှိခဲ့ပြီးဖြစ်ပါသည်။၅။ (၁၇-၄-၂၀၂၀)ရက်နေ့တွင်"           "လူနာ ([၀-၉]+)"
[24,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၉၄)"         "ဦးရှိပြီဖြစ်ပါသည်။၅။ (၁၇-၄-၂၀၂၀)ရက်နေ့တွင် ဓာတ်ခွဲအတည်ပြုခဲ့သည့်"   "လူနာ ([၀-၉]+)"
[25,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၇၉)ဦးအား"    "အောက်ပါဇယားအတိုင်း သက်ဆိုင်ရာ ဆေးရုံများတွင်"                 "လူနာ ([၀-၉]+)"
[26,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၈၅)ဦး"       "တွေ့ရှိခဲ့သည့်အနက် (၇၉)ဦးအား အောက်ပါ"                       "လူနာ ([၀-၉]+)"
[27,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၇၉)ဦးအား"    "အောက်ပါဇယားအတိုင်း သက်ဆိုင်ရာ ဆေးရုံများတွင်"                 "လူနာ ([၀-၉]+)"
[28,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၈၅)"         "ဦးရှိပြီ ဖြစ်ပြီး ဓာတ်ခွဲအတည်ပြုလူနာသစ်"                      "လူနာ ([၀-၉]+)"
[29,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၆၈)ဦးအား"    "အောက်ပါဇယားအတိုင်း သက်ဆိုင်ရာဆေးရုံများတွင် လိုအပ်သလို"            "လူနာ ([၀-၉]+)"
[30,] "ရောဂါဓာတ်ခွဲအတည်ပြုလူနာ (၇၄)"    "ဦး တွေ့ရှိခဲ့ပြီးဖြစ်ပါသည်။၄။ အဆိုပါ"                        "လူနာ ([၀-၉]+)"
[31,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၆၃)ဦး"       "တွေ့ရှိပြီးဖြစ်ကာ ၎င်းတို့အနက် -•"                           "လူနာ ([၀-၉]+)"
[32,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၁)"         "ဦးနှင့် ပတ်သက်သည့် သတင်းအချက်အလက်များကို"                     "လူနာ ([၀-၉]+)"
[33,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၄၁)"         "ဦး တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။၅။"                            "လူနာ ([၀-၉]+)"
[34,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၃၉)ဦး"       "တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။၄။ သို့ဖြစ်ရာ"                        "လူနာ ([၀-၉]+)"
[35,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၇)ဦး၏"       "ကျန်းမာရေး အခြေအနေမှာ ကောင်းမွန်လျက်ရှိပြီး"               "လူနာ ([၀-၉]+)"
[36,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၃၈)"         "ဦး တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။၁၁။"                           "လူနာ ([၀-၉]+)"
[37,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၃၁)"         "ဦး တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။၆။"                            "လူနာ ([၀-၉]+)"
[38,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၈)"         "ဦး တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။၄။"                            "လူနာ ([၀-၉]+)"
[39,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၇)ဦး"       "တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍ ပြည်သူများ"                "လူနာ ([၀-၉]+)"
[40,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၇)ဦး"       "တွေ့ရှိခဲ့ပြီး ဖြစ်ပါသည်။၇။ သို့ဖြစ်ပါ၍"                       "လူနာ ([၀-၉]+)"
[41,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၂)ဦး"       "တွေ့ရှိခဲ့ပါသည်။၃။ (၈-၄-၂၀၂၀)ရက်နေ့၊ ညနေ(၆)နာရီမှ"           "လူနာ ([၀-၉]+)"
[42,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၃)"         "ဦး တွေ့ရှိလာခဲ့ရပြီဖြစ်ပြီး ၎င်းလူနာများအနက်"                 "လူနာ ([၀-၉]+)"
[43,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၂)ဦး"       "တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍ ပြည်သူများအနေဖြင့်"          "လူနာ ([၀-၉]+)"
[44,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၁)ဦးအနက်"    "ချင်းပြည်နယ်၊ တီးတိန် ပြည်သူ့"                             "လူနာ ([၀-၉]+)"
[45,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၂)ဦး"       "တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍ ပြည်သူများအနေဖြင့်"          "လူနာ ([၀-၉]+)"
[46,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၀)"         "ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်"                            "လူနာ ([၀-၉]+)"
[47,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၁)"         "ဦး တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍"                      "လူနာ ([၀-၉]+)"
[48,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၀)"         "ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်"                            "လူနာ ([၀-၉]+)"
[49,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၁)"         "ဦး တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍"                      "လူနာ ([၀-၉]+)"
[50,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၉)"         "ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်ပြည်သူ့"                        "လူနာ ([၀-၉]+)"
[51,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၂၀)"         "ဦး တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍"                      "လူနာ ([၀-၉]+)"
[52,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၉)"         "ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်ပြည်သူ့"                        "လူနာ ([၀-၉]+)"
[53,] "ဓာတ်ခွဲအတည်ပြုလူနာ (၁၅)"         "ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်"                            "လူနာ ([၀-၉]+)"

Friendly nudge

Now I can see that the kwic() function would be quite handy for exploring other useful information out of the COVID-19 surveillance reports. Here, in my own small way, I’m happy to learn that existing NLP tools could be applied in the context of the Myanmar language. And kudos my fellow dummies for lying low at home in this social distancing period! I would be happier indeed to see you go much, much, further!

Tuesday, April 28, 2020

Compiling the texts of the COVID-19 surveillance reports, Myanmar


In this post I am sharing my experience in collecting the texts of the COVID-19 surveillance reports published daily on the Ministry of Health and Sports, Myanmar website in Myanmar language. Principally, I used the rvest package and standard tools of the R Statistical Environment including the regex functions. The idea is quite simple: (i)Identify and extract the specific URLs,(ii)read the reports from the MOHS, (iii)extract the body text of the reports, (iv)format the reports, and (v)write out the text file.

Filter and get our reports

First we excluded the reports we were not interested. Then we extracted the body of reports:
pa01 <- "COVID-19.+စောင့်ကြပ်ကြည့်ရှုမှု.+သတင်းထုတ်ပြန်ခြင်း|COVID-19.+စောင့်ကြပ်ကြည့်ရှုမှု.+သတင်းထုတ်ပြန်ခြင်း"
xvect.01 <- xvect.0[grepl(pa01, xvect.0)]
s01 <- regexpr(pa01,xvect.01)
e0 <- gregexpr("\u104b",xvect.01)
e <- sapply(e0,max)
xvect.02 <- substr(xvect.01,s01,e+1)
cat(xvect.02[51])
COVID-19 ရောဂါ စောင့်ကြပ်ကြည့်ရှုမှုနှင့်ပတ်သက်၍ သတင်းထုတ်ပြန်ခြင်း (3-4-2020, 8:00 PM)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ၁။ ကျန်းမာရေးနှင့်အားကစားဝန်ကြီးဌာနသည် ကမ္ဘာ့နိုင်ငံများတွင် ကူးစက်ပျံ့နှံ့လျက်ရှိသည့် COVID-19 ရောဂါ ဖြစ်ပွားမှုနှင့်ပတ်သက်၍ ရောဂါစောင့်ကြပ်ကြည့်ရှုခြင်း၊ ရောဂါ ရှာဖွေ၍ ထိရောက်စွာကုသမှုပေးခြင်း၊ ရောဂါပိုးတွေ့ရှိသူများနှင့် ထိတွေ့မှုရှိခဲ့သူများအား ရှာဖွေဖော်ထုတ်၍ အသွားအလာကန့်သတ်ခြင်း၊ လိုအပ်ပါက ဆေးရုံတက်ရောက်ကုသမှု ခံယူနိုင်စေရေး ဆောင်ရွက် ခြင်း၊ ပြည်ပနိုင်ငံများမှ ပြန်လည်ဝင်ရောက်လာသူများအား သက်ဆိုင်ရာ ဒေသအာဏာပိုင်အဖွဲ့များ၊ အခြားဌာနဆိုင်ရာများနှင့် ချိတ်ဆက်၍သတင်းရယူခြင်း၊ အသွားအလာ ကန့်သတ်ခြင်းလုပ်ငန်းများ ဆောင်ရွက်ခြင်း၊ COVID-19 ရောဂါနှင့်ပတ်သက်၍ ပြည်သူလူထုမှ သတင်းမှန်များ ရရှိနိုင်ရေး အတွက် နေ့စဉ်သတင်းထုတ်ပြန်ခြင်း လုပ်ငန်းများအား အရှိန်အဟုန်မြှင့် ဆောင်ရွက်လျက်ရှိပါသည်။    ၂။ (၂-၄-၂၀၂၀) ရက်နေ့၊ ညနေ (၆) နာရီမှ (၃-၄-၂၀၂၀) ရက်နေ့၊ ညနေ (၆) နာရီအထိ စောင့်ကြည့်လူနာအသစ် (၄၆) ဦး ရှိပါသည်။    ၃။ အမျိုးသားကျန်းမာရေးဓာတ်ခွဲမှုဆိုင်ရာဌာန (ရန်ကုန်) မှ (၃-၄-၂၀၂၀) ရက်နေ့ ဓာတ်ခွဲစစ်ဆေးမှုအဖြေများအရ စောင့်ကြည့်လူနာနှင့် ဆေးရုံ (သို့မဟုတ်) အိမ်တွင် အသွားအလာကန့်သတ်၍ စောင့်ကြပ်ကြည့်ရှုမှုခံယူနေသူ (၅၅) ဦး၏ ဓာတ်ခွဲနမူနာများအား စစ်ဆေးခဲ့ရာ အားလုံး၏ ဓာတ်ခွဲအဖြေများတွင် COVID-19 ရောဂါပိုး မရှိကြောင်း (မရှိကြောင်း) တွေ့ရှိရပါသည်။    ၄။ COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြုလူနာ (၁၉) ဦးအနက် ချင်းပြည်နယ်၊ တီးတိန်ပြည်သူ့ ဆေးရုံတွင် လူနာ (၁) ဦး၊ ရန်ကုန်မြို့၊ ဝေဘာဂီအထူးကုဆေးရုံကြီးတွင် လူနာ (၉) ဦး နှင့် မန္တလေး မြို့၊ ကန်တော်နဒီဆေးရုံတွင် လူနာ (၁) ဦး၊ နေပြည်တော်ပြည်သူ့ဆေးရုံကြီးတွင် လူနာ (၁) ဦး၊ ရှမ်းပြည်နယ် (မြောက်ပိုင်း)၊ ပြည်သူ့ဆေးရုံကြီး၊ လားရှိုးမြို့တွင် ကျောက်မဲမြို့ ပြည်သူ့ဆေးရုံမှ ပြောင်းရွှေ့လူနာ (၁) ဦး၊ ပဲခူးတိုင်းဒေသကြီး၊ ပြည်သူ့ဆေးရုံကြီး၊ ပြည်မြို့တွင် ပြည်သူ့ဆေးရုံ၊ ပေါက်ခေါင်းမြို့မှ ပြောင်းရွှေ့လူနာ (၄) ဦး၊ စုစုပေါင်း (၁၇) ဦးတို့၏ ကျန်းမာရေးအခြေအနေမှာ တည်ငြိမ်လျက်ရှိပါသည်။ ဝေဘာဂီအထူးကုဆေးရုံကြီးရှိ လူနာ (၂) ဦးအား အထူးကြပ်မတ်ခန်း၌ သီးခြားထားရှိဆေးကုသမှု ပေးလျက်ရှိပါသည်။    ၅။ ယခုအခါ (၂၃-၃-၂၀၂၀) ရက်နေ့မှ (၃-၄-၂၀၂၀) ရက်နေ့အထိ မြန်မာနိုင်ငံတွင် COVID-19 ရောဂါ ဓာတ်ခွဲအတည်ပြုလူနာ (၂၀) ဦး တွေ့ရှိလာရပြီဖြစ်ပါသည်။ သို့ဖြစ်ပါ၍ ပြည်သူများ အနေဖြင့် ကျန်းမာရေးနှင့်အားကစားဝန်ကြီးဌာနမှ ထုတ်ပြန်ထားသော ရောဂါကာကွယ် ရေးဆိုင်ရာ ကျန်းမာရေးပညာပေးအချက်အလက်များအား တိကျစွာလိုက်နာ ဆောင်ရွက်ခြင်းဖြင့် မိမိသာမက မိမိ၏ မိသားစုနှင့်ပတ်ဝန်းကျင်မှ လူများအတွက်ပါ ရောဂါကူးစက်မှုမရှိစေရေး ပူးပေါင်း ဆောင်ရွက် ပေးနိုင်ကြပါရန် နှိုးဆော်အပ်ပါသည်။ 

Need for correct order of code points

For the filter above, I used the pattern:
pa01 <- "COVID-19.+စောင့်ကြပ်ကြည့်ရှုမှု.+သတင်းထုတ်ပြန်ခြင်း"
However, the result failed to include two reports for “April 20, 8:00 PM and April 20, 10:00 AM”. After a lot of frustrations I found out that those two were using:
"COVID-19.+စောင့်ကြပ်ကြည့်ရှုမှု.+သတင်းထုတ်ပြန်ခြင်း"
And they looked exactly the same.
But when you compare them, it turns out that they are not identical.
"COVID-19.+စောင့်ကြပ်ကြည့်ရှုမှု.+သတင်းထုတ်ပြန်ခြင်း" == "COVID-19.+စောင့်ကြပ်ကြည့်ရှုမှု.+သတင်းထုတ်ပြန်ခြင်း"
[1] FALSE
If you look at the codes, you’ll see why!
[1] "COVID-19.+စောင့\u103aက\u103cပ\u103aက\u103cည့\u103aရ\u103eုမ\u103eု.+သတင\u103aးထုတ\u103aပ\u103cန\u103aခ\u103cင\u103aး"
[2] "COVID-19.+စောင\u103a့က\u103cပ\u103aက\u103cည\u103a့ရ\u103eုမ\u103eု.+သတင\u103aးထုတ\u103aပ\u103cန\u103aခ\u103cင\u103aး"

Create a dataframe for convenience

For convenience the results were collected in a dataframe.
We created a dataframe with title in first column and report text in the second column. For printing out the results to a text file, a third column combining the last two was created.
xM <- data.frame(stringr::str_split_fixed(xvect.02,"\\)",2),stringsAsFactors = FALSE)
xM[,1] <- paste0(xM[,1],")")
xM$xout <- paste0(xM[,1],"\n", trimws(xM[,2]),"\n")

Finally, shared

The following text file (MOHS_COVID-19_Apr3-27.txt) of COVID-19 surveillance reports (COVID-19 ရောဂါ စောင့်ကြပ်ကြည့်ရှုမှုနှင့်ပတ်သက်၍ သတင်းထုတ်ပြန်ခြင်း) for April 3 to 27 is shared as is, here.
writeLines(xM$xout, "MOHS_COVID-19_Apr3-27.txt",useBytes = TRUE)

Tuesday, January 28, 2020

Sylvan Stroll: A tribute to Yodayas - V: Syllable frequencies and...

Sylvan Stroll: A tribute to Yodayas - V: Syllable frequencies and...: I have no idea about what NLP could do in the regular case of English or English-like languages and I’m learning as I go. So it is pretty o...

Saturday, January 18, 2020

Sylvan Stroll: A tribute to Yodayas - IV: Gold and Lady-in-waitin...

Sylvan Stroll: A tribute to Yodayas - IV: Gold and Lady-in-waitin...: For further analysis of Yodaya songs, I tokenized the song “phrases” to be used like words in English language. To inspect a certain “wor...

Sylvan Stroll: A tribute to Yodayas - III: Corpus of songs

Sylvan Stroll: A tribute to Yodayas - III: Corpus of songs: It seems futile to wait for others to give me feedback with the corrected version of songs from the raw text of 35 Mahagita Yodaya songs th...