parsing

Parsing TimeSpan from string including format

五迷三道 提交于 2021-02-20 15:01:47
问题 I'm sure this must be simple, but I can't figure out how to word it correctly in Google... I have a config which has a field: TimeToPoll="1d" Now I want to do something like : TimeSpan.Parse(TimeToPoll); Returning a timespan of one day. In C# EDIT: I'm looking for a method which allows parse of "1d" as well as "1s" or "1y" etc. Is this possible? Meaning: "1d" parses to {1.00:00:00} "1h" parses to {0.01:00:00} "1m" parses to {0.00:01:00} "1s" parses to {0.00:00:01} 回答1: The d is not needed and

Parsing TimeSpan from string including format

℡╲_俬逩灬. 提交于 2021-02-20 14:56:03
问题 I'm sure this must be simple, but I can't figure out how to word it correctly in Google... I have a config which has a field: TimeToPoll="1d" Now I want to do something like : TimeSpan.Parse(TimeToPoll); Returning a timespan of one day. In C# EDIT: I'm looking for a method which allows parse of "1d" as well as "1s" or "1y" etc. Is this possible? Meaning: "1d" parses to {1.00:00:00} "1h" parses to {0.01:00:00} "1m" parses to {0.00:01:00} "1s" parses to {0.00:00:01} 回答1: The d is not needed and

What concepts or algorithms exist for parallelizing parsers?

≡放荡痞女 提交于 2021-02-20 10:16:25
问题 It seems easy to parallelize parsers for large amounts of input data that is already given in a split format, e.g. a large list of individual database entries, or is easy to split by a fast preprocessing step, e.g. parsing the grammatical structure of sentences in large texts. A bit harder seems to be parallel parsing that already requires quite some effort to locate sub-structures in a given input. Common programming language code looks like a good example. In languages like Haskell, that

What concepts or algorithms exist for parallelizing parsers?

可紊 提交于 2021-02-20 10:12:24
问题 It seems easy to parallelize parsers for large amounts of input data that is already given in a split format, e.g. a large list of individual database entries, or is easy to split by a fast preprocessing step, e.g. parsing the grammatical structure of sentences in large texts. A bit harder seems to be parallel parsing that already requires quite some effort to locate sub-structures in a given input. Common programming language code looks like a good example. In languages like Haskell, that

Java XPath umlaut/vowel parsing

主宰稳场 提交于 2021-02-20 04:13:14
问题 I want to parse the following xml structure: <?xml version="1.0" encoding="utf-8"?> <documents> <document> <element name="title"> <value><![CDATA[Personnel changes: Müller]]></value> </element> </document> </documents> For parsing this element name="????? structure I use XPath in the following way: XPath xPath = XPathFactory.newInstance().newXPath(); String currentString = (String) xPath.evaluate("/documents/document/element[@name='title']/value",pCurrentXMLAsDOM, XPathConstants.STRING); The

Java XPath umlaut/vowel parsing

烂漫一生 提交于 2021-02-20 04:13:13
问题 I want to parse the following xml structure: <?xml version="1.0" encoding="utf-8"?> <documents> <document> <element name="title"> <value><![CDATA[Personnel changes: Müller]]></value> </element> </document> </documents> For parsing this element name="????? structure I use XPath in the following way: XPath xPath = XPathFactory.newInstance().newXPath(); String currentString = (String) xPath.evaluate("/documents/document/element[@name='title']/value",pCurrentXMLAsDOM, XPathConstants.STRING); The

Java XPath umlaut/vowel parsing

不想你离开。 提交于 2021-02-20 04:12:43
问题 I want to parse the following xml structure: <?xml version="1.0" encoding="utf-8"?> <documents> <document> <element name="title"> <value><![CDATA[Personnel changes: Müller]]></value> </element> </document> </documents> For parsing this element name="????? structure I use XPath in the following way: XPath xPath = XPathFactory.newInstance().newXPath(); String currentString = (String) xPath.evaluate("/documents/document/element[@name='title']/value",pCurrentXMLAsDOM, XPathConstants.STRING); The

Using PyParsing to parse language with signficant newlines (like Python)

孤街浪徒 提交于 2021-02-19 08:58:20
问题 I am implementing a language where the newlines are significant, sometime, as in Python, with exactly the same rules. For the purpose of my question we can take the Python fragment that has to do with assignments, parentheses, and the treatment of newlines and semicolons. For example, one could write: a = 1 + 2 + 3 # ok b = c but not a = 1 + 2 + 3 b = c # incorrect because one needs a newline to divide the two statements. However we can have a = 1 + 2 + 3; b = c # ok using the semicolon. Also

Parse measurements (multiple dimensions) from a given string in Python 3

只愿长相守 提交于 2021-02-19 08:30:06
问题 I'm aware of this post and this library but they didn't help me with these specific cases below. How can I parse measurements like below: I have strings like below; "Square 10 x 3 x 5 mm" "Round 23/22; 24,9 x 12,2 x 12,3" "Square 10x2" "Straight 10x2mm" I'm looking for a Python package or some way to get results like below; >>> a = amazing_parser.parse("Square 10 x 3 x 5 mm") >>> print(a) 10 x 3 x 5 mm Likewise; >>> a = amazing_parser.parse("Round 23/22; 24,9x12,2") >>> print(a) 24,9 x 12,2 I

Text.Parsec many parser won't fully parse a custom parser

末鹿安然 提交于 2021-02-19 01:31:11
问题 I'm having an issue in which my parser for if-blocks (and Do-While blocks because the problem is the same) won't terminate upon the parsing of the string "fi". An If-Block takes the form of: if P -> p [] Q -> q fi If I use Text.Parsec 's string parser to parse "fi" like how I used it to parse "if" to even enter the loop, the program halts. When I print out what should be evaluated its not even there so the program doesn't even enter the If-Block when it is ended with "fi" . When I remove the