epub 2-column page break and layout - css

I am creating a 2-column epub book for a specific device. My problem is that when I use css to specify the columns ( -webkit-column-count: 2; -webkit-column-rule: 0px;), the end result is:
on Page 1 it shows (Part 1 | Part 3), and
on Page 2 it shows (Part 2 | Part 4) of the poem.
I would prefer to do it in a more natural book flow, which should show
(Part 1 | Part 2) on page 1, and continue to
(Part 3 | Part 4) on page 2.
Is there a way to archive this?
Some additional notes:
I tried to limit the column height but all it does is to add a 3rd column, which is not what I want.
The content of the book is dynamically generated, and thus, I cannot specify the location of the break ahead of time.

What are you applying the column count to?
http://jsfiddle.net/carolrmckay/FECr9/4/
.columncount
{
-webkit-column-count: 2; -webkit-column-rule: 0px;
}
strong
{
font-weight:bold;
}
<ul>
<li class="columncount"><p><strong>Chapter</strong> 1 – Down the Rabbit Hole: Alice is feeling bored while sitting on the riverbank with her sister, when she notices a talking, clothed White Rabbit with a pocket watch run past. She follows it down a rabbit hole when suddenly she falls a long way to a curious hall with many locked doors of all sizes. She finds a small key to a door too small for her to fit through, but through it she sees an attractive garden. She then discovers a bottle on a table labelled "DRINK ME", the contents of which cause her to shrink too small to reach the key which she has left on the table. A cake with "EAT ME" on it causes her to grow to such a tremendous size her head hits the ceiling.</p>
<p><strong>Chapter</strong> 2 – The Pool of Tears: Alice is unhappy and cries as her tears flood the hallway. After shrinking down again due to a fan she had picked up, Alice swims through her own tears and meets a Mouse, who is swimming as well. She tries to make small talk with him in elementary French (thinking he may be a French mouse) but her opening gambit "Où est ma chatte?" (that is "Where is my cat?") offends the mouse.
</p>
<p><strong>Chapter</strong> 3 – The Caucus Race and a Long Tale: The sea of tears becomes crowded with other animals and birds that have been swept away by the rising waters. Alice and the other animals convene on the bank and the question among them is how to get dry again. The mouse gives them a very dry lecture on William the Conqueror. A Dodo decides that the best thing to dry them off would be a Caucus-Race, which consists of everyone running in a circle with no clear winner. Alice eventually frightens all the animals away, unwittingly, by talking about her (moderately ferocious) cat.
</p>
<p><strong>Chapter</strong> 4 – The Rabbit Sends a Little Bill: The White Rabbit appears again in search of the Duchess's gloves and fan. Mistaking her for his maidservant, Mary Ann, he orders Alice to go into the house and retrieve them, but once she gets inside she starts growing. The horrified Rabbit orders his gardener, Bill the Lizard, to climb on the roof and go down the chimney. Outside, Alice hears the voices of animals that have gathered to gawk at her giant arm. The crowd hurls pebbles at her, which turn into little cakes. Alice eats them, and they reduce her again in size.
</p>
<p><strong>Chapter</strong> 5 – Advice from a Caterpillar: Alice comes upon a mushroom and sitting on it is a blue Caterpillar smoking a hookah. The Caterpillar questions Alice and she admits to her current identity crisis, compounded by her inability to remember a poem. Before crawling away, the caterpillar tells Alice that one side of the mushroom will make her taller and the other side will make her shorter. She breaks off two pieces from the mushroom. One side makes her shrink smaller than ever, while another causes her neck to grow high into the trees, where a pigeon mistakes her for a serpent. With some effort, Alice brings herself back to her usual height. She stumbles upon a small estate and uses the mushroom to reach a more appropriate height.
The Cheshire Cat
</p>
<p><strong>Chapter</strong> 6 – Pig and Pepper: A Fish-Footman has an invitation for the Duchess of the house, which he delivers to a Frog-Footman. Alice observes this transaction and, after a perplexing conversation with the frog, lets herself into the house. The Duchess's Cook is throwing dishes and making a soup that has too much pepper, which causes Alice, the Duchess, and her baby (but not the cook or grinning Cheshire Cat) to sneeze violently. Alice is given the baby by the Duchess and to her surprise, the baby turns into a pig. The Cheshire Cat appears in a tree, directing her to the March Hare's house. He disappears but his grin remains behind to float on its own in the air prompting Alice to remark that she has often seen a cat without a grin but never a grin without a cat.
</p>
<p><strong>Chapter</strong> 7 – A Mad Tea-Party: Alice becomes a guest at a "mad" tea party along with the March Hare, the Hatter, and a very tired Dormouse who falls asleep frequently, only to be violently woken up moments later by the March Hare and the Hatter. The characters give Alice many riddles and stories, including the famous 'Why is a raven like a writing desk?'. The Hatter reveals that they have tea all day because Time has punished him by eternally standing still at 6 pm (tea time). Alice becomes insulted and tired of being bombarded with riddles and she leaves claiming that it was the stupidest tea party that she had ever been to.
Alice trying to play croquet with a Flamingo.
</p>
<p><strong>Chapter</strong> 8 – The Queen's Croquet Ground: Alice leaves the tea party and enters the garden where she comes upon three living playing cards painting the white roses on a rose tree red because the Queen of Hearts hates white roses. A procession of more cards, kings and queens and even the White Rabbit enters the garden. Alice then meets the King and Queen. The Queen, a figure difficult to please, introduces her trademark phrase "Off with his head!" which she utters at the slightest dissatisfaction with a subject. Alice is invited (or some might say ordered) to play a game of croquet with the Queen and the rest of her subjects but the game quickly descends into chaos. Live flamingos are used as mallets and hedgehogs as balls and Alice once again meets the Cheshire Cat. The Queen of Hearts then orders the Cat to be beheaded, only to have her executioner complain that this is impossible since the head is all that can be seen of him. Because the cat belongs to the Duchess, the Queen is prompted to release the Duchess from prison to resolve the matter.
</p>
<p><strong>Chapter</strong> 9 – The Mock Turtle's Story: The Duchess is brought to the croquet ground at Alice's request. She ruminates on finding morals in everything around her. The Queen of Hearts dismisses her on the threat of execution and she introduces Alice to the Gryphon, who takes her to the Mock Turtle. The Mock Turtle is very sad, even though he has no sorrow. He tries to tell his story about how he used to be a real turtle in school, which the Gryphon interrupts so they can play a game.
</p>
<p><strong>Chapter</strong> 10 – Lobster Quadrille: The Mock Turtle and the Gryphon dance to the Lobster Quadrille, while Alice recites (rather incorrectly) "'Tis the Voice of the Lobster". The Mock Turtle sings them "Beautiful Soup" during which the Gryphon drags Alice away for an impending trial.
</p>
<p><strong>Chapter</strong> 11 – Who Stole the Tarts?: Alice attends a trial whereby the Knave of Hearts is accused of stealing the Queen's tarts. The jury is composed of various animals, including Bill the Lizard, the White Rabbit is the court's trumpeter, and the judge is the King of Hearts. During the proceedings, Alice finds that she is steadily growing larger. The dormouse scolds Alice and tells her she has no right to grow at such a rapid pace and take up all the air. Alice scoffs and calls the dormouse's accusation ridiculous because everyone grows and she can't help it. Meanwhile, witnesses at the trial include the Hatter, who displeases and frustrates the King through his indirect answers to the questioning, and the Duchess's cook.
</p>
<p><strong>Chapter</strong> 12 – Alice's Evidence: Alice is then called up as a witness. She accidentally knocks over the jury box with the animals inside them and the King orders the animals be placed back into their seats before the trial continues. The King and Queen order Alice to be gone, citing Rule 42 ("All persons more than a mile high to leave the court"), but Alice disputes their judgement and refuses to leave. She argues with the King and Queen of Hearts over the ridiculous proceedings, eventually refusing to hold her tongue. The Queen shouts her familiar "Off with her head!" but Alice is unafraid, calling them out as just a pack of cards; just as they start to swarm over her. Alice's sister wakes her up for tea, brushing what turns out to be some leaves and not a shower of playing cards from Alice's face. Alice leaves her sister on the bank to imagine all the curious happenings for herself.</li>
</ul>​

