parsing

How can I name and organize methods used by a finite state machine?

In the following code you'll see a simple lexer that conforms to the following regular expression: \d*(\.\d*)?([eE]([+-]\d+|\d+))? If I were to use this design for something more complex, all of the anonymous delegates would be a nightmare to maintain. The biggest challenge I am facing is what to name the methods that would act as cho...

Converting chinese to pinyin

I've found places on the web such as http://www.chinesetopinyin.com/ that convert Chinese characters to pinyin (romanization). Does anyone know how to do this, or have a database that can be parsed? EDIT: I'm using C# but would actually prefer a database/flatfile. ...

Python code flow does not work as expected ?

Hello everyone, I am trying to process various texts by regex and NLTK of python -which is at http://www.nltk.org/book-. I am trying to create a random text generator and I am having a slight problem. Firstly, here is my code flow: Enter a sentence as input -this is called trigger string, is assigned to a variable- Get longest word in ...

Clean text in php.

Hi, This is a string: --0-1946616131-1282798399=:21360 Content-Type: text/plain; charset=us-ascii -------------- ------ do not change ---------------------------- Ticket ID : #987336 -------------------- ------------------------------------------- Hello, This is my problem try to solve this thank u --0-1946616131-1282798399=:21360 Cont...

QString, remove labels and content?

Hi, message.Text() is a QString. I want to remove some text. The text can be: Normal: "This is a text" With a label: "<label1>something</label1>This is a text" First, I find if the text has the label: !message.Text().contains("<label1>", Qt::CaseInsensitive)) So, if it has, I want to remove the first part, to have a normal text...

Parsing this text file

I have this text file that contains approximately 22 000 lines, with each line looking like this: 12A4 (Text) So it's in the format 4-letter/number (Hexdecimal) and then text. Sometimes there is more than one value in text, separated by a comma: A34d (Text, Optional) Is there any efficient way to search for the Hex and then return the...

Automatically Map JSON Objects into Instance Variables in Ruby

I would like to be able to automatically parse JSON objects into instance variables. For example, with this JSON. require 'httparty' json = HTTParty.get('http://api.dribbble.com/players/simplebits') #=> {"shots_count":150,"twitter_screen_name":"simplebits","avatar_url":"http://dribbble.com/system/users/1/avatars/thumb/dancederholm-peek...

Objective-C, iPhone RSS Reader Application Query - How to organize your RSS Feed Display into groups?

Hi! I've been very unfortunate with my programming. I am still rather new to Objective-C, but I am trying to learn as quickly as possible. I need to complete an RSS Reader for iPhones application, a relatively simple one which parses the rss feed, displays it in a navigation-table view and when you click on an article you are taken to ...

How can I parse this JSON in Android?

I would like to be able to pull out different fields like Name and Symbol etc. How can I create my JSONObject in Android to do this? { "query": { "count": "1", "created": "2010-08-26T07:09:40Z", "lang": "en-US", "results": { "quote": { "symbol": "AAPL", "Ask": "241...

How do I Select Highest Number From Series of <string>_# File Names in Bash Script

I have a directory with files heat1.conf heat2.conf ... heat<n>.conf minimize.conf ... other files.... I want my Bash script to be able to grab the highest number filename (so I can delete and replace it when I find an error condition). What's the best way to accomplish this? Please discuss the speed of your solution and why you thi...

Working with XML in Delphi (returning specific data to a variable)

I have been trying to work with Delphi 2010 and MSXML for the past few days, I am an extreme novice and need a little direction. var MemoryStream: TMemoryStream; XMLPath: String; sName: String; XMLDoc: variant; doc: TStringList; begin //unrelated code // Create XML File to hard disk begin MemoryStream...

Problem parsing XML document with Java SAX

Hello everyone, I am parsing an XML document. I have done this thousands of times before, but I can't see why I am getting the following issue: Here is the relevant part of the XML document that I am parsing: XML: <?xml version="1.0" standalone="yes"?> <ratings> <url_template>http://api.netflix.com/users/T1BlCJtdcWMuF6gJEfue96_W.kZ_gW...

Is there a SAX Parser for Delphi and Free Pascal?

Besides MSXML and SAX for Pascal, can you recommend a SAX parser for Delphi? It would be great if it could be used in cross-platform applications with Free Pascal. ...

Parse and remove part of a QString

I want to parse some kind (or pure) XML code from a QString. My QString is like: <a>cat</a>My cat is very nice. I want to obtain 2 strings: cat, and My Cat is very nice. I think a XML parser is not maybe necessary, but in the future I will have more tags in the same string so it's also a very interesting point. ...

Safe expression parser in Python

How can I allow users to execute mathematical expressions in a safe way? Do I need to write a full parser? Is there something like ast.literal_eval(), but for expressions? ...

Parsing HTML in Android: no XSLT? What to use?

In need in my application to fetch remote HTML document and parse some parts out of it. As I don't want to play with string parsing, which would be really lots of work, I thought about using XSLT, which would let me build small XML document out of HTML and then read it easy. Seems there is no XSLT support in Android? What other ways I c...

Efficiently parsing a large text file in C#

I need to read a large space-seperated text file and count the number of instances of each code in the file. Essentially, these are the results of running some experiments hundreds of thousands of times. The system spits out a text file that looks kind of like this: A7PS A8PN A6PP23 ... And there are literally hundreds of thousands of...

How to parse different XML files using SAX on Android

Hey there, I have the following scenario: I send a XML file to a server as a request and get a XML file as response and all that as a background thread on android. The XML request is serialized using various values. The XML response is then read by SAX and put into a list. The whole request/response process happens in a background thre...

PHP: Parse document / text into sentences...

I am looking for a PHP equivalent along the lines of: http://journals.ecs.soton.ac.uk/java/tutorial/intl/collation/textBound.html My goal is to be able to take arbitrary text and split it into sentences (realizing of course that not every (.) ends a sentence. Does anyone know of a library or method? ...

Removing Tags from HTML Parsed with BeautifulSoup

I'm new to python and I'm using BeautifulSoup to parse a website and then extract data. I have the following code: for line in raw_data: #raw_data is the parsed html separated into smaller blocks d = {} d['name'] = line.find('div', {'class':'torrentname'}).find('a') print d['name'] <a href="/ubuntu-9-10-desktop-i386-t314421...