1 Replies - 247 Views - Last Post: 01 November 2017 - 06:24 AM Rate Topic: -----

#1 moose9200  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-November 17

Menu Tagging

Posted 01 November 2017 - 12:51 AM

i want to tag categories to its menuname.
i have a csv containing menu item name and in other csv i have a column containing some strings,
i want to pick that strings from categories and look into menu items if any menu item containing that string i want to create a new column next to menu item name flagged as 1 otherwise 0
and the only condition is once a menu item flagged as 1 i don't need to consider that menu item again to tag further in case of redundant strings in categories only i want to search which are flagged as 0.
please help me with the script R or Python any.
i'm attaching you my R script which is matching whole string instead of substring and giving 0 for all menu item

for(i in 1:nrow(menu)){
if(cat$`non-veg`[i] %in% menu$`Menu Name`[i]){
    menu$newcol[i] = "T"
  } else {menu$newcol[i] = "f"}

}








Menu Name
9\ bobbie"
9\ chz steak"
9\ tuna"
provolone
20\ bobbie"
bottled soda 20oz
cran-slam ww
american
small chips
medium drink
9\ meatball"
capriotti's water
20'' chicken cheese steak
9\ veg turkey"
medium chips
9\ capastrami"
12\ bobbie"
12'' chicken cheese steak
cookie
12\ chz steak"
9\ cole turkey"
kid grilled cheese white
12\ italian"
12\ meatball"
12\ capastrami"
turkey sand w
20\ slaw be jo"
swiss
12\ cole turkey"
large drink
9\ ham&chz"
9'' chicken cheese steak
9\ slaw be jo"
turkey sand ww
stuffing
12\ turkey"
9\ italian"
12\ slaw be jo"
9\ grld italian"
12\ veg burger w/chz"
extra american
black&bleu salad
9\ turkey"
20\ turkey"
20\ capastrami"
ham sand w
12\ mushroom"
12\ grld italia"
italian salad
tuna sand ww
9\ roast beef"
20\ chz steak"
20\ mushroom"
9\ veg chzstk"
ham
genoa
12\ veg turkey"
12\ veggie cole turkey"
9\ mushroom"
cap's creation
mushrooms
salad chicken
20\ cole turkey"
1 pack chicken
kr veg burger w/chz
12\ roast beef"
kid turkey n cheese white
20\ italian"
12\ ham&chz"
9\ employee sub"
roast beef kr
9\ veggie cole turkey"
12\ sausage"
tea
turkey sand kr
salad turkey
tuna sand kr
brownie
slice american cheese
1 oz pastrami
9\ cheese"
12\ italian up"
12\ capastrami up"
1 pack steak
delaware's finest small
the sampler sm
side ranch dressing
12\ veg turkey up"
20\ roast beef"
roast beef w
1oz turkey
12\ tuna"
20\ veg turkey"
12\ veg chzstk"
9\ sausage"
kid ham n cheese white
side italian dressing
salad provolone
20\ grld italia"
sample item 6
sample item 9
turkey
12\ slaw be jo up"
12\ meatball up"
1 oz roast beef
ham sand ww
delaware's finest large
side cole slaw large
large chips
20\ meatball"
12'' chick cheese stk up
12\ chz steak up"
12\ grld italia up"
cran-slam w
12\ bobbie up"
20\ cheese"
slice provolone
the sampler lg
meatball bar
slice ham
wise large chips
small side
sm soup
12\ tuna up"
12\ cole turkey up"
prosciutini
20\ veggie cole turkey"
soup
roast beef
20\ italian up"
20'' chick cheese stk up
20\ chz steak up"
20\ bobbie up"
20\ veg turkey up"
slice swiss
20\ capastrami up"
sample item 7
12\ ham&chz up"
salad swiss
12\ veggie cheese stk up"
california omelet
orange juice
exteme bac boy
dinner salad
chef salad
12\ turkey up"
the big cheese
combo it
fries cmb
sm pepsi
km cheese burger
#NAME?
#NAME?
kid grilled cheese wheat
kids ham cheese white box
calif. blt
bacon turkey melt
coffee
1-pc pancake
fries
tuna sand
biscuits & gravy
s-1/3 patty
x avocado
x chez
s-bacon
#NAME?
xtra egg
lg bev upcharge
sm ice tea
small soup
roast beef ww
salad tuna
med pepsi
20\ veg chzstk up"
day nm egg san
s-chkn brest
bell pepper
fruit
1 slice veggie turkey
s-toast
x sausage
1 pack sausage
chicken salad
lg pepsi
x dressing
large side
9\ firecracker turkey"
20\ sausage up"
20\ turkey up"
20\ veg chzstk"
lg ice tea
12\ roast beef up"
sample item 8
catering cap creation sal
the turkey lover sm
little italy sm
cookie tray
sd chk avo san
sm fry / 2 pc zucch
kid turkey n cheese wheat
junior chz burger
extra italian meat
chili chz fries
sm fry / 2 pc o ring
extra turkey






CATEGORIES

non-veg
chix
salmon
ch
chkn
brisket
brskt
bacon
bcn
chse
mahi
dog
shk
clam
parmesan
asiago
prosciutto
prosciutti
salami
Angus
hicken
chk
chick
wings
prk
pork
ham
bacon
ribs
fish
shrimp
tuna
beef
steak
stk
meatball

Is This A Good Question/Topic? 0
  • +

Replies To: Menu Tagging

#2 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6379
  • View blog
  • Posts: 25,770
  • Joined: 12-December 12

Re: Menu Tagging

Posted 01 November 2017 - 06:24 AM

I've never touched R (looks oogly) but always willing to dabble.

I think %in% is searching a vector, so something like "cat" %in% c("cat","dog"). So an alternative appears to be grepl:

if (grepl("cat", "catalog")) {
    print("yes")
} else {
    print("no")
}
# yes

I tested this on something called jdoodle.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1