Related

Filtering dataframe based on a string in R

I have a data frame similar to this
dput(sample_data)
structure(list(listing_id = c(12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L, 12899L,
12899L, 12899L, 12899L, 12899L), id = c(24767, 29230, 29806,
32572, 32862, 40792, 43566, 43920, 46120, 48434, 52902, 57458,
61672, 68414, 71418, 74541, 75259, 77605, 78600, 79300, 80982,
82555, 83752, 98488, 99753, 102145, 105460, 107350, 111060, 118238,
122914, 130226, 150419, 176176, 179317, 183355, 188840, 200734,
213728, 216268, 219476, 224141, 230224, 242707, 256155, 271224,
274658, 299623, 305993, 326731, 348879, 358361, 365440, 405902,
416997, 421410, 431327, 439108, 450967, 462680, 475923, 497264,
504158, 512703, 569301, 592555, 611971, 621267, 634440, 636623,
666385, 721778, 735454, 744152, 777928, 786787, 811911, 821548,
833250, 848303), date = c("24/01/2010", "13/03/2010", "16/03/2010",
"31/03/2010", "02/04/2010", "08/05/2010", "17/05/2010", "18/05/2010",
"24/05/2010", "31/05/2010", "14/06/2010", "26/06/2010", "06/07/2010",
"24/07/2010", "31/07/2010", "06/08/2010", "07/08/2010", "12/08/2010",
"15/08/2010", "16/08/2010", "18/08/2010", "22/08/2010", "24/08/2010",
"16/09/2010", "18/09/2010", "21/09/2010", "26/09/2010", "28/09/2010",
"04/10/2010", "13/10/2010", "19/10/2010", "31/10/2010", "07/12/2010",
"30/01/2011", "07/02/2011", "16/02/2011", "26/02/2011", "16/03/2011",
"31/03/2011", "03/04/2011", "06/04/2011", "12/04/2011", "18/04/2011",
"27/04/2011", "09/05/2011", "19/05/2011", "22/05/2011", "06/06/2011",
"09/06/2011", "21/06/2011", "02/07/2011", "07/07/2011", "11/07/2011",
"30/07/2011", "03/08/2011", "05/08/2011", "09/08/2011", "12/08/2011",
"16/08/2011", "21/08/2011", "26/08/2011", "03/09/2011", "05/09/2011",
"08/09/2011", "26/09/2011", "03/10/2011", "09/10/2011", "11/10/2011",
"16/10/2011", "17/10/2011", "26/10/2011", "15/11/2011", "21/11/2011",
"26/11/2011", "11/12/2011", "15/12/2011", "29/12/2011", "01/01/2012",
"03/01/2012", "07/01/2012"), reviewer_id = c(69327L, 72846L,
84196L, 89114L, 100318L, 106706L, 122590L, 124878L, 115296L,
128686L, 101332L, 133253L, 61601L, 170065L, 89041L, 174803L,
189922L, 53967L, 97181L, 165949L, 169685L, 166756L, 24799L, 1972408L,
214136L, 212710L, 216604L, 49785L, 205468L, 207387L, 232310L,
202219L, 290589L, 339123L, 128686L, 112038L, 385948L, 409204L,
406780L, 382114L, 153837L, 117790L, 430323L, 501446L, 102379L,
574784L, 476509L, 493172L, 656282L, 614047L, 755566L, 555937L,
193404L, 12386L, 650075L, 794170L, 348567L, 820789L, 888114L,
817107L, 546440L, 791723L, 989632L, 588916L, 1013150L, 888114L,
1128969L, 450362L, 166365L, 894104L, 1206085L, 1296041L, 1390344L,
1215456L, 1421703L, 970946L, 26035L, 1540509L, 1502615L, 1486972L
), reviewer_name = c("Stuart", "John", "Lois", "Troy", "Cathy",
"Johanna", "Madelyn", "Adam", "Craig", "Leah", "Christopher",
"John & Lyn", "Nick", "Hope & Sebastien", "Ariel", "Marilyn",
"Kathy", "Erik", "Angela", "Erica", "Susan", "Darrell", "Mavis",
"Jaclyn", "Jen", "Frederick", "Linda", "Barrett", "Lynda", "Sarah",
"Maneesh", "Constance", "Chris", "Toby", "Leah", "Vincent", "Ellen",
"Fran", "Mark", "Ryan", "James", "Sally", "Annette", "Lynne",
"Angela", "Katie And Tommy", "Leigh", "Liz", "David", "Diana",
"Iñaki", "Mary", "Wendy", "Adrian", "Joan", "Kristine", "Jovana",
"Beth", "Deevy", "Craig", "Jennifer", "Barbara", "Biff", "Kelly",
"Amanda", "Deevy", "Pieter & Dietsje", "Johnny", "Sherri", "Suzette",
"Nancy", "Duncan", "Rebecca", "Pam", "Kaitlin", "Paul & Iho & Alexandrea & Anabella",
"Norma", "Kim", "Ana", "Daron"), comments = c("recommended very good value spacious airy upper floor alison david welcoming helpful",
"our ten days visiting portland enormously enhanced alison david they contributed welcoming warmth wonderful economical accomodations if lucky enough get back portland maine imagine staying anywhere else br jack lorel",
"we wonderful time staying area alberta arts the beds comfy upstairs spacious with walk 5 blocks found great food including thai one try chicken satay ali david amazing home filled great atmosphere lots laughs definitely place revisit",
"i stayed ali david s place i first moved portland the space comfortable private lots room ali david knowledgeable portland neighborhoods get around anyone coming portland will enjoy stay here",
"clean comfortable quiet rooms easygoing generous hosts great walking neighborhood close parks seemingly unlimited restaurant choices wish able stay longer",
"beautiful neighborhood convenient airport interstate considerate hosts comfortable spacious private rooms i asked better highly recommend anyone traveling portland",
"this space ideal 3 adults my wife sister i spent weekend portland stayed here we found space clean hosts friendly neighborhood quiet we never part portland happened come local street fair ended finding good vegetarian fare just blocks away enjoyed walking street we will definitely consider space option visiting portland",
"beautiful house cute neighborhood the hosts gracious helpful without over bearing two bedrooms small kitchen space coffee maker small bathroom shower provided enough space highly recommended anyone looking something personal hotel room better price too",
"wonderful gracious welcoming hosts when i asked david child barrier stairs quickly came solution they provide place way home hotel gave us insight portland help us move i recommend place highly very clean quiet neighborhood thanks ali david",
"i recommend place enough the rooms bright pretty even gray day hosts just terrific knowledgeable friendly generous when i found i d forgotten running shoes ali lent me hers i m indebted life especially since i indulging wonderful food prepared many marvelous restaurants found mere blocks away should prefer something simpler new seasons within easy walking distance plus two massage studios two yoga studios just close who ask more",
"allison david stellar hosts combining available attentiveness needs quiet leisurely atmosphere home space comfortable spotless alli s garden inspiring perfect holiday",
"had great time dave ali they friendly helpful nothing much trouble the room private comfortable bathroom sole use plenty eating places nearby try hamburgers new seasons highly recommended",
"fantastic spot comfy clean quiet prime location even got nice bike ride in a ideal place spend days portland",
"unfortunately able chat much ali david busy seem lovely br br the suite wonderful place stay hubbub really tourist y areas there great restaurants nearby though walking around area cinch make sure look bus routes if car get here house obvious frequent route although knew busses best easy br br ali david good resource great place stay",
"we asked much hosts ali david welcoming room clean bed soooo comfy our time portland definitely enhanced staying here couldn t recommend more",
"this perfect space charming convenient neighborhood hosts helpful intrusive a great find",
"very clean quiet friendly hosts we enjoyed two night stay much recommend highly great places eat alberta area",
"great hosts classic quiet portland home the converted attic almost apartment great access northeast portland scene",
"ali dave warm gracious hosts we arrived late flight willing wait us the place lovely clean conveniently located we definitely recommend staying here",
"i wonderful introduction portland staying clean comfy spacious appartment ali dave s charming home i overnighted moved quickly i get spend much time ali dave however charming helpful throughout stay the room ideally located get airport short taxi ride the location great artsy laid back spot cool places eat coffee generally absorb atmosphere genuine portland neighborhood",
"my family great time portland kastners helpful giving suggestions restaurants places hike visit",
"david ali s husband made us feel welcome time met us door left unfortunately able stay one night comfortable place stay time everything clean comfortable just amenities needed br we highly recommend lovely apartment friends br br annette spratt br leavenworth ks",
"we couple third person home absolutely perfect us comfortable beds kitchen facilities microwave bar sink small fridge plates etc the hosts superb warm gracious friendly a 10 minute drive city center a definite return place us",
"much enjoyed ali dave wish time chat them eager provide valuable information things see including kennedy school enjoyed much little apartment upstairs perfect two friends travel together need separate rooms need frequently overlooked typical b bs friend seattle appreciated sharing little kitchenette separate bedrooms br br i m moving portland alabama hope touch ali dave settling in great hosts also interesting people recommend highly anyone traveling portland br br luba",
"huge space friendly owners just needed very nicely located close alberta street bars food portland hippies br br will definitely stay poor",
"clean place nice people good coffee", "what fabulous place stay it s beautiful house rental space great way beyond expectations you can walk new seasons coffee shops alberta killingsworth around lovely neighborhood nearby parks it s lovely sit front porch just happy portland br br david ali wonderful hosts they friendly informative welcoming my first night took time sit porch talk making feel especially welcome br br i imagine staying anywhere else portland next visit",
"david ali great hosts upstairs clean comfortable the neighborhood nice great restaurants within walking distance a great place stay",
"my daughters enjoyed stay much david ali wonderful hosts helpful the neighborhood nice ali david gave girls discount coupon one local sushi restaurants enjoyed much br we definitely recommend br br br",
"ali david wonderful hosts they warm generous spirits made us feel welcome br br the house located beautiful neighborhood front back gardens lush green it s gorgeous spacious house hardwood floors the upstairs stayed great its completely new clean everything need a big comfy bed nice view garden small kitchen ish area fridge sink microwave everything perfectly new clean good order br br eric i cat people although two new teenage cats stay downstairs plenty time play pet them really liked it real comfort us stay there home away home describes perfectly br br if plans visit portland place stay br br we hope stay next trip portland already recommended family coming visit future br br rating 10 plus stars",
"i pulled house ali david porch gave warm welcome it felt like staying friends rather strangers a really comfortable apartment within walking distance alberta arts district the apartment clean comfortable quiet i will definitely stay again",
"we great time visiting family portland staying ali david s home very clean quiet sleeping pleasant environment david ali friendly low key perfect hosts close alberta new seasons good stuff definitely recommend place anyone",
"great hosts great place great neighborhood ali david bent backwards make sure stay incredible the place cozy inviting everything just right the neighborhood lacks nothing i ll stay sure",
"ali dave s house gorgeous upstairs apartment awesome it super clean spacious well decorated stocked little kitchenette plates utensils clean towels shower they super friendly hosts cute cats even gave us fresh coffee grounds the area really great too reason may stay now planning buy place near",
"oh always really lovely time ali david s pretty festive home as usual fun exchanges books cats recipes thank you ali david",
"ali david great hosts we felt comfortable living situation will repeat next time chance the home great neighborhood within walking distance needs our regret getting know hosts better seem like great people",
"ali dave great hosts br br they kind thoughtful welcoming warm and oh helpful information go do br br because visit working retreat insider information helped make great use time br br i got choice rooms picked smaller one just right amount space one person cozy comfortable br and within walking distance alberta street i needed great shops restaurants fantastic",
"a perfect 10 i wonderful stay ali david from first ali responsive via email easy arrange stay when i arrived david greeted got settled the rooms wonderful david made sure i warm enough the rooms classic portland simple uncluttered big windows looking green trees ali supplied tea small fridge milk etc the big bed comfy perfect snuggling blankets rain drumming softly roof in evenings i enjoyed hanging them sitting fire playing kitties walking concordia alehouse fries drink",
"ali david great hosts friendly easy talk to gave us real welcome home portland feel the suite comfortable we enjoyed mini kitchen convenience stocked coffee too the spacious warm bedroom with extra blankets provided needed privacy much appreciated the neighborhood quiet beautiful close everything we strongly recommend staying portland ali david hope able return someday",
"david ali wonderful house just blocks eclectic lively alberta street northwest pdx the upstairs space available comfortable roomy perfect stays length br br both david ali offered great advice must dos pdx first timer generous offering extra bicycle weekend making initial two wheeled bridgetown experience authentic br br next time i m back i ll here",
"ali david wonderful hosts provided really great place stay very accommodating flexible house beautiful parking easy everything exceeded expectations hesitate stay again",
"ali david s suite spacious lovely clean private there small kitchen area coffee maker coffe tea provided ali david great hosts friendly helpful i able park car front house every night just short walk interesting alberta arts district",
"this first stay booked via airbnb fantastic david allie responsive first booking email i departed they available helpful i also felt i good bit privacy the space lovely coffee maker coffee microwave fridge the location also great near airport neighborhood lots going on available easy parking i enjoyed nearby new seasons market extracto coffee the wifi included fast i able watch shows hulu check e mail etc i slept well quite bed comfy lots blankets pillows provided",
"we much enjoyed stay the kastner s suite cold perfect the space really large multiple rooms plenty closet space the bed truly comfortable linens nicely done plenty hot water there small kitchenette area provided coffee they live beautiful quiet street able park right front house every night even though private entrance space still felt private in fact times coming going either ali david home since come front door chances visit added enjoyment staying there we hope stay whenever portland",
"jenny i attended acupuncture class portand delightful stay br with david alison their lovely home quick walk great restaurants br a grocery store yoga studio etc david alison excellent hosts br providing beautiful quiet place stay generously inviting us join br in neighborhood events they great suggestions enjoy area br including lending us 2 bicycles explore it we wonderful time br highly recommend staying them br",
"ali david accommodating space clean due flight cancellations travel disasters time ali david cut short one night kind enough offer us refund stayed late following evening welcome us home david even made list vegetarian restaurants open late i grab food finally got there the space clean warm hosts beyond kind welcoming our brief memories portland definitely shaped ali david s hospitality upon returning portland love stay will recommend friends future",
"ali dave great unfortunately i much loved spend time alberta arts district the neighborhood cute felt safe the bus one block away i loved eats coffee cup saucer cafe the space ample clean sleep several it nice cup tea getting ready day thank dave ali accommodation random hours",
"what delightful surprise lovely home lovely gardens welcoming hosts we two couples plenty room us",
"this first experience airbnb great start the home tastefully decorated quiet ali david gracious helpful the neighborhood beautiful great restaurants interesting art galleries walking distance",
"we wonderful four day stay all advertised meticulously clean wonderfully comfortable space ali david thoughtful relaxed helpful hosts plus great location lovely home cute kitties recommended without qualification",
"lovely house suite entire second floor clean spacious easy go downtown portland using public bus just 2 blocks away alberta arts district st something recommendable specially last thursday month ali david great hosts knowledgeable city",
"we wonderful experience beautiful house lovely people the rooms spotless comfortable welcome received david ali warm friendly br this area portland full nice cafes restaurants within walking distance within easy access city centre",
"dave waiting us front yard late nightly arrived perfect host moment on ali town much stay enjoyed meeting well the rooms nice coffee welcome space absolutely spotless we enjoyed immensely happy stay again thanks making wonderful experience",
"beautiful area helpful hosts they flexible time wise ex helped late checkout i ve never seen beautiful sidewalk 31st venue alberta br br the space nicely appointed refinished attic including shower plenty hot water sink fridge 2 rooms beds there air conditioning floor fan keeping windows open fine us watch low ceiling tall like me br br internet provided fast wife completely unable connect if depend 100 reliable quick internet bring plan wifi time around nearby cafe s opening hours br br for liesure traveler great spot 2 buses nearby couple inexpensive restaurants within 15 minute walk br br if use hidden airbnb maps note zipcode phone number hidden airbnb phone number hidden airbnb can really confuse things via bus can get downtown within phone number hidden airbnb minutes depending timeliness route make sure note odd bus fare 2 05 via cab 15 downtown 20 airport br br anyway i hope expanse tips prove useful you alberta arts great place consider looking relaxing leisure trip portland",
"the alberta arts suite just perfect i traveled 18 year old daughter 2 bedrooms worked great the suite just pictured clean modern everything need stay the house located beautiful neighborhood portland ali david wonderful hosts when come portland again will stay again",
"david ali superb hosts their home front gardens lovely upstairs suite guests just weary travelers needed the space gave us room spread relax perfect the alberta neighborhood fun us explore fun shopping resale shops great restaurants galleries within walking distance i hesitate recommend spot friends thanks great stay david ali",
"we wonderful time ali david s home the space beautiful extremely clean quiet hosts considerate accommodating ie made iron ironing board available us helped faulty internet connection laptop offered advice city transportation overall stay ali david again recommend travelers",
"we wonderful stay really wonderful people went beyond ensuring comfortable stay good location great experience",
"my friend i enjoyed ali david s place immensely it perfect needed great snapshot great pdx neighborhood i ll come back sure",
"the stay wonderful room clean nice my girlfriend i felt welcome i definitely stay again",
"we wonderful stay ali dave generous helpful from kind welcome directions recharging ipod whole experience made stay portland great",
"i want live accommodation well thought supplied great location intelligent gentle attentive hosts a real winner",
"if going portland couple nights longer fantastic place stay great neighborhood easy walk bike things might want ali david wonderful hosts",
"ali david great hosts their space cute clean they accommodating made sure everything needed they also good suggesting delicious neighborhood restaurants if ever portland area will definitely checking see space available",
"the alberta arts studio great place weekend visit the suite lots space clean uncluttered the neighbourhood fantastic lots great restaurants shops within 10min walk it 30min leisurely bike ride downtown lovely neighbourhoods we found david ali friendly helpful tips suggestions things do the studio lots portland magazines maps us read on it also great use bikes although kitties may suffer allergies they come suite day so friends definitely feeling itchy eyed br having stayed great place definitely added fantastic portland weekend getaway",
"once again great stay we love ali david s house neighborhood this second stay time three us their place just great three two thanks",
"we great time alberta arts a nive location portland great city the room clean spacious the hosts helpfull nice people general we will come back area sure",
"lovely place stay great hosts", "my husband adult daughter i enjoyed stay ali david they greeted us street evening made us feel welcome comfortable they quick help forgotten shampoo providing ironing board iron needed them we used rooms just like photos clean clutter free they live beautiful portland neighborhood fun restaurants shops i recommend contact need place two nights portland br",
"my daughter i enjoyed stay ali dave they nicer my flight arrived late friday dave waiting outside umbrella pulled 11 pm they great communicators along way the rooms comfortable quiet peaceful amenities internet microwave fridge sink advertised they informative gracious hosts providing right measure privacy help finding looking for my daughter mentioned enjoyed spoken word next morning found note date time venue poetry slam went enjoyed immensely web searching find otherwise known this i doubt hotel concierge taken time find us i highly recommend staying dave ali return get portland again",
"spacious quiet comfortable additional benefit small kitchenette very accessible public transportation close airport great choice anyone wants ne portland",
"alison david went beyond expectations hosts incredibly kind warm people they made us feel welcome home immediately questions concerns even just chat br br the private space upstairs house quiet cozy comfortable they attended amenities even finer details br br we amazing stay here slept like babies night stay anywhere else come back portland br br thanks ali david",
"this first experience airbnb will certainly back ali david wonderful hosts two bedrooms upstairs space husband 16 year old daughter i stayed comfortable quiet amenities possibly wanted everything went smoothly we also liked within walking distance restaurants cafes shops within easy driving distance downtown portland lewis clark college omsi",
"our stay comfortable quiet i agree others said cleaner nicer pictures might indicate seemed brand new spotless ali david accommodating hosts david met us helped carry bags upstairs br my warning might six two ceilings attic type husband connected ceiling one occasion i however loved it felt cozy roomy since heighth foot shorter his i definitely recommend it",
"very comfortable quiet the entire upstairs floor classic portland bungalow ali husband made feel right home super easy make reservation even though i contacted last minute place stay i live portland town visitor location perfect access portland s fun unique shopping dining areas",
"ali david wonderful hosts we needed quiet secluded place days exactly got we whole second floor private bathroom it also quiet clean the neighborhood wonderful everything needed within walking distance grocery store restaurants yoga we recommend place others",
"the accommodations clean quiet david ali helpful cheerful hosts we enjoyed visiting look forward return visit soon we love location well since close wonderful new season s market alberta street restaurants street parking easy all pleasant stay comfortable clean surroundings excellent hosts",
"we delightful stay ali david just new years their upstairs guest suite met needs perfectly clean comfortable quiet charming part portland we definitely recommend place anyone",
"ali david friendly hosts made sure needed we good stay them room again",
"ali s place perfect just advertised i plenty privacy lots space i definitely stay again"
)), row.names = c(NA, 80L), class = "data.frame")
I have done the preprocessing part and I want ti filter the data frame on two parts containing some strings "pets," "pet," "cat," "cats," "dog," and "dogs"
I have tried the following
Filter_pets<-sample_data %>%
filter(grepl("dog|cat|pet|pets|dogs|cats ",comments))
and
Filter_no_pets<-USA_data %>%
filter(!grepl("pet|^cat|dog|pets|dogs|cats",comments))
It is not prodicing the desired results. For example, if some word is there called "Cater" it still filters it to assign it to the first data frame. Also it is not capturing everu term inclduing "pets"
Can anyone help?
Your regex alternation should be surrounded by word boundaries on both sides:
Filter_pets <- sample_data %>%
filter(grepl("\\b(?:dogs?|cats?|pets?)\\b", comments))
This will match cat as a standalone word but not cater.

