Document Indexing And Retrieval : Assignment 1

 - by NAzT
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

เรื่องที่เกี่ยวข้อง