Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. text<-'this is a long text. its not an email'
  2. text0<-'another piece of text'
  3. text1<-'last sentence of nonsense'
  4. all.text<-list(text,text0,text1)
  5. features1<-data.frame(start=c(1,3,5,7),end=c(2,5,9,12),type=c('na','person','person','location'))
  6. features2<-data.frame(start=c(1,3,5,7),end=c(2,5,9,12),type=c('na','person','person','location'))
  7. features3<-data.frame(start=c(7,8,10,12),end=c(9,9,11,15),type=c('na','person','person','location'))
  8. all.features<-list(features1,features2, features3)
  9.  
  10. one.text<-NULL for (i in 1:nrow(features1)) one.text[i]<-((substr(text,features1[i,1],features1[i,2])))
  11. features1$word<-one.text
  12.  
  13. named.get<-function(text.list,features.list){
  14. named.entities<-substr(text.list,features.list[,1],features.list[,2])
  15. }
  16. all<-sapply(all.text,named.get,all.features)
  17.  
  18. one.obj<-NULL
  19. two.obj<-NULL
  20. for(i in 1:length(all.text)){
  21. for (j in 1:length(all.features)){
  22. one.obj[j]<-list([i]<-((substr(all.text[i],all.features[[i]][j,1],all.features[[i]][j,2]))))
  23. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement