parsing

parser for Data.ByteString.Lazy.Char8 in Haskell ?

Hi i'm facing the following problem, i have to re-write an existant code to improve his performances. the old version was using a parser defined like this : newtype Parser Char a = Parser {runParser :: [Char] -> [(a,[Char])]} to parse lines from files. but it was too slow and required a lot of memory to achieve the computation upon l...

Unknown recursions of a XML structure with SAX

I have to parse a XML structure in JAVA using the SAX parser. The problem is that the structure is recursive with an unspecified count of recursions. This still is not such a big deal the big deal is that I can't take advantage of the XML namespace functionality and the tags are the same on every recursion level. Here is an example of t...

istream parse EVENT_TYPE(param1;param2; ...)

I'm trying to find an elegant way to parse a string like: EVENT_TYPE(param1;param2; ...) EVENT_TYPE is one of many string constants, each has zero or more parameters. So far I thought that given the sting "s" contains EVENT_TYPE(param1;param2) I'd write: if (boost::istarts_with(s, "EVENT_TYPE")) { std::istringstream iss(s); int p...

Removing whitespace-characters, except inside quotation marks in PHP?

Hey I couldn't find any similar question, so I start a new one. I need to remove all whitespace from string, but quotations should stay as they were. I'm building a personal kind of minifier. Here's an example: string to parse: hola hola "pepsi cola" yay output: holahola"pepsi cola"yay Any idea? I'm sure this can be done with rege...

Parse string into a tree structure?

I'm trying to figure out how to parse a string in this format into a tree like data structure of arbitrary depth. "{{Hello big|Hi|Hey} {world|earth}|{Goodbye|farewell} {planet|rock|globe{.|!}}}" [[["Hello big" "Hi" "Hey"] ["world" "earth"]] [["Goodbye" "farewell"] ["planet" "rock" "globe" ["." "!"]]]] ...

How to break a number into different parts in Java ?

Hi, I'm looking to do the following : let's say I have a number like 125.625 => I would like to be able to tell my program that is 1 * 100 + 2 * 10 + 5 * 1 + 0.625. How could I do that please ? thanks ...

Parsing the Data in JSON Response

Hello Team, Here I am posting the Json Response: {"ResultSet": {"Result":[ {"Phone":"(650) 473-9999", "Distance":"2.59", "MapUrl":"http://maps.yahoo.com/maps_result?q1=441+Emerson+St+Palo+Alto+CAgid1=28734629", "Categories": {"Category":[ {"content":"Salad Restaurants", ...

zend_mm_heap error with simple_html_dom

I'm trying to parse an HTML file with simplehtmldom and I'm getting this error: zend_mm_heap corrupted after about 4 seconds of execution on a 8231 lines HTML file. Could this be a bug or just excessive memory usage? ...

MT940 format parser

Can you recommend any OS, ready-to-go, well-documented and not dead MT940 format parser for Python? ...

Java Parser for Natural Langauge

Hi everyone! I am looking for a parser (or generated parser) in java that is capable of followings: 1- I will provide sentences that are already part-of-speech tagged. I will use my own tag set. 2- I don't have any statistical data. So if the parser is statistical, I want to be able to use it without this feature. 3- Adaptable to other...

opennlp vs stanford nlptools vs berkeley

Hi the aim is to parse a sizeable corpus like wikipedia to generate the most probable parse tree,and named entity recognition. Which is the best library to achieve this in terms of performance and accuracy? Has anyone used more than one of the above libraries? ...

C# Convert Relative to Absolute Links in HTML String

I'm mirroring some internal websites for backup purposes. As of right now I basically use this c# code: System.Net.WebClient client = new System.Net.WebClient(); byte[] dl = client.DownloadData(url); This just basically downloads the html and into a byte array. This is what I want. The problem however is that the links within the h...

String to Date parsing in C#?

Hi, I have a data string 'yyyymmddhhmmss' example: '20101001151014', how Do I parse this to date in C#? ...

How to parse the "request body" using python CGI?

I just need to write a simple python CGI script to parse the contents of a POST request containing JSON. This is only test code so that I can test a client application until the actual server is ready (written by someone else). I can read the cgi.FieldStorage() and dump the keys() but the request body containing the JSON is nowhere to ...

Haskell : how to stop Data.Attoparsec.Char8.sepBy when input String is empty ?

hi i've wrote the following Haskell code import Data.Attoparsec (Parser) import qualified Data.Attoparsec.Char8 as A import qualified Data.ByteString.Char8 as B someWithSep sep p = A.sepBy p sep the code is suppose to work this way : main*> A.parse (someWithSep A.skipSpace A.decimal) $ B.pack "123 45 67 89" Done "" [123,45,67,89]...

XML parsing issue with '&' in element text

I have the following code: import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource(new StringRea...

Parsing element of a string array into a int

As the question says am trying to parse one of the elements of an string array into a int variable. although the code is right in terms of syntax, when I try to run it, I get the following error message. Error 1 Building content threw FormatException: Input string was not in a correct format. at System.Number.StringToNumber(St...

Java: how to collect incoming data fragments into properly terminated strings for subsequent parsing?

I just joined StackOverflow after having found many great answers here in the past. Here's my first question: EDIT: I feel bad... my first question to StackOverflow turned out to be a "wild goose chase". The problem is in the data, not the code reading the data. I was looking for a solution in the wrong place! I will explain in a commen...

Downloaded plist (in NSString) convert to NSArray

I am not sure what I am doing wrong here. I have a simple plist on my server. I am using the ASIHTTPRequest framework, so I can get both the data object and a string. Outputting: [[NSString alloc] initWithData:[request responseData] encoding:NSUTF8StringEncoding] works just fine and the output it the plist. However, I cannot get this ...

Android java datetime values from String to Long to String issue

Long time reader, first time poster. In Android, capturing date from datepicker and storing as string in sqlite. Sorting by date doesn't work because they're strings (unless I'm doing it wrong. I've googled this issue for ~5 days, and it looks like there should be a way to capture the date from the date picker, convert it to a Long, s...