I'm wondering if and how this can be done using Dart. Basically we have a list of ingredients and want to give the user the ability to increment (or decrement) the serving size. When this happens, we need to change the numbers in brackets []. We also need to gracefully handle formatted fractions.
Here's an example of the text:
Bean Bowl Base
[2], 15 oz cans of black beans, rinsed and drained
[1 1/2] cups frozen fire roasted corn, thawed
[1] red bell pepper, diced
[1/4] cup diced red onion, about half a small onion
[1] cup cherry tomatoes, halved
[1/4] cup fresh cilantro, minced
Tortillas or Tortilla chips for serving
Lime Dressing
Juice and zest of [2] limes
[2] tbsp extra virgin olive oil
[2] tbsp apple cider vinegar or white wine vinegar
[1] tbsp maple syrup or agave, adjust amount based on preference
[2] cloves garlic, crushed
[1/2] tsp ground cumin
[1–2] tsp smoked paprika, chipotle powder or chili powder
[1/4] tsp salt or more to taste
My thoughts are to:
Split the text at every \n
Map each line, looking for at most one [] to update
I'm not sure how to accomplish the (2).
Related
I'm trying to mimic grep
One thing I don't understand is: when should I print a line separator --?
For example, running the command:
cat test.txt | grep -b -v -A 1 -i on (I'll paste text.txt at the bottom)
I get the following output:
87:aaa
91:
92:from the start Her daughters were identical twins but the resemblance was purely physical
185-Madeline had been difficult baby from day one She was one who cried nonstop who
269:refused to nurse When Paige would finally get her settled and carefully place her down
358:she rarely got as far as the nursery door before Madelines blood curdling cries began
444-again often waking Erica as well Paige would want to sob on the floor she was so
529:absolutely depleted
550:Madeline was an infant who made Paige understand why Shaken Baby Syndrome was thing
It makes perfect sense in terms of matching lines and trailing context (because -A)
but I thought a line separator should be printed between continous blocks of printed lines:
For example, for the same input, my program prints:
87:aaa
91:
92:from the start Her daughters were identical twins but the resemblance was purely physical
185-Madeline had been difficult baby from day one She was one who cried nonstop who
--
269:refused to nurse When Paige would finally get her settled and carefully place her down
358:she rarely got as far as the nursery door before Madelines blood curdling cries began
444-again often waking Erica as well Paige would want to sob on the floor she was so
--
529:absolutely depleted
550:Madeline was an infant who made Paige understand why Shaken Baby Syndrome was thing
My reasoning - on the output itself:
87:aaa -- no match, so print (because -v)
91: -- no match so print (because -v)
92:from the start Her daughters were identical twins but the resemblance was purely physical -- no match, so print (because -v)
185-Madeline had been difficult baby from day one She was one who cried nonstop who -- match, print because -A 1 and -v -> extra line - last extra line , so must print a line seperator if found a new match
-- -> print a line separator - found a new line that has no match (because -v )
269:refused to nurse When Paige would finally get her settled and carefully place her do
..
.
.
The text.txt:
Their mother Paige would have told you there was something wrong with Madeline right
aaa
from the start Her daughters were identical twins but the resemblance was purely physical
Madeline had been difficult baby from day one She was one who cried nonstop who
refused to nurse When Paige would finally get her settled and carefully place her down
she rarely got as far as the nursery door before Madelines blood curdling cries began
again often waking Erica as well Paige would want to sob on the floor she was so
absolutely depleted
Madeline was an infant who made Paige understand why Shaken Baby Syndrome was thing
So my question is: when exactly does grep prints a line separator ?
Note: I'm not answering about -v and context matching, since I don't think they are well defined or even supposed to work. For example, this output doesn't make sense:
$ seq 5 | grep -v -A1 '3'
1
2
3
4
5
The separator -- won't be added if two or more groups of matching lines have overlapping lines or are next to each other in input file. Consider this sample input:
$ cat context.txt
wheat
roti
bread
blue
toy
flower
sand stone
light blue
flower
sky
water
dark red
ruby
blood
evening sky
Case 1: groups are next to each other
$ grep -C1 'flower' context.txt
toy
flower
sand stone
light blue
flower
sky
Case 2: overlapping groups
$ grep -A4 'flower' context.txt
flower
sand stone
light blue
flower
sky
water
dark red
ruby
I am attempting to form a product string normalization algorithm and am curious if this can be modeled using a neural network.
For example, I have the following input and target output data from eBay:
Input String 1: Brand New, Air Jordan 11 Retro XL Space Jam Size 10-US, Free Ship!
Target Output String 1: Space Jam Nike Air Jordan
Input String 2: Air Jordan 11 Retro XI 2016 Nike Space Jam 45 Men AJ11 DS Monstars 378037-003
Target Output String 2: Space Jam Nike Air Jordan
Input String 3: 2016 Nike Air Jordan Retro XI Space Jam US 8.5 - 9.5 IN HAND 11 378037 003 OG
Target Output String 3: Space Jam Nike Air Jordan
Input String 4: Air Jordans Nike 11 Retro XI 2016 45 Men AJ11 DS Monstars 378037-003
Target Output String 4: Space Jam Nike Air Jordan
If I feed the algorithm a new string, I'd like it to output something similar to below:
Input String: 2016 Air Jordan Retro 11 XI "Space Jam" MEN'S & GS Size 4Y-15 Nike
Target Output String: Space Jam Nike Air Jordan
I have used a CRF algorithm to do this somewhat successfully, but that requires preparing/bucketing the input strings/tokens into specific POS or attribute categories, which isn't really necessary here.
Instead, what I'd like to do is feed the input and output strings/tokens into a neural net, and have it give me a predicted output string based on the tokens that are present in a new string.
What I've tried so far is creating a sparse matrix with all of the input tokens and creating a model with the entire result string as an output, but this doesn't have great results.
Is there a better way to go about this? Thanks.
Does WordNet have "higher order" concepts? How to generate them for a given word?
I have a corpus of data in the form of prolog 'facts'. I want to generalize the conceptual components, i.e. 'contains'('oranges', 'vitamin c'). and 'contains'('spinach','iron'). would be generalized to 'contains'(<food>, <nutrient>).
I don't know WordNet very well, so one thing I was thinking about was just to generate all possible hypernyms and then combinatorially elaborate every possible new rule, but this is sort of a 'brute force' approach.
Does WordNet store higher order concepts such as <food> for instance? That might make it easier, because then I can just create one new rule with the higher order concept of that particular variable, assuming that there is one in WordNet, as opposed to perhaps fifty or one hundred if I do it the brute force way.
So what I actually want to know is: is there a command to generate the higher order concepts for each of the three components within a given 'fact'? Or maybe just for the two that are inside the parentheses. If such a command exits, what is it?
Below is some of the data I'm working with for reference.
'be'('mr jiang', 'representing china').
'be'('hrh', 'britain').
'be more than'('# distinguished guests', 'the principal representatives').
'end with'('the playing of the british national anthem', 'hong kong').
'follow at'('the stroke of midnight', 'this').
'take part in'('the ceremony', 'both countries').
'start at about'('# pm', 'the ceremony').
'end about'('# am', 'the ceremony').
'lower'('the british hong kong flag', '# royal hong kong police officers').
'raise'('the sar flag', 'another #').
'leave for'('the royal yacht britannia', 'the #').
'hold by'('the chinese and british governments', 'the handover of hong kong').
'rise over'('this land', 'the regional flag of the hong kong special administrative region of the people \'s republic of china').
'cast eye on'('hong kong', 'the world').
'hold on'('schedule', 'the # governments').
'be festival for'('the chinese nation', 'this').
'go in'('the annals of history', 'july # , #').
'become master of'('this chinese land', 'the hong kong compatriots').
'enter era of'('development', 'hong kong').
'remember'('mr deng xiaoping', 'history').
'be along'('the course', 'it').
'resolve'('the hong kong question', 'we').
'wish to express thanks to'('all the personages', 'i').
'contribute to'('the settlement of the hong kong', 'both china and britain').
'support'('hong kong \'s return', 'the world').
Wordnet refers to higher-order concepts as "hypernyms". A hypernym for the color "green," for instance, is "chromatic color", because the color green belongs to the higher-order class of chromatic colors.
One should note that Wordnet differentiates between "words" (strings of characters) and "sysnets" (the meaning we associate with a given string of characters). Just as one word can have multiple meanings, one string can have multiple synsets. If you want to retrieve all of the higher-order meanings for a given word, you can run these lines in Python:
from nltk import wordnet as wn
# If you are using nltk version 3.0.1, the following will tell you all the synsets for "green" and will thenn find all of their hypernyms. If you're running nltk 3.0.0, you can change the first line to `for synset in wn.synsets('bank'):
for synset in wn.wordnet.synsets('green'):
for hypernym in synset.hypernyms():
print synset, hypernym
I would like to type some math equation within texts. However, because the equation is too long, it extends into the margin on the right side of the page. Please see the image below:
My Latex code is:
The minimal cost is 1358.3333 calories, which is achieved by the
vector $[x_1, x_2, x_3, x_4, x_5, x_6]=[4.1667, 0.0000, 0.0000,
0.0000, 8.3333, 29.1667]$, where the total fat is $4.17\%$,
saturated fat and cholesterol both $0$, sodium $37.5\%$, total
carbohydrate, calcium and iron all $100\%$ meaning their constraints
active, dietary fiber $341.67\%$, vitamin A $5154.17\%$, vitamin C
$1600\%$.
Anyone has some idea about how to make the extending part of the equation to start at the next line?
Thanks and regards!
latex isn't clever enough to find suitable places in equations to break lines, and so does not attempt this. you need to break the line manually, or split it yourself. one obvious possibility is
$[x_1, x_2, x_3, x_4, x_5, x_6]$
$=[4.1667, 0.0000, 0.0000, 0.0000, 8.3333, 29.1667]$
(line break inserted for clarity, not needed)
it might look better to give the equation it's own line, ie wrap in \begin{equation}
I'm trying to write a paper based on VLDB .cls and .tex files, it can be reached from here.It uses ACM SIG Proceedings Style.After fixing many errors, now i don't get any errors, However when i save my file as pdf or ps,i can not see the author names.
The title and abstract are shown just not the code between these is not shown.
i'm using lyx on Ubuntu.
Here is the code for the authors.
% ****************** TITLE ****************************************
\title{A Sample {\ttlit VLDB} Proceedings Paper in LaTeX
Format\titlenote{for use with vldb.cls}}
\subtitle{[Extended Abstract]
\titlenote{A full version of this paper is available as\textit{Author's Guide to Preparing ACM SIG Proceedings Using \LaTeX$2_\epsilon$\ and BibTeX} at \texttt{www.acm.org/eaddress.htm}}}
% ****************** AUTHORS **************************************
% You need the command \numberofauthors to handle the 'placement
% and alignment' of the authors beneath the title.
%
% For aesthetic reasons, we recommend 'three authors at a time'
% i.e. three 'name/affiliation blocks' be placed beneath the title.
%
% NOTE: You are NOT restricted in how many 'rows' of
% "name/affiliations" may appear. We just ask that you restrict
% the number of 'columns' to three.
%
% Because of the available 'opening page real-estate'
% we ask you to refrain from putting more than six authors
% (two rows with three columns) beneath the article title.
% More than six makes the first-page appear very cluttered indeed.
%
% Use the \alignauthor commands to handle the names
% and affiliations for an 'aesthetic maximum' of six authors.
% Add names, affiliations, addresses for
% the seventh etc. author(s) as the argument for the
% \additionalauthors command.
% These 'additional authors' will be output/set for you
% without further effort on your part as the last section in
% the body of your article BEFORE References or any Appendices.
\numberofauthors{8} % in this sample file, there are a *total*
% of EIGHT authors. SIX appear on the 'first-page' (for formatting
% reasons) and the remaining two appear in the \additionalauthors section.
\author{
% You can go ahead and credit any number of authors here,
% e.g. one 'row of three' or two rows (consisting of one row of three
% and a second row of one, two or three).
%
% The command \alignauthor (no curly braces needed) should
% precede each author name, affiliation/snail-mail address and
% e-mail address. Additionally, tag each line of
% affiliation/address with \affaddr, and tag the
% e-mail address with \email.
%
% 1st. author
\alignauthor
Ben Trovato\titlenote{Dr.~Trovato insisted his name be first.}\\
\affaddr{Institute for Clarity in Documentation}\\
\affaddr{1932 Wallamaloo Lane}\\
\affaddr{Wallamaloo, New Zealand}\\
\email{trovato#corporation.com}
% 2nd. author
\alignauthor
G.K.M. Tobin\titlenote{The secretary disavows
any knowledge of this author's actions.}\\
\affaddr{Institute for Clarity in Documentation}\\
\affaddr{P.O. Box 1212}\\
\affaddr{Dublin, Ohio 43017-6221}\\
\email{webmaster#marysville-ohio.com}
% 3rd. author
\alignauthor Lars Th{\Large{\sf{\o}}}rv{$\ddot{\mbox{a}}$}ld\titlenote{This author is the
one who did all the really hard work.}\\
\affaddr{The Th{\large{\sf{\o}}}rv{$\ddot{\mbox{a}}$}ld Group}\\
\affaddr{1 Th{\large{\sf{\o}}}rv{$\ddot{\mbox{a}}$}ld Circle}\\
\affaddr{Hekla, Iceland}\\
\email{larst#affiliation.org}
\and % use '\and' if you need 'another row' of author names
% 4th. author
\alignauthor Lawrence P. Leipuner\\
\affaddr{Brookhaven Laboratories}\\
\affaddr{Brookhaven National Lab}\\
\affaddr{P.O. Box 5000}\\
\email{lleipuner#researchlabs.org}
% 5th. author
\alignauthor Sean Fogarty\\
\affaddr{NASA Ames Research Center}\\
\affaddr{Moffett Field}\\
\affaddr{California 94035}\\
\email{fogartys#amesres.org}
% 6th. author
\alignauthor Charles Palmer\\
\affaddr{Palmer Research Laboratories}\\
\affaddr{8600 Datapoint Drive}\\
\affaddr{San Antonio, Texas 78229}\\
\email{cpalmer#prl.com}
}
% There's nothing stopping you putting the seventh, eighth, etc.
% author on the opening page (as the 'third row') but we ask,
% for aesthetic reasons that you place these 'additional authors'
% in the \additional authors block, viz.
\additionalauthors{Additional authors: John Smith (The Th{\o}rv\"{a}ld Group,
email: {\texttt{jsmith#affiliation.org}}) and Julius P.~Kumquat
(The Kumquat Consortium, email: {\texttt{jpkumquat#consortium.net}}).}
\date{30 July 1999}
% Just remember to make sure that the TOTAL number of authors
% is the number that will appear on the first page PLUS the
% number that will appear in the \additionalauthors section.
\maketitle
i also tried another author format and still author names not shown.
% ****************** TITLE ****************************************
\title{Alternate {\ttlit ACM} SIG Proceedings Paper in LaTeX
Format\titlenote{(Produces...}}
\numberofauthors{3}
% Three authors sharing the same affiliation.
\author{
\alignauthor Ben King\\
\email{king#cs.berkeley.edu}
%
\alignauthor Georgia Tobin\\
\email{tobin#cs.berkeley.edu}
%
\alignauthor Gerald Murray\\
\email{murrray#cs.berkeley.edu}
%
\sharedaffiliation
\affaddr{Department of Electrical Engineering and Computer Science } \\
\affaddr{University of California, Berkeley } \\
\affaddr{Berkeley, CA 94720-1776 }
}
%
\maketitle
also when i checked the title i see that:
Error in latexParagraphs: You should not mix title layouts with normal ones.
however i see my the document as dvi,ps or pdf
i'm not sure what causes the problem?
EDIT
WHILE converting from .lyx to pdf or dvi i still don't see the authors however, by using shell commands everthing is fine.
i think this is a problem of lyx,
i spend 8 hours to solve it, seriously i set up windows 7 lyx and tried there, still same.
thanks lyx:) You are good when you are working properly.
The vldb.cls class from the link you mention does not define a command called \sharedaffiliation. Commenting out that code allows the file to compile and also see the author names:
\documentclass{vldb}
\title{Alternate {\ttlit ACM} SIG Proceedings Paper in LaTeX
Format\titlenote{(Produces...}}
\numberofauthors{3}
\author{
\alignauthor Ben King\\
\email{king#cs.berkeley.edu}
\alignauthor Georgia Tobin\\
\email{tobin#cs.berkeley.edu}
\alignauthor Gerald Murray\\
\email{murrray#cs.berkeley.edu}
% \sharedaffiliation
\affaddr{Department of Electrical Engineering and Computer Science } \\
\affaddr{University of California, Berkeley } \\
\affaddr{Berkeley, CA 94720-1776 }
}
\begin{document}
\maketitle
\end{document}
The address is ugly this way, though. It is up to the journal to define how to display author addresses with a single affiliation. Unfortunately, the sample file does not do this. In that situation I would contact the editor and ask.