How to classify strings using r
My text file is such a structure.
>cell_c2< 8/30/2017 This location has been closed for a few months. Recently I passed by and attracted by their street sign Teriyaki Grill Open. I gave a try. The cashier was friendly and recommended me to try their most popular Teriyaki chicken box. It came with mixed vege and steamed rice. They have an open kitchen with SS equipment. I could see the chef make grill after my order was placed. I love the teriyaki chicken with white rice. The full box costs $8 after tax. I think it's pretty reasonable for what you get near the University area. The chicken is tasty, tender, fresh, and not-to-sweet. I like this little new place, clean and friendly. Next time I will try their noodle., 5/5/2014 1 check-in After avoiding Sono express for five years I thought I'd give it a try to see if it had improved. ??Alas, no better than in 2008. ??The food is edible but for an Asian restaurant, I would place it on a very low tier of quality. ??Paper plates and plastic knives and forks are the norm. ??A 3 item combo seemed overpriced for the quality at $8.50. ??The egg roll was like one at the deli of a supermarket while the mixed vegetable was overlooked cabbage and broccoli with a chicken stock sauce. ??The teriyaki chicken was in small chunks and the meat tasted old. ??Sorry if my review mimics my tip, but, I felt I should review this place to dissuade others from coming here. ??I wish it were good, a quality Asian place would benefit the university neighborhood.Sono Express facadeSono Express facade, 11/10/2015 Updated reviewI regularly stopped by to have Taiwanese Pork Chop rice, and I'm a little bit sad that I found out the business has a new owner now., 10/31/2015 Convenient location, friendly staff.I think I got some chicken with my mirin, but I'm not sure. The sauces were so vinegary I couldn't tell. Did the 3-entree special, cost $8.55 after tax for 3 very small portions of this vinegary meat and a plentiful portion of white rice. I've come to expect value to be an unheard of concept near the U, but this one takes the cake. If I had paid $6 for the meal I'd still be unsatisfied due to the lack of flavor.It's a shame, because this is a prime location for a hole-in-the-wall Asian restaurant., 10/29/2012 1 check-in I like this place for a few reasons.It's around the corner from the law school, is cheap and all the breaded/fried meats and fish are pan fried when you order them rather than hours before. ??All the bentos come with a big plate of rice that's always perfectly cooked (fluffy, warm, and almost buttery in texture), some sauteed veggies on the side (usually cabbage, carrots, etc.), and a main attraction--a breaded pork cutlet, a piece of fried fish, chicken drumsticks, etc. ??I can't say enough good things about the fried fish. ??The breading is light, crispy and well-seasoned. ??The fish inside is a garden variety white fish, and it's always piping hot and cooked thoroughly yet still moist and tender. ??I had the beef noodle soup today which is a new offering. ??It was really filling with a ton of noodles and a super rich beefy broth. ??It was dominated by egg noodles, which was fine by me, because I'm a pig for noodles. ??The beef was the star of the dish--it reminded me of a pot roast where it literally melts in your mouth. ??The broth was also impressive. ??My only criticisms are that the bok choy seemed like an afterthought and there wasn't enough broth. ??I wonder if the noodles soaked up quite a bit of broth the longer the soup sat in front of me. ??I've never tried any of the Americanized items. ??I usually stick with the fish bento or the Tonkatsu. ??They used to do a Katsu bowl which had fluffy, almost whipped eggs mixed in with the breaded pork and rice. ??It was my favorite, but they've not offered it the last few times I was in.Probably the thing I appreciate most about this place is that they really don't give a damn about impressing you. ??Take its paper plates and styrofoam cups or leave it. ??They have enough of a consistent Asian student clientele that they don't need to advertise or use actual dishes or provide an especially warm dining experience. ??I come here when I want to be anonymous. ??Most patrons dining in are Asian, while most others pop in for to-go orders.This is not a destination spot by any means, but it's a nice option to have around campus for when you're in the mood for something that's cheap and tastes relatively homemade, if a little boring in variety.Fish bento.Fish bento.Beef noodle soup. I think this is seasonal during the fall/winter.Beef noodle soup. I think this is seasonal during the fall/winter., 10/15/2011 7 check-ins This hole-in-the-wall place seemed sketchy at first, but alas, I found a nice old Asian couple making simple Asian food for a living here.The food is decent and tastes better than what they serve at the Union over at the University of Utah. The only thing I really recommend here is their two or three combo plates for approximately six to eight bucks. Other than that, there's nothing much here.The seating inside of Sono Express.The seating inside of Sono Express.The windows of Sono Express.The windows of Sono Express., 3/19/2013 Clean and small restaurant. Great food on Chinese menu!Added an egg and a chicken leg. Delicious!Added an egg and a chicken leg. Delicious!, 8/10/2011 This place is good chice for a hungary student who is looking for sth sweet and like chiness. Its very quite and interestingly there is no music. I suggest its two and three choices plate. The quality is acceptable but not that good., 10/8/2009 This place is inexpensive and not that bad. Sure, it's nothing fancy, sure the plates are paper, but hey, the food is decent (not earth-shattering) and cheap!I would recommend this place to anyone who wants standard American-Chinese fair and does not want to spend much!, 5/8/2012 This is probably the worst place I have ever been to. It is expensive if you consider the quality of food they serve and ambience even if you compare it to the regular university hang-outs.The only sauce they have is teriyaki.They serve food in paper plates which still might have been acceptable had the owner/waitress kept her fingers off my food.There are no refills for the drinks.Since they don't appreciate you throwing your leftover drinks in the food garbage bin, you will find a small bucket right next to it, in which you will have to pour your drink. I found that pretty disgusting and was wondering whether they had ever been inspected.I will never go there again in my life. I absolutely hated everything.....in spite of it being right across from the university and being supposedly cheap., 9/19/2007 First to Review Listed in Wanugee 100! Japanese, Wanugee! Salt Lake CitySono Express is your typical Collegetown food place. Cheap and across from campus. In this case, U of U campus, home of the Utes! By cheap, think paper plates and cups! The highest quality thing in here are the disposable chopsticks...they use the better pointed barrel Japanese type that separate at one end, instead of the cheaper flat square ones that are joined the entire length and never split evenly! Such a luxury!Japanese and Chinese Cuisine is their moniker. All of those words are a stretch of the truth. Japanese? There is tonkatsu, tempura, etc, but every dish is served with teriyaki sauce. What does this tell you? Chinese owners! No self-respecting Japanese would run a Teriyaki only place, unless there were no asians for 50 miles to appreciate real asian food. You know all of those Teriyaki places in OR and WA? (you know what I am talking about Portland and Seattle! They are everywhere!) Those are Chinese, Koreans or Vietnamese passing off cheap teriyaki dishes as Japanese food to ignorant non-asians whose only known Japanese food is Teriyaki something. So this abomination has spread to Utah! Actually, the owners are Chinese, I heard them speaking Cantonese, and they didn't know what Donburi was. Half the menu is Chinese which consists of the normal Low Fan oriented dishes you will find at Panda Express at your nearest suburban mall. (Actually, P.E. is a lot better quality!). Hey, but as a starving student, you don't care about quality food, you want your food budget to stretch a long ways so you have more for your beer budget! At least I did, when I was at Uni. (actually, I would bum off my buddies. They liked me so much or felt sorry for me enough that they would invite me to join them for a bite or a brew and help pay!)I digress. Nothing over $10 on this menu. The Shrimp Tempura was served on a paper plate, the diet coke in a paper cup, and the total was under $10. There were 5 shrimp pieces plus veggies, with a batter between real tempura and Jack in the Box onion rings. And the dipping sauce was...you guessed it....Teriyaki!, 8/19/2011 Every time we visit my Alma mater, my family comes to Sono Express for lunch. ??This year we found they added some traditional Chinese dishes. ??They are written in Chinese on the menu board, consisting of Pork barbecue, Lu Eggs, and roasted pork feet. ??We love them, reminds me of the lunch box on-board Taiwan's trains! ??We also love their fried tempura vegetables and sushi rolls. ??The price is very reasonable and the food is fast.
>cell_c3<1/15/2016 1 check-in First to Review This is a little food stand right outside of Wells Fargo. ??It's adjacent to The Curryer which has been there for years and is delicious and loved by many. ??They opened up recently so I decided to brave the cold weather and go try it out for the first time. I ordered the Bibimbap with Fire Chicken. ??The basic description of Bibimbap is that it comes with some rice, veggies, meat, sauce, and a fried egg. ??You mix it all together and then enjoy. Buldak (the name of the stand) translates to Fire Chicken. I expected the fire chicken to be spicy - it wasn't spicy at all. ??Instead it more tasted like it was cooked in a fire, it had a charred/smoky taste to it. ??I wish that it had been spicier.My deduction for stars is because the meal ended up not being that enjoyable. ??It wasn't my favorite Korean food I've had and it was cold/lukewarm. ??When I walked up to the stand at 11:30 it didn't look like they were quite ready, but I asked if they were open. They said yes, took my order, and then started to prepare my dish. ??I saw the egg and chicken get cooked right in front of me, so it was peculiar that my meal was so cold. ??I think it was because the rice and veggies were cold so when it was all mixed up the temps changed to a colder dish. ??It was also a really cold day outside, but I got my hot meal and walked a couple hundred of feet to work.If you like Korean food, I'd recommend giving this place a try. ??Everything is under $10 and the portions are big. ??Plus there aren't a lot of Korean food options within walking distance nearby.Fire chicken bibimbapFire chicken bibimbap, 4/12/2016 I tried the chicken bibimbop- my egg was cooked all the way through so kind of gross and the chicken wasn't reheated all the way through. Great concept, but fell way too short in execution. I've tried 4x and keep feeling disappointed.
>cell_c4< 4/1/2017 Soooo good. We had been actively avoiding this place because of its sketchy exterior and now I hugely regret that decision. It's been right down the street and I've been missing out for HOW LONG??!! The interior has been revamped into what is actually a very pleasant atmosphere.We got the spicy seafood bibimbop, beautifully crusty rice and delicious veg and seafood out of a sizzling clay bowl. It could have been spicier but a bit of gochujang brought out by the lovely waiter solved that problem.However, the true star of the show was the LA short rib bulgogi! I am still drooling after the dish is long gone. Perfectly marinated and marbled. So yum. So so yum.Short rib bulgogi and seafood bibimbopShort rib bulgogi and seafood bibimbop, 4/21/2017 Updated review8 check-ins Another great meal! I got a message that this place will be closing soon. That is too bad cause the food and service was excellent!Pot stickersPot stickersGambitang awesomeGambitang awesomeShort ribShort rib See all photos from John C. for Seoul Garden , 2/8/2017 Seoul Garden should absolutely be your Korean BBQ go-to.My boyfriend and I have practically become regulars at this charming family-owned restaurant, thanks to the good food, super friendly service, and well-priced BBQ options. Yun, who has been our server every time we've gone, is so sweet and always makes us feel welcome. She has an awesome upbeat attitude, especially on top of going to school full-time. We pretty much want her to be our best friend.One of the greatest things about Seoul Garden is their a la carte tabletop grill BBQ option that I haven't seen at any other Korean restaurants in Salt Lake. Basically, you can either choose the 2-person Korean BBQ meals that come with rice and side dishes, or you can pick from 6 a la carte meats that don't come with any other sides, but are cheaper (and you get more bbq variety). With the second option, you can also get yummy DIY hot pot with add-on options of veggies, udon noodles, seafood, and more. Our favorite BBQ picks are the marinated short ribs (kalbi), pork belly (samgyeopsal), and marinated beef (bulgogi). Their marinade is delicious! The first time we went we were a little confused about the BBQ options, but Yun explained it all to us, and they've since updated the menu with a chart that goes over the details.Of the other dishes we've tried there, the hot stone bibimbap, kimchi jjigae, and dduk mandu guk were our favorites!Definitely check out this gem, and support a local, family-owned business!Dduk mandu guk, or rice cake dumpling soup. Yummy broth, described by the eater as a great hearty soup.Dduk mandu guk, or rice cake dumpling soup. Yummy broth, described by the eater as a great hearty soup.Side dishes!Side dishes!A la carte tabletop BBQ - 2 orders of short ribs, 1 marinated beefA la carte tabletop BBQ - 2 orders of short ribs, 1 marinated beef See all photos from Erin F. for Seoul Garden , 12/9/2016 COMPLETELY CLUELESS is the only way to describe this place. ??I asked what kind of noodles came with soups, where it was not listed on the menu. ??The server had no idea. ??The menu isn't very extensive, how could that be? ??He went to check and, still very unsure, mumbled something about them coming with ramen, so I asked if I could substitute rice noodles. ??I explained that I have a food intolerance and could not have wheat. ??The server then proceeded to recommend vegetarian dishes, which was completely baffling. ??I am not vegetarian nor did I ask anything about vegetarian options. ??When I asked if that was the only gluten free option, he said that he needed to check again. This time he came back saying that I can get a side of rice noodles with any of the soups. ??I pointed out that I still cannot have a soup with wheat noodles in it. ??He asks if I am a vegetarian, which again makes no sense. ??The whole time I have been asking about beef and pork dishes. ??At this point, it is still completely unclear to both me and the server what ingredients are in any of the dishes. ??I ask which dishes are gluten free or can be made gluten free. ?? Anyway, he goes to check again. ??For the same thing. ??And he is incredibly slow moving, so we've now been sitting here for 20 minutes while he figures out how to locomote to the other side of the building.This time he says he can't make any substitutions... ??Why didn't he just say this in the first place?!? ??He also still didn't know what noodles come with anything. ??Unfortunately, we just had to leave at this point due to the complete lack of comprehension on behalf of this simpleminded individual and whoever was serving as the manager on duty at the time. ??It is quite unfortunate that people in hospitality could be so completely ignorant about the food that they are serving., 10/8/2016 1 check-in I really wanted to like this place because of the reliable reviews of my fellow yelpers, but I was a little disappointed and here's why. Don't get me wrong, the service and food were good. I just wanted my usual Korean BBQ experience with a little bit of homemade touch. In regards to the Korean BBQ experience, I'm talking about the servers firing up the grill and we cook the meat at our own pace. ??Tongs were provided to pick up our protein and lay them on the grill. ??We ordered the pork belly and the prime beef, both not marinated. ??My friend and I planned to cook a few pieces here and there so it wouldn't overcook on the grill or get cold after a few minutes. ??Well that plan went downhill when the chef from the came to our table and asked us if she can help us cook. ??I wasn't sure what to expect so I said, SURE!. She took our plate and distributed it all over the grill. (Sad face). As I attempt to add some pork belly, she recommended not to. We didn't want to be rude if this was their usually routine, but I didn't really like it. It also felt like they took over our cooking experience and then standing over us was a little uncomfortable at times only because I wanted to catch up with my buddy. I was also expecting a lot more side dishes and wanted some of the items to taste more homemade. ??The broccoli was just boiled with no added flavors. The Kimchee tasted like the ones I've had in the jar. The BBQ sauce provided tasted like the ones I buy for my baked beans. If you need extra lettuce, it's $1.50 more and they give you 6 pieces to start with. The bean sprouts are awesome though.....yay! Like other similar Korean BBQ restaurants in SLC, I think its overpriced for the amount of food you get. I know my review sounds like it should be a 2 star rating, but the restaurant was clean, food was good and staff are friendly. ??I just wish for homemade taste and more of my own hands on cooking experience.Vegetable tempura with soy sauceVegetable tempura with soy saucePrime beefPrime beefIf you need more lettuce, they charge $1.50If you need more lettuce, they charge $1.50 See all photos from Mylan D. for Seoul Garden , 12/6/2016 1 check-in Had high expectations coming in hearing great reviews. ??It was good. ??A solid 3.5 stars at best. I thought the servings could be bigger especially at these prices. I could mention a few other Korean joints in town that are similar to prices but serve a lot more food. The ribs and bulgogi were good. Banchans were tasty. ??Service was Great! Overall pretty good. ??I just felt there was something missing. ??And I can't quite figure it out. ??Karaoke maybe?Seafood pancakeSeafood pancakeSpicy goodnessSpicy goodnessKorean red wine (chilled)Korean red wine (chilled), 4/25/2017 1 check-in Great food!! Meat was marinated to perfectly! Plum wine was perfect. Great service. Good place eat hang out and eat.Plum winePlum wine, 1/24/2016 Updated review4 check-ins I threatened our server if that she did not use my card for payment over my friends that I would leave a bad review. I was kidding, kind of, no really I was definitely kidding. Even if she did not use my card, I would have left a good review! This establishment deserved a bump up from their previous rating because of their black bean noodles (usually only offered during lunch Monday-Thursday but they made it for me on a Saturday evening), their delicious kim chi, consistency in grilled mackerel (no surprise here), excellent service, and seriously how cute the yellow pickled radish was (usually comes with black bean noodles). The only downfall this time around was the sweet and sour chicken. I didn't really enjoy the sauce, it was too sweet and not tangy enough. But overall, this was a pretty solid visit.-Sailor outSweet and sour chickenSweet and sour chickenSpicy pork hot stone potSpicy pork hot stone potBlack bean noodlesBlack bean noodles, 2/11/2017 1 check-in Great food & amazing service!! We started w/the fried dumplings, then got the marinated beef, spicy pork, spicy octopus & a broth w/their seafood medley! Wow! So yum! All of these dishes were phenomenal & our server Jackson was wonderful! Try it out if you haven't yet! You won't be disappointed!Great food & Amazing Service! All of these dishes were phenomenal & our server Jackson was wonderful! Try it out if you haven't yet!Great food & Amazing Service! All of these dishes were phenomenal & our server Jackson was wonderful! Try it out if you haven't yet!We had the fried dumplings, marinated beef to grill, spicy pork, spicy octopus & seafood medley broth!We had the fried dumplings, marinated beef to grill, spicy pork, spicy octopus & seafood medley broth!, 3/30/2017 My husband and I can here for dinner on a Sunday night. We were hungry early so decided to go right when they opened. There were already at lest five parties here before they unlocked the door! My guess is this place gets busy fast. We had the Korean BBQ that we cooked ourselves as well as the bipbimbop bowl. Both amazing. The service was also great and every person that helped us did so with a smile on their face. Definitely a place we will add into our weekend rotations., 1/4/2017 2 check-ins I think I've found a new Korean restaurant for me to frequent, because this place was delightful! Our server was very friendly and quick, the food was absolutely delicious, and the place was very open and clean. Plenty of options on the menu, though for those that aren't familiar with Korean fare, more pictures and/or descriptions may be helpful.One thing to note: if you want to order any bbq/grill type of foods, make sure you tell them before they seat you. I saw a table have to get up and move to another side because one guy wanted bbq., 3/9/2016 1 check-in ROTD 8/22/2016 I think I'm in love with this place. My husband I stopped in here for dinner for the first time a couple of weeks ago. I was initially skeptical because we were the only customers (granted, it was about 830pm on a Thursday), however that skepticism didn't last long. We started with a bit of soju, which was a very nice treat. It's very difficult to find non-Tyku soju anywhere around (even in the liquor store), but they have a couple of different varieties here. We were overwhelmed with all the tasty sounding choices, but finally settled on the tableside BBQ with spicy squid and pork belly. I'm often worried about overcooking or undercooking my food in this context, but our server made sure everything was cooked properly, and it was absolutely delicious! The sauce was very flavorful (but not devilishly spicy for us, we used the whole thing without a problem). The service was absolutely fantastic. Our server was very helpful with food and drink recommendations and is very enthusiastic about all the stuff they serve. Given the amount of customers there on that particular night, I'm a little worried about this place surviving, so please visit! I want to try all the things on the menu (which is going to take many visits). That won't happen if you don't come eat here too, so please help., 1/1/2017 Service was...well, great as far as filling up water and getting our food went. ??But was very unfriendly and seemed...annoyed we were there. Yeah, we all felt kind of unwelcome. ??The food was ok. We were a party of 6 and they brought out the tiniest amount of side dishes. We are used to K town in LA where the side dishes are always refilled and plentiful and it just seemed really stingy. ??I guess you have to pay for more?They only have some items on the menu 2 days a week...which sucks cause we came for the black bean noodles and they don't serve those on Sunday. The tofu stew was good. ??The bulgogi was decent, but not the best I've had. ??The decor and atmosphere is a little cafeteria like., 2/27/2016 1 check-in I ended up order the Japchae (which was a first for me), and pleasantly surprised. The glassy noodles were tasty along with the sweet potato, mushroom, and whatever else seasoned in this dish. It all came together really well!The staff was very accommodated and even asked us their thoughts on remodeling ideas. The service was certainly topnotch!,
I want to distinguish day / month / year.
I know there are commands. "strsplit" ,"str_split"
But I do not know how to write day / month / year.
If you categorize it, the data is not what I want.
What should I do? I would appreciate it if you could answer me.
b<-readLines(file.choose()) #My document is a .txt file.
B<-strsplit (crudeCorp,"/")
b<-data.frame(B)
write.csv(B,"tqtqtq.csv")
You need to specify a pattern for dates more completely.
## Your sample data
b = "10/1/2017 This was the first restaurant. 9/30/2015 i'm happy. i'm ~~. 6/20/2016 Prices were reasonable.."
Messages = strsplit(b, "\\d{1,2}/\\d{1,2}/\\d{4}")[[1]]
m <- gregexpr("\\d{1,2}/\\d{1,2}/\\d{4}", b)
Dates = regmatches(b, m)[[1]]
if(length(Messages) > length(Dates)) { Messages = Messages[-1] }
as.data.frame(cbind(Dates, Messages))
Dates Messages
1 10/1/2017 This was the first restaurant.
2 9/30/2015 i'm happy. i'm ~~.
3 6/20/2016 Prices were reasonable..
stringr and rebus packages are really helpful and intuitive.
> string<-"10/1/2017 This was the first restaurant. 9/30/2015 i'm happy. i'm ~~. 6/20/2016 Prices were reasonable.."
> library(stringr)
> library(rebus)
> pattern<-
+ capture(dgt(1,2))%R%
+ char_class("/")%R%
+ capture(dgt(1,2))%R%
+ char_class("/")%R%
+ capture(dgt(1,4))%R%
+ capture(one_or_more(or(WRD,char_class(" ","'"))))
> matrix<-str_match_all(string,pattern)
> matrix
[[1]]
[,1] [,2] [,3] [,4] [,5]
[1,] "10/1/2017 This was the first restaurant" "10" "1" "2017" " This was the first restaurant"
[2,] "9/30/2015 i'm happy" "9" "30" "2015" " i'm happy"
[3,] "6/20/2016 Prices were reasonable" "6" "20" "2016" " Prices were reasonable"
Related
I need to count the frequency of unique words found in a column that contains descriptions in each row.
So far, I have eliminated a list of stopwords from the original column and I have extracted the unique words from the column and put them into a list called unique_description.
> description[1:5]
[1] "Come stay Vinh & Stuart (Awarded one Australia's top hosts Airbnb CEO Brian Chesky & key shareholder Ashton Kutcher. We're Sydney's #1 reviewed hosts ). Find out 've positively reviewed 500+ times. Message talk first BEFORE make reservation request - And please read listing end (hint hint). Everything need know . We're pretty relaxed hosts, fully appreciate staying someone , home home, -one. This business, hotel. We're casual Airbnb hosts, hoteliers. If 're looking alternative expensive hotel, 're . Here 'll treated same way treat family & friends stay. So... fluffy bathrobes... Please hello message *BEFORE* make reservation request... It'll help speed things up, smooth things out... Please read listing way end. It make getting confirmed reserv"
[2] "Beautifully renovated, spacious quiet, 3 Bedroom, 3 Bathroom home 10 minute walk beaches Fairlight Forty Baskets, 30 minute walk Manly via coastal promenade, Express bus runs 20 mins door. Our home thirty minute walk along seashore promenade Manly, one Sydney's beautiful beaches, village restaurants, cafes, shopping. If prefer more variety, Manly ferry take Sydney CBD 15 minutes. The residence sited sought- family-friendly street short stroll nearby North Harbour reserve Forty Baskets cafe beach. It's short walk further express CBD buses, ferries, Manly entertainment. Or bus (#131 #132) around corner drops Manly 8 minutes. Our home features stainless steel galley kitchen, including Ilve oven gas cooktop. We two separate living areas ground floor. The front lounge enjoys P&O"
[3] "Welcome sanctuary - bright, comfortable one bedroom apartment North Sydney. Free Wifi, heated pool/jacuzzi everything need make stay Sydney very comfortable. Enjoy fabulous Home away home, fantastic stay Sydney! The apartment within walking distance restaurants shops, Luna Park North Sydney business district. Access Sydney CBD easy bus, train, taxi ferry. It short bus ride famous Balmoral Beach Taronga Zoo. My apartment situated North Sydney 3 kms Sydney CBD. Here details apartment: You'll enjoy being centrally located couple blocks away train station go anywhere quickly Sydney. The apartment features several windows tons natural light. It comfortable fully stocked. Here's I here: LIVING ROOM: 50\" LCD TV DVD / blu ray player CD/Radio/Blue tooth syncing w"
[4] "Fully self-contained sunny studio apartment. 10mn walk Bondi beach. Bus city door. Private 13m swimming pool. Sunny, studio apartment . Private terrace. bus door Bondi Junction City Ground floor 1 bedroom double bed plus kitchenette & study desk. shower & toilet, share laundry, kitchen facilities Swimming pool 13m. Separate security private entrance Private entrance. Ground floor. Happy indicate best spots walking, dining, entertaining best sightseeing location Sydney. Upmarket area. Very nice quiet neighbourhood . Very safe place. Bus door city."
[5] "Sunny warehouse/loft apartment heart one Sydney's best neighbourhoods. Located corner two iconic Darlinghurst streets famous laneway bars eateries, footsteps equally amazing Surry Hills Potts Point. Walk through beautiful parks city less 10 mins, opera house 20 access Bondi Beach easily 25 via bus stop directly front building. My apartment beautiful, simple, open plan / one bedroom loft soaring high ceilings hardwood floors hint 's previous life printing factory 1940s. It huge windows flood space glorious sunshine throughout day provide refreshing breeze during summer. A few key features: * Wireless harman/kardon aura stereo system stream music wirelessly bluetooth device * Internal laundry washer dryer * The kitchen equipped gas cooking, microwave, dishwasher basics preparing m"
> unique_description[1:10]
[1] "Come" "stay" "Vinh" "&" "Stuart" "(Awarded"
[7] "one" "Australia's" "top" "hosts"
I'm not sure how to count the frequency of the words in unique_description that are found in the column 'description'. I tried using freq_terms in library(qdap), but qdap will not load for me so am trying to find another way.
You could use the stringr package.
library(stringr)
x <- "Come stay Vinh & Stuart (Awarded one Australia's top hosts Airbnb CEO Brian Chesky & key shareholder Ashton Kutcher. We're Sydney's #1 reviewed hosts ). Find out 've positively reviewed 500+ times. Message talk first BEFORE make reservation request - And please read listing end (hint hint). Everything need know . We're pretty relaxed hosts, fully appreciate staying someone , home home, -one. This business, hotel. We're casual Airbnb hosts, hoteliers. If 're looking alternative expensive hotel, 're . Here 'll treated same way treat family & friends stay. So... fluffy bathrobes... Please hello message *BEFORE* make reservation request... It'll help speed things up, smooth things out... Please read listing way end. It make getting confirmed reserv"
y <- "come stay Stuart"
unique_desc <- c("come", "stay", "Stuart")
desc <- c(x,y)
result <- lapply(desc, FUN = str_count, pattern = unique_desc)
#result holds first element is counts in first element of desc
lapply will call the str_count function to each element of desc. In this example the ith entry of result there is a vector of counts corresponding to the ith entry of desc and the vector of counts correspond to the counts of each word in unique_desc.
I have one page story (i.e. text data), I need to use Bayesian network on that story and analyse the same. Could someone tell me whether it is possible in R? If yes, that how to proceed?
The objective of the analysis is - Extract Action Descriptions from
Narrative Text.
The data considered for analysis -
Krishna’s Dharam-shasthra to Arjuna:
The Gita is the conversation between Krishna and Arjuna leading up to the battle.
Krishna emphasised on two terms: Karma and Dharma. He told Arjun that this was a righteous war; a war of Dharma. Dharma is the way of righteousness or a set of rules and laws laid down. The Kauravas were on the side of Adharma and had broken rules and laws and hence Arjun would have to do his Karma to uphold Dharma.
Arjuna doesn't want to fight. He doesn't understand why he has to shed his family's blood for a kingdom that he doesn't even necessarily want. In his eyes, killing his evil and killing his family is the greatest sin of all. He casts down his weapons and tells Krishna he will not fight. Krishna, then, begins the systematic process of explaining why it is Arjuna's dharmic duty to fight and how he must fight in order to restore his karma.
Krishna first explains the samsaric cycle of birth and death. He says there is no true death of the soul simply a sloughing of the body at the end of each round of birth and death. The purpose of this cycle is to allow a person to work off their karma, accumulated through lifetimes of action. If a person completes action selflessly, in service to God, then they can work off their karma, eventually leading to a dissolution of the soul, the achievement of enlightenment and vijnana, and an end to the samsaric cycle. If they act selfishly, then they keep accumulating debt, putting them further and further into karmic debt.
What I want is - post tagger to separate verbs, nouns etc. and then create a meaningful network using that.
The steps that should be followed in pre-processing are:
syntactic processing (post tagger)
SRL algorithm (semantic role labelling of characters of the story)
conference resolution
Using all of the above I need to create a knowledge database and create a Bayesian network.
This is what I have tried so far to get post tagger:
txt <- c("As the years went by, they remained isolated in their city. Their numbers increased by freeing women from slavery.
Doom would come to the world in the form of Ares the god of war and the Son of Zeus. Ares was unhappy with the gods as he wanted to prove just how foul his father’s creation was. Hence, he decided to corrupt the mortal men created by Zeus. Fearing his wrath upon the world Zeus decided to create the God killer in order to stop Ares. He then commanded Hippolyta to mould a baby from the sand and clay of the island. Then the five goddesses went back into the Underworld, drawing out the last soul that remained in the Well and giving it incredible powers. The soul was merged with the clay and became flesh. Hippolyta had her daughter and named her Diana, Princess of the Amazons, the first child born on Paradise Island.
Each of the six members of the Greek Pantheon granted Diana a gift: Demeter, great strength; Athena, wisdom and courage; Artemis, a hunter's heart and a communion with animals; Aphrodite, beauty and a loving heart; Hestia, sisterhood with fire; Hermes, speed and the power of flight. Diana was also gifted with a sword, the Lasso of truth and the bracelets of penance as weapons to defeat Ares.
The time arrived when Diana, protector of the Amazons and mankind was sent to the Man's World to defeat Ares and rid the mortal men off his corruption. Diana believed that only love could truly rid the world of his influence. Diana was successfully able to complete the task she was sent out by defeating Ares and saving the world.
")
writeLines(txt, tf <- tempfile())
library(stringi)
library(cleanNLP)
cnlp_init_tokenizers()
anno <- cnlp_annotate(tf)
names(anno)
get_token(anno)
cnlp_init_spacy()
anno <- cnlp_annotate(tf)
get_token(anno)
cnlp_init_corenlp()
I'm trying to read a huge file with fread, but i guess something is messed with the layout of the file.
If i try to read the file with
data = fread(input = "../data.txt", sep = "\t")
on this file (i just took the line with the error and few before and after):
ID imdbID Title Year Rating Runtime Genre Released Director Writer Cast Metacritic imdbRating imdbVotes Poster Plot FullPlot Language Country Awards lastUpdated Type
683 tt0000683 The Fatal Hour 1908 14 min Short, Crime 1908-08-18 D.W. Griffith D.W. Griffith George Gebhardt, Harry Solter, Linda Arvidson, Florence Auer 5.9 26 Pong Lee, a Mephistophelian, saffron-skinned varlet, has for some time carried on this atrocious female white slave traffic, in which sinister business he was assisted by a stygian whelp, ... Pong Lee, a Mephistophelian, saffron-skinned varlet, has for some time carried on this atrocious female white slave traffic, in which sinister business he was assisted by a stygian whelp, by name Hendricks. Pong writes Hendricks that he has need for five young girls, and so Hendricks sets out to secure them. Visiting a rural district, he has no trouble, by his glib, affable manner, in gaining the confidence of several young and pretty girls. Pong is on hand with a closed carriage to bag the prey. One of the girls, as she is seized, emits a yell that alarms the neighborhood and brings to the scene several policemen and a couple of detectives, who have long been on the lookout for these caitiffs. The Chinese get away with the carriage, however, and Hendricks by subterfuge throws the police on the wrong scent. One of the detectives is a woman, and possessed of shrewd powers of deduction, hence does not swallow the bald story of the villain, and exercises her natural acumen with success. She shadows Hendricks, and by means of a flirtation inveigles him to a restaurant, where she succeeds in doping his drink. He falls asleep and she secures the letter written by Pong, which discloses the hiding place of the Chinaman. This she immediately telephones to the police, and while so doing Hendricks awakes and starts off to warn his friends. He arrives at the old deserted house ahead of the police, but escape is impossible, so the police rescue the girls, but fail to secure Pong and Hendricks, who afterwards seize the girl detective, and taking her to the house, tie her to a post and arrange a large pistol on the face of a clock in such a way that when the hands point to twelve the gun is fired and the girl will receive the charge. Twenty minutes are allowed for them to get away, for the hands are now indicating 11:40. Certain death seems to be her fate, and would have been had not an accident disclosed her plight. Hendricks after leaving the place is thrown by a street car, and this serves to discover his identity, so he is captured and a wild ride is made to the house in which the poor girl is incarcerated. This incident is shown in alternate scenes. There is the helpless girl, with the clock ticking its way towards her destruction, and out on the road is the carriage, tearing along at breakneck speed to the rescue, arriving just in time to get her safely out of range of the pistol as it goes off. In conclusion we can promise this to be an exceedingly thrilling film, of more than ordinary interest. English USA 2015-10-24 01:44:09.623000000 movie
684 tt0000684 Father Gets in the Game 1908 10 min Short, Comedy 1908-10-10 D.W. Griffith D.W. Griffith Mack Sennett, Harry Solter, George Gebhardt, Linda Arvidson 5.1 39 "You have got to keep up with the bandwagon or quit." This never impressed old Wilkins so forcibly as when his son and daughter give him the go-by, stamping him as a "has-been," and away ... "You have got to keep up with the bandwagon or quit." This never impressed old Wilkins so forcibly as when his son and daughter give him the go-by, stamping him as a "has-been," and away out of the game. Even Mrs. Wilkins, who is as vivacious as a widow, snubs him. He keenly feels his condition and resolves to alter it. With this in view, he enlists the services of Professor Dyem, the celebrated Dermatologist and Tonsorial Artist. After a session with the Professor, beheld the transmogrified Wilkins. What a change! Shorn of his grizzly beard, his locks raven, complexion florid, eye clear and step elastic, he views himself in the mirror. He hardly recognizes himself. In fact, it requires his valet to convince him that he is he. "Am I in it? Well. I guess. If I don't keep up with and even beat that bandwagon by a city block, my name is not Pill Wilkins." He sallies forth and makes for the park. The first person he encounters is his wife. He approaches her in elation, but she mistakes him for an impudent masher and he receives the weight of her parasol over his head for his trouble. The next one he meets is his daughter. She is seated on a bench, waiting for Charley. He takes a seat beside her and when he tries to make himself known she draws herself up to full height and with a blow sends him backward over the bench onto the grass. Well, he changes his tactics, and gets reckless. Along comes his son with his best girl, so he decides to win her out for spite. Now this young lady has a sensitive pneumogastric nerve, and when he sits beside her on the bench and slyly suggests a cold bottle and a hot bird, she is "his'n." This is done so coolly and so quickly, that young Wilkins, who, of course, does not recognize his respected papa, is speechless with rage. He follows them, however, to the café, where his intrusion is resented and he is rudely thrown from the place. At the Wilkins' domicile there is an indignation meeting. Mother, daughter and son all rush in to relate their experiences to father. He is not to be found. Suddenly a hilarious individual enters. "'Tis he, the insulter: a drunk and disorderly." They are about to have him thrown out when the valet comes to his rescue and explains that the jubilant gentleman is no other than their dear papa, who has not only caught up with the bandwagon, but is sitting on the seat with the driver. They all gasp in surprise, and young Wilkins takes a wreath of laurel from a statue and places it on old Wilkins' brow, saying: "Pop, you are the candy." English USA 2015-10-02 04:59:48.643000000 movie
685 tt0000685 The Feud and the Turkey 1908 15 min Short, Drama, Romance 1908-12-08 D.W. Griffith D.W. Griffith Harry Solter, Linda Arvidson, Arthur V. Johnson, Robert Harron 5.8 13 The Wilkinsons and Caulfields, owing to a trivial dispute, had been at loggerheads for years and as time went on the feeling became more bitter, until they even forbade their children ... The Wilkinsons and Caulfields, owing to a trivial dispute, had been at loggerheads for years and as time went on the feeling became more bitter, until they even forbade their children playing together. The little ones, however, in their childish innocence, could not appreciate the odium of their elders, and Bobby Wilkinson and Nellie Caulfield became child lovers. This incensed Colonel Wilkinson, who tore the children apart, ordered Bobby never to be seen in her company again. The Colonel's action ignited the ire of the Caulfields and a furious conflict ensued, resulting in the shooting to death of George, the Colonel's youngest son, a boy of fourteen. From that time on the clans kept strictly to themselves. But love knows no clannishness, and, despite family hatred, Bob and Nellie remained lovers. After ten years, driven to desperation by this apparently insurmountable barrier, they elope and are married. Bob decides to brave the storm of his father's anger and present his wife, but the old Colonel drives him from the house, disowning him. Old Aunt Dinah and Uncle Daniel, the colored servants, were so attached to the young folks that they go with them. Two years later we find the little family, now increased by an infant son, having a hard of it. It is Christmas morning and no turkey for dinner. Old Aunt Dinah, believing in the efficacy of prayer, gets down on her knees in the kitchen to ask the good Lord to send them a bird. Uncle Daniel, touched by this demonstration of faith, takes a gun and determines to get a turkey at any hazard. Over the hills he goes, but his journey is hopelessly fruitless until he comes to the rear of the Colonel's house. Tillie, the cook, has just hung a fat turkey on a post outside the kitchen door. When Daniel sees it he can't resist the temptation. Back home he hustles and finds Dinah still at prayer, he lays the fowl on the floor beside her and sneaks out. When Dinah sees it she surely thinks it was due to her prayers. Well, the turkey is cooked and an old-fashioned Christmas anticipated. Meanwhile the Colonel has discovered his loss and tracks the thief to Bob's estate. Entering, a tragedy seems inevitable, but when the old Colonel sees the young one, his grandson, in the cradle, his heart goes out to it and the feud ends then and there. All hands sit down and enjoy a real Merry Christmas dinner. English USA 2015-08-29 00:33:15.610000000 movie
686 tt0000686 Fiestas del carnaval de 1908 en Barcelona 1908 Documentary, Short Fructuós Gelabert Fructuós Gelabert Spain 2015-11-09 14:24:29.583000000 movie
I get this error:
> Error in fread(input = "../data.txt", sep="\t" : Expected sep (' ') but new line, EOF (or other
> non printing character) ends field 20 when detecting types ( first):
> 684 tt0000684 Father Gets in the Game 1908 10 min Short,
> Comedy 1908-10-10 D.W. Griffith D.W. Griffith Mack Sennett, Harry
> Solter, George Gebhardt, Linda Arvidson 5.1 39 "You have got to keep
> up with the bandwagon or quit." This never impressed old Wilkins so
> forcibly as when his son and daughter give him the go-by, stamping him
> as a "has-been," and away ... "You have got to keep up with the
> bandwagon or quit." This never impressed old Wilkins so forcibly as
> when his son and daughter give him the go-by, stamping him as a
> "has-been," and away out of the game. Even Mrs. Wilkins, who is as
> vivacious as a widow, snubs him. He keenly feels his condition and
> resolves to alter it. With this in view, he enlists the services of
> Professor Dyem, the celebrated Dermatologist and Tonsorial Artist.
> After a session with the Professor, beheld the transmogrified Wilkins.
> W
How can i solve it?
I'm not 100% sure what the error is in your data, here, but try running the code with
data = fread(input = "../data.txt", sep = "\t", fill = TRUE)
in the fread options. I had a similar error, and it seemed that fread was having trouble identifying my column separation. Setting fill to true allows fread to fill in any missing data- at least then you can check the resulting data frame and find out where the weirdness is.
Add fill = TRUE in the syntax
What's happening: The rows in the data have unequal length. With this syntax, blank fields are implicitly filled.
Please anyone can help me to import angle brackets data into R from a unix executable file. It seems like an XML type so, I tried to use XML parser but it failed.
I have attached sample file.
Thanks in advance.
https://drive.google.com/file/d/0B97ow4h4jwHcRTVtWHdudDJ0c1k/view?usp=sharing
'&' characters exist in elements in your XML document.
One example is below:
<DOC>
<DATE>01/07/2009</DATE>
<AUTHOR>Debce</AUTHOR>
<TEXT>I have owned my MDX for about 1 1/2 yrs & have loved every minute of driving the 24k problem free miles on it! It is so much fun to drive; looks & feels luxurious so no problem pulling up to upscale places! I didn't want to give up space to pop things in the back and go so I keep the third seat down & purchased the rubber mat for the back. I have plenty of room while at the same time I am "zippy"; easily pulling into parking spaces and getting around town. I love the navigation system, although it does need updating and the bluetooth is wonderful, although for some reason it keeps unhooking my Treo phone which the Acura people say is the phone's fault. LOVE IT & would buy it again.</TEXT>
<FAVORITE>Large storage area, hands free phone with the bluetooth & voice recognition is safe. The heaviness of it feels safe and large interior is very comfortable. </FAVORITE>
</DOC>
'&' characters should be escaped.
'>'
'<'
'&'
'%'
characters are special characters which should be escaped in an XML document.
Here is a way of extracting the data into a character matrix.
> require(XML)
> x <- htmlParse("/temp/2007_acura_mdx")
>
> # get the 'DOC'
> docs <- getNodeSet(x, "//doc")
>
> # display one
> docs[[1]]
<doc>
<date>07/31/2009</date>
<author>FlewByU</author>
<text>I just moved to Germany two months ago and bought an 07 MDX from another military member. It has everything I could want. We just returned from a week driving through the Alps and this SUV is simply amazing. Granted, I get to drive it much faster than I could in the states, but even at 120 MPH, it was rock solid. We need the AWD for the snow and the kids stay entertained with the AV system. Plenty of passing power and very comfortable on long trips. Acuras are rare in Germany and I get stares all the time by curious Bavarians wondering what kind of vehicle I have. If you are in the market for a luxury SUV for family touring, with cool tech toys to play with, MDX can't be beat. </text>
<favorite>The separate controls for the rear passengers are awesome. I can control temp and AV from the front or switch to rear. Sound system is amazing. I will sometimes sit in the driveway and just listen. Also has a 120v outlet in console. Great for us since we live with 220v and need 120 on occasion. </favorite>
</doc>
>
> # process docs getting all fields -- need to transpose
> results <- t(sapply(docs, function(x) xmlSApply(x, xmlValue)))
>
> # show head
> head(results)
date author
[1,] "07/31/2009" "FlewByU"
[2,] "07/30/2009" "cvillemdx"
[3,] "06/22/2009" "Pleased"
[4,] "04/13/2009" "wasatch7"
[5,] "04/06/2009" "mnozek"
[6,] "01/07/2009" "Debce"
text
[1,] "I just moved to Germany two months ago and bought an 07 MDX from another military member. It has everything I could want. We just returned from a week driving through the Alps and this SUV is simply amazing. Granted, I get to drive it much faster than I could in the states, but even at 120 MPH, it was rock solid. We need the AWD for the snow and the kids stay entertained with the AV system. Plenty of passing power and very comfortable on long trips. Acuras are rare in Germany and I get stares all the time by curious Bavarians wondering what kind of vehicle I have. If you are in the market for a luxury SUV for family touring, with cool tech toys to play with, MDX can't be beat. "
[2,] "After months of careful research and test drives at BMW, Lexus, Volvo, etc. I settled on the MDX without a doubt in mind. I love the way the car handles, no stiffness or resistance in the steering or acceleration. The interior design is a little Star Trek for me, but once I figured everything out, it is a pleasure to have all the extras (XM radio, navigation, Bluetooth, backup camera, etc.)"
[3,] "I'm two years into a three year lease and I love this car. The only thing I would change would be the shape of the grill...THAT'S IT. Everything else is perfect. Great performance, plenty of power and AWD when skiing, plenty of room for baggage, great MPG for an SUV, navi system is far superior to GM's Suburban (don't have to put in park to change your destination, etc). Zero problems...just gas and oil changes. One beautiful car...except for the sho-gun shield looking grill."
[4,] "First luxury crossover SUV I have owned. MDX won out over the Lexus, and cost less for a very well equipped base package. Handling, power and ride are outstanding. Back seats are a little less comfortable for my tall teenagers. Back cargo area is very roomy, and easily expandable with 3rd seat folded and back seats down. I drive up snowy, often treacherous mountain canyons to ski in the winter. The SH-AWD system, coupled with the manual shift mode (for descents), is outstanding. The MDX is much better in the snow than 3 truck base SUVs, I have owned previously. "
[5,] "This is the first Japanese SUV we have had in a while. Last SUV's were Yukon XL and Envoy XL. This beats them out by far. Performs almost as well as our Mercedes e class but has the utility of our Envoy. We always take this on trips and it is very comfortable. The third row is great for smaller children but not so much for adults. Best SUV so far. No problems within our almost 2 years ownership."
[6,] "I have owned my MDX for about 1 1/2 yrs & have loved every minute of driving the 24k problem free miles on it! It is so much fun to drive; looks & feels luxurious so no problem pulling up to upscale places! I didn't want to give up space to pop things in the back and go so I keep the third seat down & purchased the rubber mat for the back. I have plenty of room while at the same time I am \"zippy\"; easily pulling into parking spaces and getting around town. I love the navigation system, although it does need updating and the bluetooth is wonderful, although for some reason it keeps unhooking my Treo phone which the Acura people say is the phone's fault. LOVE IT & would buy it again."
favorite
[1,] "The separate controls for the rear passengers are awesome. I can control temp and AV from the front or switch to rear. Sound system is amazing. I will sometimes sit in the driveway and just listen. Also has a 120v outlet in console. Great for us since we live with 220v and need 120 on occasion. "
[2,] "The self-adjusting side mirrors which rotate to give you a view of the curb/lines as you back up. Makes backing into parking spaces and parallel parking a breeze, along with the back-up camera. Also a fan of the push-to-talk for my cell phone."
[3,] "Navi is easy, hands-free is great, AWD is perfect."
[4,] "AWD system, exterior styling, cargo room"
[5,] "Navigation, sound system, bluetooth, comfort, acceleration, performance, all wheel drive ability."
[6,] "Large storage area, hands free phone with the bluetooth & voice recognition is safe. The heaviness of it feels safe and large interior is very comfortable. "
>
>
>
I have data file which has angle brackets from http://kavita-ganesan.com/opinosis-opinion-dataset.
<DOCNO>2007_acura_mdx</DOCNO>
<DOC>
<DATE>07/31/2009</DATE>
<AUTHOR>FlewByU</AUTHOR>
<TEXT>I just moved to Germany two months ago and bought an 07 MDX from another military member. It has everything I could want. We just returned from a week driving through the Alps and this SUV is simply amazing. Granted, I get to drive it much faster than I could in the states, but even at 120 MPH, it was rock solid. We need the AWD for the snow and the kids stay entertained with the AV system. Plenty of passing power and very comfortable on long trips. Acuras are rare in Germany and I get stares all the time by curious Bavarians wondering what kind of vehicle I have. If you are in the market for a luxury SUV for family touring, with cool tech toys to play with, MDX can't be beat. </TEXT>
<FAVORITE>The separate controls for the rear passengers are awesome. I can control temp and AV from the front or switch to rear. Sound system is amazing. I will sometimes sit in the driveway and just listen. Also has a 120v outlet in console. Great for us since we live with 220v and need 120 on occasion. </FAVORITE>
</DOC>
<DOC>
<DATE>07/30/2009</DATE>
<AUTHOR>cvillemdx</AUTHOR>
<TEXT>After months of careful research and test drives at BMW, Lexus, Volvo, etc. I settled on the MDX without a doubt in mind. I love the way the car handles, no stiffness or resistance in the steering or acceleration. The interior design is a little Star Trek for me, but once I figured everything out, it is a pleasure to have all the extras (XM radio, navigation, Bluetooth, backup camera, etc.)</TEXT>
<FAVORITE>The self-adjusting side mirrors which rotate to give you a view of the curb/lines as you back up. Makes backing into parking spaces and parallel parking a breeze, along with the back-up camera. Also a fan of the push-to-talk for my cell phone.</FAVORITE>
</DOC>
<DOC>
<DATE>06/22/2009</DATE>
<AUTHOR>Pleased</AUTHOR>
<TEXT>I'm two years into a three year lease and I love this car. The only thing I would change would be the shape of the grill...THAT'S IT. Everything else is perfect. Great performance, plenty of power and AWD when skiing, plenty of room for baggage, great MPG for an SUV, navi system is far superior to GM's Suburban (don't have to put in park to change your destination, etc). Zero problems...just gas and oil changes. One beautiful car...except for the sho-gun shield looking grill.</TEXT>
<FAVORITE>Navi is easy, hands-free is great, AWD is perfect.</FAVORITE>
</DOC>
It seems like an XML file, but when I tried to
xml.url <- "2007_acura_mdx"
xmlfile <- xmlTreeParse(xml.url)
class(xmlfile)
xmltop <- xmlRoot(xmlfile)
topxml <- xmlSApply(xmltop, function(x) xmlSApply(x, xmlValue))
xml_df <- data.frame(t(topxml), row.names=NULL)
I had a problem when I executed data.frame. Can anyone help me? At this moment I would like to use grep()`` and gsub() but this is also not easy.
Try this:
txt <- "<DOCNO>2007_acura_mdx</DOCNO>
<DOC>
<DATE>07/31/2009</DATE>
<AUTHOR>FlewByU</AUTHOR>
<TEXT>I just moved to Germany two months ago and bought an 07 MDX from another military member. It has everything I could want. We just returned from a week driving through the Alps and this SUV is simply amazing. Granted, I get to drive it much faster than I could in the states, but even at 120 MPH, it was rock solid. We need the AWD for the snow and the kids stay entertained with the AV system. Plenty of passing power and very comfortable on long trips. Acuras are rare in Germany and I get stares all the time by curious Bavarians wondering what kind of vehicle I have. If you are in the market for a luxury SUV for family touring, with cool tech toys to play with, MDX can't be beat. </TEXT>
<FAVORITE>The separate controls for the rear passengers are awesome. I can control temp and AV from the front or switch to rear. Sound system is amazing. I will sometimes sit in the driveway and just listen. Also has a 120v outlet in console. Great for us since we live with 220v and need 120 on occasion. </FAVORITE>
</DOC>
<DOC>
<DATE>07/30/2009</DATE>
<AUTHOR>cvillemdx</AUTHOR>
<TEXT>After months of careful research and test drives at BMW, Lexus, Volvo, etc. I settled on the MDX without a doubt in mind. I love the way the car handles, no stiffness or resistance in the steering or acceleration. The interior design is a little Star Trek for me, but once I figured everything out, it is a pleasure to have all the extras (XM radio, navigation, Bluetooth, backup camera, etc.)</TEXT>
<FAVORITE>The self-adjusting side mirrors which rotate to give you a view of the curb/lines as you back up. Makes backing into parking spaces and parallel parking a breeze, along with the back-up camera. Also a fan of the push-to-talk for my cell phone.</FAVORITE>
</DOC>
<DOC>
<DATE>06/22/2009</DATE>
<AUTHOR>Pleased</AUTHOR>
<TEXT>I'm two years into a three year lease and I love this car. The only thing I would change would be the shape of the grill...THAT'S IT. Everything else is perfect. Great performance, plenty of power and AWD when skiing, plenty of room for baggage, great MPG for an SUV, navi system is far superior to GM's Suburban (don't have to put in park to change your destination, etc). Zero problems...just gas and oil changes. One beautiful car...except for the sho-gun shield looking grill.</TEXT>
<FAVORITE>Navi is easy, hands-free is great, AWD is perfect.</FAVORITE>
</DOC>"
library(XML)
txt2 <- paste("<root>", txt, "</root>")
doc <- xmlTreeParse(txt2, asText = TRUE, useInternalNodes = TRUE)
L <- xpathApply(doc, "//DOC", xmlApply, FUN = xmlValue)
dd <- do.call(rbind, lapply(L, as.data.frame, stringsAsFactors = FALSE))
giving:
> str(dd)
'data.frame': 3 obs. of 4 variables:
$ DATE : chr "07/31/2009" "07/30/2009" "06/22/2009"
$ AUTHOR : chr "FlewByU" "cvillemdx" "Pleased"
$ TEXT : chr "I just moved to Germany two months ago and bought an 07 MDX from another military member. It has everything I could want. We ju"| __truncated__ "After months of careful research and test drives at BMW, Lexus, Volvo, etc. I settled on the MDX without a doubt in mind. I lov"| __truncated__ "I'm two years into a three year lease and I love this car. The only thing I would change would be the shape of the grill...THAT"| __truncated__
$ FAVORITE: chr "The separate controls for the rear passengers are awesome. I can control temp and AV from the front or switch to rear. Sound sy"| __truncated__ "The self-adjusting side mirrors which rotate to give you a view of the curb/lines as you back up. Makes backing into parking sp"| __truncated__ "Navi is easy, hands-free is great, AWD is perfect."