R: tm package stemCompletion Error (with data)

I have 2 speech data in 2 separate text files. I have attached the speech data at the bottom of this question, since most questions on tm do not provide data and make it difficult for others to answer their questions. And I created a corpus based on these 2 text files.
Then I applied transformation to these speech data. All work perfectly except for the stemCompletion step.
corpus.tmp <- tm_map(corpus, removePunctuation)
# remove whitespace
corpus.tmp <- tm_map(corpus.tmp, stripWhitespace)
# convert to lower case letters
#
#corpus.tmp <- tm_map(corpus.tmp, tolower)
corpus.tmp <- tm_map(corpus.tmp, content_transformer(tolower))
# remove stopwords
corpus.tmp <- tm_map(corpus.tmp, removeWords, c(stopwords("english"), "tweet", "views", "mitt", "romney", "obama", "barack"))
# stemming
corpus.tmp <- tm_map(corpus.tmp, stemDocument, language = "english")
corpus.tmp <- tm_map(corpus.tmp, stemCompletion, dictionary = corpus.tmp)
I ran into the following error, but that's not it. When I inspect the corpus, the content all became error messages. Can someone tell me what went wrong? How to fix it?
Warning message:
In mclapply(content(x), FUN, ...) :
all scheduled cores encountered errors in user code
Browse[1]> inspect(corpus.tmp)
<<VCorpus (documents: 2, metadata (corpus/indexed): 0/0)>>
inspect(corpus.tmp)
[[1]]
[1] "Error in setNames(if (length(n)) n else rep(NA, length(x)), x) : \n 'names' attribute [60] must be the same length as the vector [2]\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in setNames(if (length(n)) n else rep(NA, length(x)), x): 'names' attribute [60] must be the same length as the vector [2]>
[[2]]
[1] "Error in setNames(if (length(n)) n else rep(NA, length(x)), x) : \n 'names' attribute [61] must be the same length as the vector [2]\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in setNames(if (length(n)) n else rep(NA, length(x)), x): 'names' attribute [61] must be the same length as the vector [2]>
The 2 separate text files are as follow:
[[1]]
<<PlainTextDocument (metadata: 7)>>
07/29/12 – Mitt Romney’s Policy Speech in Jerusalem
Tweet
Thank you for that kind introduction, Mayor Barkat, and thank you all for that warm welcome. It’s a pleasure and a privilege to be in Israel again.
To step foot into Israel is to step foot into a nation that began with an ancient promise made in this land. The Jewish people persisted through one of the most monstrous crimes in human history, and now this nation has come to take its place among the most impressive democracies on earth. Israel’s achievements are a wonder of the modern world.
These achievements are a tribute to the resilience of the Israeli people. You have managed, against all odds, time and again throughout your history, to persevere, to rise up, and to emerge stronger.
The historian Paul Johnson, writing on the 50th anniversary of the creation of the Jewish state, said that over the course of Israel’s life, 100 completely new independent states had come into existence. “Israel is the only one whose creation can fairly be called a miracle,” Johnson wrote.
It is a deeply moving experience to be in Jerusalem, the capital of Israel.
Our two nations are separated by more than 5,000 miles. But for an American abroad, you can’t get much closer to the ideals and convictions of my own country than you do in Israel. We’re part of the great fellowship of democracies. We speak the same language of freedom and justice, and the right of every person to live in peace. We serve the same cause and provoke the same hatreds in the same enemies of civilization.
It is my firm conviction that the security of Israel is in the vital national security interest of the United States. And ours is an alliance based not only on shared interests but also on enduring shared values.
In those shared values, one of the strongest voices is that of your prime minister, my friend Benjamin Netanyahu. I met with him earlier this morning and I look forward to my family joining his this evening as they observe the close of this fast day of Tisha B’Av.
It’s remarkable to consider how much adversity, over so great a span of time, is recalled by just one day on the calendar. This is a day of remembrance and mourning, but like other such occasions, it also calls forth clarity and resolve.
At this time, we also remember the 11 Israeli athletes and coaches who were massacred at the Munich Olympics forty years ago. Ten years ago this week, 9 Israeli and American students were murdered in the terrorist attack at Hebrew University. And tragedies like these are not reserved to the past. They are a constant reminder of the reality of hate, and the will with which it is executed upon the innocent.
It was Menachem Begin who said this about the Ninth of the month of Av: “We remember that day,” he said, “and now have the responsibility to make sure that never again will our independence be destroyed and never again will the Jew become homeless or defenseless.” “This,” Prime Minister Begin added, “is the crux of the problems facing us in the future.”
So it is today, as Israel faces enemies who deny past crimes against the Jewish people and seek to commit new ones.
When Iran’s leaders deny the Holocaust or speak of wiping this nation off the map, only the naïve – or worse – will dismiss it as an excess of rhetoric. Make no mistake: the ayatollahs in Tehran are testing our moral defenses. They want to know who will object, and who will look the other way.
My message to the people of Israel and the leaders of Iran is one and the same: I will not look away; and neither will my country. As Prime Minister Begin put it, in vivid and haunting words, “if an enemy of [the Jewish] people says he seeks to destroy us, believe him.”
We have seen the horrors of history. We will not stand by. We will not watch them play out again.
It would be foolish not to take Iran’s leaders at their word. They are, after all, the product of a radical theocracy.
Over the years Iran has amassed a bloody and brutal record. It has seized embassies, targeted diplomats, and killed its own people. It supports the ruthless Assad regime in Syria. They have provided weapons that have killed American soldiers in Afghanistan and Iraq. It has plotted to assassinate diplomats on American soil. It is Iran that is the leading state sponsor of terrorism and the most destabilizing nation in the world.
We have a solemn duty and a moral imperative to deny Iran’s leaders the means to follow through on their malevolent intentions.
We should stand with all who would join our effort to prevent a nuclear-armed Iran – and that includes Iranian dissidents. Do not erase from your memory the scenes from three years ago, when that regime brought death to its own people as they rose up. The threat we face does not come from the Iranian people, but from the regime that oppresses them.
Five years ago, at the Herzliya Conference, I stated my view that Iran’s pursuit of nuclear weapons capability presents an intolerable threat to Israel, to America, and to the world.
That threat has only become worse.
Now as then, the regime’s claims that it seeks to enrich nuclear material for peaceful purposes are belied by years of malign deceptions.
Now as then, the conduct of Iran’s leaders gives us no reason to trust them with nuclear material.
But today, the regime in Iran is five years closer to developing nuclear weapons capability. Preventing that outcome must be our highest national security priority.
I want to pause on this last point. It is sometimes said that those who are the most committed to stopping the Iranian regime from securing nuclear weapons are reckless and provocative and inviting war.
The opposite is true. We are the true peacemakers. History teaches with force and clarity that when the world’s most despotic regimes secure the world’s most destructive weapons, peace often gives way to oppression, to violence, or to devastating war.
We must not delude ourselves into thinking that containment is an option. We must lead the effort to prevent Iran from building and possessing nuclear weapons capability. We should employ any and all measures to dissuade the Iranian regime from its nuclear course, and it is our fervent hope that diplomatic and economic measures will do so. In the final analysis, of course, no option should be excluded. We recognize Israel’s right to defend itself, and that it is right for America to stand with you.
These are some of the principles I first outlined five years ago. What was timely then has become urgent today.
Let me turn from Iran to other nations in the Middle East, where we have seen rising tumult and chaos. To the north, Syria is on the brink of a civil war. The dictator in Damascus, no friend to Israel and no friend to America, slaughters his own people as he desperately clings to power.
Your other neighbor to the north, Lebanon, is under the growing and dangerous influence of Hezbollah.
After a year of upheaval and unrest, Egypt now has an Islamist President, chosen in a democratic election. Hopefully, this new government understands that one true measure of democracy is how those elected by the majority respect the rights of those in the minority. The international community must use its considerable influence to ensure that the new government honors the peace agreement with Israel that was signed by the government of Anwar Sadat.
As you know only too well, since Hamas took control of the Gaza Strip in 2007, thousands of rockets have rained on Israeli homes and cities. I have walked on the streets of Sderot, and honor the resolve of its people. And now, new attacks have been launched from the Sinai Peninsula.
With Hezbollah rockets aimed at Israel from the north, and Hamas rockets aimed from the south, with much of the Middle East in tumult, and with Iran bent on nuclear arms, America’s vocal and demonstrated commitment to the defense of Israel is even more critical. Whenever the security of Israel is most in doubt, America’s commitment to Israel must be most secure.
When the decision was before him in 1948, President Harry Truman decided without hesitation that the United States would be the first country to recognize the State of Israel. From that moment to this, we have been the most natural of allies, but our alliance runs deeper than the designs of strategy or the weighing of interests.
The story of how America – a nation still so new to the world by the standards of this ancient region – rose up to become the dear friend of the people of Israel is among the finest and most hopeful in our nation’s history.
Different as our paths have been, we see the same qualities in one another. Israel and America are in many respects reflections of one another.
We both believe in democracy, in the right of every people to select their leaders and choose their nation’s course.
We both believe in the rule of law, knowing that in its absence, willful men may incline to oppress the weak.
We both believe that our rights are universal, granted not by government but by our Creator.
We both believe in free enterprise, because it is the only economic system that has lifted people from poverty, created a large and enduring middle class, and inaugurated incomparable achievements and human flourishing.
As someone who has spent most of his life in business, I am particularly impressed with Israel’s cutting edge technologies and thriving economy. We recognize yours as the “start-up nation” – and the evidence is all around us.
You have embraced economic liberty. You export technology, not tyranny or terrorism. And today, your innovators and entrepreneurs have made the desert bloom and have made for a better world. The citizens of our countries are fortunate to share in the rewards of economic freedom and in the creativity of our entrepreneurs. What you have built here, with your own hands, is a tribute to your people, and a model for others.
Finally, we both believe in freedom of expression, because we are confident in our ideas and in the ability of men and women to think for themselves. We do not fear open debate. If you want to hear some very sharp criticisms of Israel and its policies, you don’t have to cross any borders. All you have to do is walk down the street and into a café, where you’ll hear people reasoning, arguing, and speaking their mind. Or pick up an Israeli newspaper – you’ll find some of the toughest criticism of Israel you’ll read anywhere. Your nation, like ours, is stronger for this energetic exchange of ideas and opinions.
That is the way it is in a free society. There are many millions of people in the Middle East who would cherish the opportunity to do the same. These decent men and women desire nothing more than to live in peace and freedom and to have the opportunity to not only choose their government but to criticize it openly, without fear of repression or repercussion.
I believe that those who oppose these fundamental rights are on the wrong side of history. But history’s march can be ponderous and painfully slow. We have a duty to speed and shape history by being unapologetic ambassadors for the values we share.
The United States and Israel have shown that we can build strong economies and strong militaries. But we must also build strong arguments that advance our values and promote peace. We must work together to change hearts and awaken minds through the power of freedom, free enterprise and human rights.
I believe that the enduring alliance between the State of Israel and the United States of America is more than a strategic alliance: it is a force for good in the world. America’s support of Israel should make every American proud. We should not allow the inevitable complexities of modern geopolitics to obscure fundamental touchstones. No country or organization or individual should ever doubt this basic truth: A free and strong America will always stand with a free and strong Israel.
And standing by Israel does not mean with military and intelligence cooperation alone.
We cannot stand silent as those who seek to undermine Israel, voice their criticisms. And we certainly should not join in that criticism. Diplomatic distance in public between our nations emboldens Israel’s adversaries.
By history and by conviction, our two countries are bound together. No individual, no nation, no world organization, will pry us apart. And as long as we stay together and stand together, there is no threat we cannot overcome and very little that we cannot achieve.
Thank you all. May God bless America, and may He bless and protect the Nation of Israel.
4,889 views
[[2]]
<<PlainTextDocument (metadata: 7)>>
08/14/12 – Mitt Romney’s Speech in Chillicothe, Ohio
Tweet
Thank you, Ohio. It’s good to be back in the Buckeye State. And it’s a privilege to be here with two good friends – your great governor, John Kasich and your outstanding senator, Rob Portman. Governor Kasich is doing a great job despite the head winds from Washington. As President, I can’t wait to work with Senator Portman to turn those Obama headwinds into pro-job policies that will help working families all across Ohio.
Tonight, we’re wrapping up our five-state bus tour to towns big and small. That trip reconfirmed to me just how important this election is – and why we need to change the direction of the country by changing the current occupant of the Oval Office.
We started out on the decks of a battleship in Norfolk, Virginia, where arbitrary and reckless defense cuts threaten our national security and 150,000 jobs. From there it was on to North Carolina, through towns that have lost thousands and thousands of manufacturing jobs. And yesterday we were in Florida, where families are still struggling with the Obama Economy.
The people I met on this tour – and the thousands of Americans I’ve visited in break rooms and lunch rooms, in school gymnasiums and on factory floors – are worried about their children, their jobs, their mortgages, and their future. And they are right to be worried.
All across the country, I’ve met people who are hurting. Some have lost their jobs; others work two jobs just to get by. Some have fallen out of the middle class and now they’re struggling to get back to where they started. The cost of living keeps going up, and they’re living paycheck to paycheck.
They are tired of being tired.
And tonight, I’d like to say to each of them: You have not been forgotten. We will not leave you behind. This is America. We are Americans. It doesn’t have to be this way!
Unemployment has been above 8 percent for 42 straight months. We will put Americans back to work!
Half of recent college graduates can’t find work or a job that matches their skills. We’ll get good jobs for our kids.
Nearly one out of six Americans are in poverty today. This is a disgrace we will end.
And President Obama has amassed five trillion dollars of debt – nearly as much debt held by the public as all other Presidents combined. We will end this moral failure.
After four years, it’s clear that President Obama’s policies aren’t fixing these problems, they’re making them worse. That is why Ohio will lead the way by electing a new President on November 6th.
For the first time, most Americans believe that our best days are behind us. This is an election in which we should be talking about the path ahead, but you don’t hear any answers coming from President Obama’s re-election campaign. That’s because he’s intellectually exhausted, out of ideas, and out of energy. And so his campaign has resorted to diversions and distractions, to demagoguing and defaming others. This is an old game in politics; what’s different this year is that the president is taking things to a new low.
It wasn’t supposed to be this way.
In 2008, Candidate Obama said, “if you don’t have any fresh ideas, then you use stale tactics to scare voters.” He said, “if you don’t have a record to run on, then you paint your opponent as someone people should run from.” And that, he told us, is how, “You make a big election about small things.”
That was Candidate Obama describing the strategy that is the now the heart of his campaign.
His campaign and his surrogates have made wild and reckless accusations that disgrace the office of the Presidency. Another outrageous charge came a few hours ago in Virginia. And the White House sinks a little bit lower.
This is what an angry and desperate Presidency looks like.
President Obama knows better, promised better and America deserves better.
Over the last four years, this President has pushed Republicans and Democrats as far apart as they can go. And now he and his allies are pushing us all even further apart by dividing us into groups. He demonizes some. He panders to others. His campaign strategy is to smash America apart and then cobble together 51 percent of the pieces.
If an American president wins that way, we all lose.
But he won’t win that way. America is one Nation under God. American history has been a story of the many becoming one – uniting to preserve liberty, uniting to build the greatest economy in the world, uniting to save the world from unspeakable darkness. Everywhere I go in America there are monuments that list those who have given their lives. There is no mention of their race, their party affiliation or what they did for a living. They lived and died under a single flag fighting for a single purpose. They pledged allegiance to the United States of America. So, Mr. President, take your campaign of division and anger and hate back to Chicago and let us get about rebuilding and reuniting America.
This election is about restoring the promise of America. It’s a choice between two visions for our nation’s future. It’s about the challenges America faces. It is about a better tomorrow and a better future.
We don’t need more excuses. We don’t need more blame. We don’t need more small-minded attacks.
What we really need is a new president.
Voters deserve an honest debate. And that’s what Paul Ryan and I will give them.
Paul and I have a positive agenda that will lead to economic growth, to widespread and shared prosperity that will improve the lives of our fellow citizens. Our Plan For A Stronger Middle Class will get America back to work and get our country back on track.
We are offering solutions that are bold, specific, and achievable. We’re committed to helping create 12 million new jobs and to bring better take-home pay to middle class families.
My plan focuses on five things.
First, energy independence. We will achieve North America energy independence by 2020, by taking full advantage of our oil, our gas, our coal, our renewables and our nuclear power. Abundant, inexpensive, domestic energy will not only create energy jobs, it will bring back manufacturing jobs.
Second, we must give our workers and our children the skills they need to succeed. Our nation cannot continue to fail in public education. For too long, we have let the agenda of union bosses steer the agenda of our schools. It is time to put our kids and their parents and their teachers first, and the union bosses behind.
Third, trade must work for America. We are one of the world’s most productive nations. Trade creates jobs and raises take-home pay for American workers. We must open more doors for trade in Latin America, where there is a growing middle class. But when any nation cheats, as China has cheated, we must make sure that there are clear and compelling consequences.
Fourth, we will do what politicians in both parties have been promising for years, but have failed to do. We will cut spending, shrink deficits, and put America on track to a balanced budget.
Fifth, we will champion small business. Unlike President Obama, I won’t raise taxes on small business. I’ll make sure regulators protect the public, but that they stop killing our jobs. I will remove the crippling uncertainty that is preventing businesses from hiring.
That begins by repealing Obamacare. It’s bad for jobs and it’s bad for seniors. If the President is re-elected, he will succeed in raiding $716 billion from Medicare — from the trust fund you have paid into all your lives – to pay for Obamacare. He is taking your money to finance his risky and unproven takeover of the health-care system. He is putting Medicare at greater risk. He is putting health care at greater risk. He is putting your jobs at greater risk. We must not let Obamacare happen.
If we focus on these five areas – energy, education, trade, deficits, and championing small business – America’s economy will come roaring back to life. And we will finally see a comeback for America’s middle class.
My plan is based on proven principles that will produce real results. I spent 25 years in business, and I know what it takes for the private sector to create jobs. I know why jobs go away, what it takes to bring them back, and what we must do to make America the best place in the world for entrepreneurs and innovators and job creators. My five-point plan will bring more jobs and more take-home pay for middle-class Americans.
People ask me why I think the President’s policies have been such a disappointment. I just don’t think President Obama understands what it is that drives our economy.
America runs on freedom. Free men and women, pursuing their dreams, working hard to build a better future for their families. This is what propels our economy. When an American succeeds, when she wins a promotion, when he creates a business, it is that individual, that American that has earned it, that has built it. Government does not build our businesses, the American people do.
The American people also build the government. We pay for it with our taxes. We choose who will lead us with our votes.
Do you want a president who believes that your rights come from God, not from government?
Do you want a president who honors your right to pursue happiness, not as government commands, but as you choose?
Do you want a president who will work every day to bring us together, not tear us apart?
Do you want a president who will celebrate success, not attack it?
Do you want a president who will never, ever apologize for the greatest nation on earth?
With your support, I will be that President.
We are 84 days away from the start of the better future we deserve.
We need new leadership, and new ideas, and a new approach – because four years of failure is enough.
Paul Ryan and I believe in America – and in this election, we’re offering Americans a clear and honest choice. Every single day we’re going to do our part. And we need you to do yours.
I commit to you that I will be the President that this moment demands. I will work to strengthen our families, to rebuild our economy and to keep our military second to none in the world.
I ask you to commit like never before over the next 84 days. This election can come down to just one more vote. I ask you find that vote. Ask one more person to join our campaign. Ask one more person to join us who supported President Obama four years ago and didn’t get the change they deserved. One more vote can make the difference in Ohio. And Ohio will make the difference for America.
Thank you. God bless you. And God bless the United States of America.
7,573 views

