Document Indexing And Retrieval : Assignment 1 เป็นวิชาที่ไม่ได้ลงเรียนแล้ว เขียนโปรแกรมด้วยภาษา groovy (ลองมือ)
file= new File(‘TIME.ALL’)
stopwordsFile=new File(‘stopwords.txt’)
stopwords=[]
stopwordsFile.eachLine { stopwords << it.toString().toUpperCase() }
def isStopWords={ input-> if (stopwords.contains(input)) return true else return false }
def TEXT = /^*TEXT(s|t)+([d]+)(s|t)([d]+.[d]+.[d]+.)(s|t)PAGE(s|t)([d]+)/
def contents=[:]
ID=1
file.eachLine{
m=(it.toString()=~TEXT)
if (m)
{
ID=m[0][2].toInteger()
contents[ID]=[DATE:m[0][4].toString(),PAGE:m[0][7].toString(),DATA:”"];
}
else
{
if(it.toString()!=”*STOP”)
contents[ID].DATA<<=it.toString()
// it.toString().tokenize().each { word -> if(!isStopWords(word)) contents[ID].DATA<<=word.toString()+” ” }
}
}
println contents[563].DATA
Related Blogs
- If Hideki Matsui was American and spoke english, we he be more …
- Something Happen to My Heart (English Version Remake Karaoke) BOF …
- Global Voices in English » Colombia: A Look at Twitter Use Around …
- Global Voices in English » Video: Kids News Network turns to web
- English: A language for all seasons (New Book) | Sistema Limbico
- An English Parliament is more necessary than ever « Autonomous Mind


