13 ธันวาคม 2008Document Indexing And Retrieval : Assignment 1

Document Indexing And Retrieval : 1 เป็นวิชาที่ไม่ได้ลงเรียนแล้ว เขียนโปรแกรมด้วยภาษา (ลองมือ)

 

 

 

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


Tags: ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

Comment ไม่ได้กดที่นี่

Get Adobe Flash playerPlugin by wpburn.com wordpress themes