IE + overflow: hidden

I don't know is that an issue or bug, but when I use overflow: hidden, selecting the text and moving the cursor to the page bottom in IE, the page is scrolling (I tried IE9-IE11)! When I use Firefox/Opera/Chrome/Safari the page isn't scrolling... I have to use overflow: hidden, but it has an odd behavior in IE.
So, my question is: how can I avoid page scrolling in IE?
Use -ms-scroll-limit: 0 0 0 0; to prevent any scrolling whatsoever in IE 10+.
For older browsers you can write a workaround using JavaScript.
Example of CSS and JavaScript:
body {
overflow: hidden;
-ms-scroll-limit: 0 0 0 0;
}
window.onscroll = function (event) {
window.scrollTo(0, 0);
}
window.onscroll = function (event) {
window.scrollTo(0, 0);
}
body {
overflow: hidden;
-ms-scroll-limit: 0 0 0 0;
}
We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard, because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one which we intend to win.
We choose to go to the moon in this decade and do the other things, not because they are easy, but because they are hard, because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one which we intend to win.
Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory.
What was most significant about the lunar voyage was not that man set foot on the Moon but that they set eye on the earth.
If you could see the earth illuminated when you were in a place as dark as night, it would look to you more splendid than the moon.
When I orbited the Earth in a spaceship, I saw for the first time how beautiful our planet is. Mankind, let us preserve and increase this beauty, and not destroy it!
Buy why, some say, the moon? Why choose this as our goal? And they may as well ask why climb the highest mountain?
Across the sea of space, the stars are other suns.
Many say exploration is part of our destiny, but it’s actually our duty to future generations and their quest to ensure the survival of the human species.
As we got further and further away, it [the Earth] diminished in size. Finally it shrank to the size of a marble, the most beautiful you can imagine. That beautiful, warm, living object looked so fragile, so delicate, that if you touched it with a finger it would crumble and fall apart. Seeing this has to change a man.
If you could see the earth illuminated when you were in a place as dark as night, it would look to you more splendid than the moon.
We have an infinite amount to learn both from nature and from each other
To go places and do things that have never been done before – that’s what living is all about.
Spaceflights cannot be stopped. This is not the work of any one man or even a group of men. It is a historical process which mankind is carrying out in accordance with the natural laws of human development.
Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.
To be the first to enter the cosmos, to engage, single-handed, in an unprecedented duel with nature—could one dream of anything more?
We have an infinite amount to learn both from nature and from each other
Many say exploration is part of our destiny, but it’s actually our duty to future generations and their quest to ensure the survival of the human species.
NASA is not about the ‘Adventure of Human Space Exploration’…We won’t be doing it just to get out there in space – we’ll be doing it because the things we learn out there will be making life better for a lot of people who won’t be able to go.
Never in all their history have men been able truly to conceive of the world as one: a single sphere, a globe, having the qualities of a globe, a round earth in which all the directions eventually meet, in which there is no center because every point, or none, is center — an equal earth which all men occupy as equals. The airman's earth, if free men make it, will be truly round: a globe in practice, not in theory.
Where ignorance lurks, so too do the frontiers of discovery and imagination.
Astronomy compels the soul to look upward, and leads us from this world to another.
We have an infinite amount to learn both from nature and from each other
Curious that we spend more time congratulating people who have succeeded than encouraging people who have not.
Where ignorance lurks, so too do the frontiers of discovery and imagination.
Curious that we spend more time congratulating people who have succeeded than encouraging people who have not.
Where ignorance lurks, so too do the frontiers of discovery and imagination.
A Chinese tale tells of some men sent to harm a young girl who, upon seeing her beauty, become her protectors rather than her violators. That's how I felt seeing the Earth for the first time. I could not help but love and cherish her.
What was most significant about the lunar voyage was not that man set foot on the Moon but that they set eye on the earth.
That's one small step for [a] man, one giant leap for mankind.
(overflow: hidden is apparently inconsistent across browsers, but I do not know which browser does it right.)
Have you looked at the -ms-overflow-style property?
-ms-overflow-style: none;
More information available here: http://msdn.microsoft.com/en-us/library/ie/hh771902(v=vs.85).aspx
I have a solution for it but not sure that this is the right way or not but you can try it.
http://jsfiddle.net/b5DYf/1/
html{
position:fixed;
}

