Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Strings not changing

  • 14-04-2007 11:26pm
    #1
    Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭


    Hi hi,

    Was wondering if anyone could help. I've attached a text file which I'm sorting and counting which all works fine to the most part. There are some values at the end which arent being stripped properly was wondering if anyone knows why

    Below are the characters which are removed from the text file. I'm reading in alice in wonderland, counting the words then sorting it in a balanced tree. So that all works fine, but I think I'm overlooking some text values to modify (As I build a word up once I hit " " assumes a new word is coming in)
            private string removeEscapeCharacters(string value)
            {
                value = value.Replace("\t", string.Empty);
                value = value.Replace("\v", string.Empty);
                value = value.Replace("\n", string.Empty);
                value = value.Replace("\r", string.Empty);
                value = value.Replace("\'", string.Empty);
                value = value.Replace("\"", string.Empty);
                value = value.Replace("-", string.Empty);
                value = value.Replace("!", string.Empty);
                value = value.Replace("?", string.Empty);
                value = value.Replace("_", string.Empty);
                value = value.Replace("`", string.Empty);
                value = value.Replace("(", string.Empty);
                value = value.Replace(")", string.Empty);
    
                return value;
            }
    

    P.s the text file is the sorted and counted file. The values that arent being converted properly are at the bottom of the text file.


Comments

  • Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭damnyanks


    Also while I'm at it. Does anyone have a cheaper solution for writing hte values to the text file?

    currently have the following
                foreach (int q in fdq)
                {
                    string value = orderWordStructure().Values.ToString();
                    File.WriteAllText(@"c:\f.txt", value);
                }
    

    the rest of the algorithm kicks in just fine. The writing to disk takes about 15 seconds! Can I write 1meg to a stream and dump it into a text file quicker?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Why not just read it in blocks?

    As for the first question haven't tested it, but I would use StringTokenizer and just have those as token seperators. Although there is probably an easier way again.


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    Firstly, check out "Regex", in particular use the Regex.Replace method to filter out the letters you don't want.

    Secondly, what's the problem? I don't know what you textfile is supposed to look like, and i dont know what's wrong with it. You'll have to explain a bit better what the problem is.

    Finally,
    foreach (int q in fdq)
                {
                    string value = orderWordStructure().Values.ToString();
                    File.WriteAllText(@"c:\f.txt", value);
                }
    
    For each int in fdq you are writing out the *entire* of the order word structure. That means you're writing the exact same thing potentially hundreds of times one after the other to the disk. Thats what its slow.

    Remove the "foreach" and you'll be fine.


  • Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭damnyanks


    Did some screwing about with regex and it murdered my computer. I'm parsing the wholoe alice in wonderland as my test. Finally figured out the slow disk thing thanks :)

    It's all working fine now.

    Anyone know where I could get a list of prnouns, nouns etc. ?


  • Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭damnyanks


    Already comiled that is. GOing through google english websites at the moment :)


  • Advertisement
Advertisement