A question I dare not ask on Stackoverflow
-
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
-
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
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
-
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
Thank you! I will give this a try tonight!
-
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
-
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
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
-
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
-
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
-
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
nice ! - I don't recall seeing that .. it's a pity the image links in your docco are messed up :(
-
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
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 -
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
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.
-
nice ! - I don't recall seeing that .. it's a pity the image links in your docco are messed up :(
-
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 -
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
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.