Network Traffic, MMO Tower Defense

I am programming a MMO Tower Defense game (Client Server architecture). Because of cheating protection, the server needs to have the logic. But I have real design problem. When lets say 10 People fight deathmatch against each other, every tower shoot needs to be calcuted and send over to the players. When many towers are build. (Like 10 Players * 10 Tower = 100 Tower ) the traffic is very high. (One player causes many messages per second) How can I solve this problem?
Server is written in Java ( Smartfox 2x)
Client is written in C# ( Unity 3d)
Thanks in advance.
Use strong simplified Units and combat rules on the server. Just program your damage algorithm by affecting continuous damage over time if someone is stepping into the "Damage area" around the tower.
U can use tow dimensional battlefields on the server where all units and towers and damage areas are just circles or oints and circles. U can also use several rings of damage with damage per second is lower in the outter circles and higher at the inner circles around the defense tower.
U can use queues for managing single target damage / multi target damage and area damage. Just the first in the queue is affecting by the damage area if single shot, just the first, second and third is affected by multi shot etc.
If a tower shoot a bullet every 5 seconds and does 40 damage per bullet u just calculate on the server by affecting a damage of 8 per second for every target standing in the "Damage area" or "damage circle".
On the client u can all the things like flying bullets and hitting and splish and splash and fireworks and so on.
But on the server do all the stuff by entering damage areas and then get damage per second. (sorry for bad english)
Because of cheating protection, the server needs to have the logic.
This is a false assumption. The server needs to have sufficient logic to run game logic and make sure that all players' actions make sense, but it does not need to send back the results. The clients can all run that same logic in parallel and figure out the results on their own.

Computing Checkmate Correctly

When computing checkmate for a king in chess, do you determine the other players possible moves against your king? Or do you consider merely their unit's reach? If you say it's the former, then there is a contradiction like "this statement is false" Consider this image with two kings a square apart and their knights protecting from above rooks. If we assume that the definition of possible moves must prevent check based on enemy possible moves, then the logic recursively alternates.
First, we say that our king is in check from the enemy knight so we are limited from moving our own knight because we must escape.
Then we realize that the knight does not have an available move into our king's square because he will be placing his king in check with our rook. He does not have our king in check after all.
Then we realize, free from check, that we are now able to move our own knight to the enemy king forcing him to move from check and preventing further his choices.
However, we notice that we cannot do this because it will place us in check with the enemy rook.
We realize that since we cannot actually move our knight, the enemy king is not actually in check, therefore he is freely able to use his knight to attack our king.
Go to step 2 (no matter how many times you have already).
Okay, so maybe we assume that reach always counts regardless of the enemy's check status. If our king is in reach of the enemy knight's usual attack range, we consider it a check and must resolve it. Is this how the actual game is ruled though? It seems an easy solution to the problem faced when programming the game logic, but I'm not sure if it is correct or not.
I did some thinking and came up with this analysis:
I think you have proven that the scenario of both kings being in check (not necessarily the scenario of the board I showed) cannot exist by contradiction.
Only one player can make a move at a time.
Therefore, one player makes the initial move which transitions from the state of no kings being in check to some king(s) being in check.
According to the rules, this move is not allowed if that player's king results is in a check. (I will point out the significance of 'results' soon)
This means that no matter how check is defined, he cannot make any move if his king meets that condition.
Therefore, the only transition to checks from no checks is to the enemy being in check.
The enemy must escape check, still following the rule of not entering check in one move.
The remaining state would be game over or that king escaping check.
So I understand that both kings being in check is not possible.
Now the board I showed is either reachable or not reachable.
Let's assume the board is reachable and see if there is a contradiction.
Let's ambiguously assume it's white's turn since the scenario is symmetric.
This means black just moved.
Therefore, black's king is not in check.
The black king is only reachable by the white knight.
Therefore, the white knight must be restricted by some rule to not attack the black king.
The only two possible rules that can enforce that conclusion are:
The white knight is currently protecting his king from check.
The white king is in check already and that move will not solve the check.
First, assume 2 is true regardless of 1.
The white king is in check and the only piece in attack range is black knight.
The black knight cannot attack the square containing king, however, because it would place his own king in check.
Therefore 1 must be true and the white king is not in check.
So both kings are not in check.
We reverse the game board to see if this is reachable.
Assume the scenario with the following alterations:
White has a bishop 2 up and 1 right from the black rook.
The black king is one square to the left.
The white king is one square to the right.
No kings are in range of any other pieces, so it may be reasonable to assume this initial state is reachable.
The black knight is protecting his king from the bishop, so it cannot move to under the white knight.
The white king moves left.
Now the white knight is protecting the white king and cannot move to under the black knight.
The black king moves right one square.
Thus, the scenario is reachable.
The only questioned assumption standing is that when any moves are considered, it is safe to assume that the check rules are computed. Thus, a king may come in range of a unit which may not attack it due to prevention of his own king being in check. If this assumption is not made, then the pieces simply could follow the rules of not allowing kings to enter the unrestricted attack range of an enemy unit.
Now, it is interesting to see if this scenario is computable without infinite loops.
For dependencies, I will use arrows.
For the initial white king moving left,
white king -> black knight stopped -> white bishop attack black king
Those are single step computations, no loops in dependencies so far.
For the black king to move right,
black king -> white knight stopped -> black rook attack white king
Still no dependencies.
What about when we now try to check white knight's available moves including attacking the black king?
white knight stopped -> black rook attack white king
What about if the white rook attacks the black rook?
white rook stopped -> black knight attack white king
White's remaining options are to move the king to the right or down.
Our conclusion,
Moving to this board state is possible without breaking the 'don't move into check' rule.
This board state obviously assumes that computing check depends on possible enemy moves, not their simple native attack ranges.
When this state is reached, both kings are not in check.
It is at least possible that this is not a stalemate. (Unknown if always)
So I finally found rules on wikipedia about placing another king in check even if it compromises one's own king. So, we cannot make our assumption in part 2, thus the board state is not reachable.
"A piece unable to move because it would place its own king in check (it is pinned against its own king) may still deliver check to the opposing player."
Thus our final conclusion for the apparent actual rules of chess, the board state is not reachable as it follows the check rules.
I am going to choose icedtrees answer because of the valuable logic which follows the game rules:
if for every move for player X (ignoring rules about king threats),
player Y can capture player X's king next turn,
then player X is in checkmate.
However, I would fix them to be the following:
{X is checkmate}
if and only if {
For all legal moves:(move according to rule definition) X {
There exists a generic move:(legal move A ignoring rules of protecting king A) Y such that {
X king is captured
}
}
}
I may be misunderstanding, but I think your problem is easily fixed by noting that it is only possible to be in check if it is your own turn. Check in chess is associated strongly with a compulsion to defend the check, and you cannot do that if it is not your turn.
For any chess position, it is VERY IMPORTANT to define whose turn it is, because that lies behind so many mechanics in the game. In your board position, if it is black's turn, then black is in check, and if it is white's turn, then white is in check.
Even if the position is impossible, you can still define some good rules about positions that are good for chess computations.
Some notes on checkmate in chess:
Checkmate is actually not very intuitive, and when you play the game you start to notice funny checkmate situations that do not make much sense.
Here is a good way of thinking about checkmate, in my opinion:
In a legal chess game, when checkmate occurs, the checkmated player is unable to prevent his king being captured the successive turn by the opposing player. That is, checkmate in chess is nothing but "ending the game one turn early", so to speak. If you ignore all rules in chess about threats to the king, but preserve the movement patterns of the pieces, a computer could calculate checkmate by looking forward.
The logic would be as follows:
if for every move for player X (ignoring rules about king threats), player Y can capture player X's king next turn, then player X is in checkmate.
Here is a more complete version of "check and escaping check":
Given it is player X's turn:
if player X's king is in movement range of player Y's piece, it is in check. If the piece cannot escape check, it is checkmate.
There are three ways of escaping check:
Moving your king to a non-attacked square
Blocking the piece(s) delivering check
Capturing the checking piece.
Maybe you're over-thinking this :-)
Here's the algorithm from a working chess program that's relatively strong in human terms:
Generate the list of pseudo-legal moves for the side to move. By pseudo-legal, I mean don't bother to verify whether the generated move leaves that side's King in check. Omitting this verification can save time validating moves that are never searched.
For each move that is searched, validate that it doesn't leave the side to move in check.
If every move leaves the King in check, then the side to move has either been mated or it's stalemate.
If the side to move is currently in check, then it's mate. Otherwise it's stalemate.
My naïve approach would probably go like this.
player.startTurn();
if (player.isInCheck()
if(player.king.hasNoLegalMoves() && player.cannotProtectKing())
game.checkMate(player);
function isInCheck() {
boolean isInCheck = false;
for (Piece p : player.Opponent)
if (p.canAttack(player.king) {
isInCheck = true;
return;
}
I may be missing something here, but I don't understand why it wouldn't be this simple.
For one thing, this board position isn’t even REMOTELY possible.
1) How did you get the rooks and kings off the first and eighth ranks without moving any pawns?
2) Check is defined as the state where your king is under attack by an opposing piece. CheckMATE is the situation where you are in check and cannot legally get out of check.
3) If it’s your turn and one of your pieces is capable of capturing the opponent’s king, it doesn’t matter if you would put yourself in check to do so: it’s whose king would die first?
4) Notwithstanding that, if it’s your turn and your opponent is in check, it either means neither player noticed that your opponent was in check (in which case you go back and make sure they can—and do—get out of check before you do anything else) or that nobody noticed that it was checkmate.
So, when it’s your turn you can’t finish in check, but when determining a threat to the king, the opposing king’s safety is irrelevant.

Resources