Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. A question I dare not ask on Stackoverflow

A question I dare not ask on Stackoverflow

Scheduled Pinned Locked Moved The Lounge
linuxquestiontoolsperformance
13 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RaviBeeR RaviBee

    You can use my StringParser[^] to do exactly this.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using RavSoft;

    namespace StringParserExample
    {
    class Program
    {
    static void Main(string[] args)
    {
    // The corpus
    string corpus = @"
    I'm crafty like a fox. But it's not as if anyone cares.
    Covered as an examine so regular of. Ye astonished friendship
    remarkably like a potentiometer. Windows admire matter praise
    you as if they really care. Delivered ye sportsmen zealously
    like an elephant who never forgets. Nay any article enabled
    musical shyness yet sixteen yet blushes.";

            // Initialization
            List similies = new List();
            string phrase = null;
            StringParser sp = new StringParser(corpus);
    
            // Get phrases following "like a"
            while (sp.skipToEndOf(" like a ")) {
                if (sp.extractTo(".", ref phrase)) {
                    similies.Add(phrase);
                }
            }
    
            // Get phrases following "as if"
            sp.resetPosition();
            while (sp.skipToEndOf(" as if ")) {
                if (sp.extractTo(".", ref phrase)) {
                    similies.Add(phrase);
                }
            }
    
            // Output results
            foreach(string similie in similies.OrderBy(p => p)) {
                Console.WriteLine(similie);
            }
        }
    }
    

    }

    /ravi

    My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    Holy sh!t What would your comment have been if it had been a new member?

    It does not solve my Problem, but it answers my question Chemists have exactly one rule: there are only exceptions

    J RaviBeeR 2 Replies Last reply
    0
    • L Lost User

      Holy sh!t What would your comment have been if it had been a new member?

      It does not solve my Problem, but it answers my question Chemists have exactly one rule: there are only exceptions

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #5

      I'm guessing the same.

      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

      RaviBeeR 1 Reply Last reply
      0
      • J jeron1

        I'm guessing the same.

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #6

        Yessir. :thumbsup: /ravi

        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

        1 Reply Last reply
        0
        • L Lost User

          Holy sh!t What would your comment have been if it had been a new member?

          It does not solve my Problem, but it answers my question Chemists have exactly one rule: there are only exceptions

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #7

          The same. /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          1 Reply Last reply
          0
          • RaviBeeR RaviBee

            You can use my StringParser[^] to do exactly this.

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using RavSoft;

            namespace StringParserExample
            {
            class Program
            {
            static void Main(string[] args)
            {
            // The corpus
            string corpus = @"
            I'm crafty like a fox. But it's not as if anyone cares.
            Covered as an examine so regular of. Ye astonished friendship
            remarkably like a potentiometer. Windows admire matter praise
            you as if they really care. Delivered ye sportsmen zealously
            like an elephant who never forgets. Nay any article enabled
            musical shyness yet sixteen yet blushes.";

                    // Initialization
                    List similies = new List();
                    string phrase = null;
                    StringParser sp = new StringParser(corpus);
            
                    // Get phrases following "like a"
                    while (sp.skipToEndOf(" like a ")) {
                        if (sp.extractTo(".", ref phrase)) {
                            similies.Add(phrase);
                        }
                    }
            
                    // Get phrases following "as if"
                    sp.resetPosition();
                    while (sp.skipToEndOf(" as if ")) {
                        if (sp.extractTo(".", ref phrase)) {
                            similies.Add(phrase);
                        }
                    }
            
                    // Output results
                    foreach(string similie in similies.OrderBy(p => p)) {
                        Console.WriteLine(similie);
                    }
                }
            }
            

            }

            /ravi

            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

            G Offline
            G Offline
            Garth J Lancaster
            wrote on last edited by
            #8

            nice ! - I don't recall seeing that .. it's a pity the image links in your docco are messed up :(

            RaviBeeR 1 Reply Last reply
            0
            • RaviBeeR RaviBee

              You can use my StringParser[^] to do exactly this.

              using System;
              using System.Collections.Generic;
              using System.Linq;
              using RavSoft;

              namespace StringParserExample
              {
              class Program
              {
              static void Main(string[] args)
              {
              // The corpus
              string corpus = @"
              I'm crafty like a fox. But it's not as if anyone cares.
              Covered as an examine so regular of. Ye astonished friendship
              remarkably like a potentiometer. Windows admire matter praise
              you as if they really care. Delivered ye sportsmen zealously
              like an elephant who never forgets. Nay any article enabled
              musical shyness yet sixteen yet blushes.";

                      // Initialization
                      List similies = new List();
                      string phrase = null;
                      StringParser sp = new StringParser(corpus);
              
                      // Get phrases following "like a"
                      while (sp.skipToEndOf(" like a ")) {
                          if (sp.extractTo(".", ref phrase)) {
                              similies.Add(phrase);
                          }
                      }
              
                      // Get phrases following "as if"
                      sp.resetPosition();
                      while (sp.skipToEndOf(" as if ")) {
                          if (sp.extractTo(".", ref phrase)) {
                              similies.Add(phrase);
                          }
                      }
              
                      // Output results
                      foreach(string similie in similies.OrderBy(p => p)) {
                          Console.WriteLine(similie);
                      }
                  }
              }
              

              }

              /ravi

              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

              J Offline
              J Offline
              Johnny J
              wrote on last edited by
              #9

              Nice work. Hadn't seen that before. An easy 5 from me! :thumbsup:

              Anything that is unrelated to elephants is irrelephant
              Anonymous
              -----
              The problem with quotes on the internet is that you can never tell if they're genuine
              Winston Churchill, 1944
              -----
              Never argue with a fool. Onlookers may not be able to tell the difference.
              Mark Twain

              RaviBeeR 1 Reply Last reply
              0
              • P Peltier Cooler

                This could have been a rant, but it's a question that I am serious about getting an answer for rather than multiple downvotes from Stackoverflowers who have too much free time and way too much bile: I love noir fiction for the use of similes (and metaphors, but they lack useful key phrases for this exercise). I want to create a script of some kind to scan through a text corpus and pull out the words in a sentence which follow the word "like" to the end of the sentence. Or "as if". I haven't used grep, sed and awk for many years now but memory tells me that's the fast way to write this little script. Am I totally on the wrong track? It's a newbie's question for sure, which is why I won't take it to SO. :~

                Raised by wolves in the stacks of the public library

                O Offline
                O Offline
                obermd
                wrote on last edited by
                #10

                I wouldn't ask a question there either as the one time I did I got told it was a stupid idea, yet here we are doing both of those things all the time. It was how to upload files to a web-site before frameworks handled this. I also don't answer questions there because someone will always come along and downvote it, even if it answers the question perfectly.

                1 Reply Last reply
                0
                • G Garth J Lancaster

                  nice ! - I don't recall seeing that .. it's a pity the image links in your docco are messed up :(

                  RaviBeeR Offline
                  RaviBeeR Offline
                  RaviBee
                  wrote on last edited by
                  #11

                  Yes, they've been 404 for years. Will fix - thanks. /ravi

                  My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                  1 Reply Last reply
                  0
                  • J Johnny J

                    Nice work. Hadn't seen that before. An easy 5 from me! :thumbsup:

                    Anything that is unrelated to elephants is irrelephant
                    Anonymous
                    -----
                    The problem with quotes on the internet is that you can never tell if they're genuine
                    Winston Churchill, 1944
                    -----
                    Never argue with a fool. Onlookers may not be able to tell the difference.
                    Mark Twain

                    RaviBeeR Offline
                    RaviBeeR Offline
                    RaviBee
                    wrote on last edited by
                    #12

                    Thank you! /ravi

                    My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                    1 Reply Last reply
                    0
                    • P Peltier Cooler

                      This could have been a rant, but it's a question that I am serious about getting an answer for rather than multiple downvotes from Stackoverflowers who have too much free time and way too much bile: I love noir fiction for the use of similes (and metaphors, but they lack useful key phrases for this exercise). I want to create a script of some kind to scan through a text corpus and pull out the words in a sentence which follow the word "like" to the end of the sentence. Or "as if". I haven't used grep, sed and awk for many years now but memory tells me that's the fast way to write this little script. Am I totally on the wrong track? It's a newbie's question for sure, which is why I won't take it to SO. :~

                      Raised by wolves in the stacks of the public library

                      N Offline
                      N Offline
                      Nelek
                      wrote on last edited by
                      #13

                      Next time please use the Quick Answers[^] or the specific forum from the Discussion Boards[^]

                      M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups