Search Results

Search found 2490 results on 100 pages for 'matching'.

Page 1/100 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • A couple of pattern matching issues with pattern matching in Lua

    - by Josh
    I'm fairly new to lua programming, but I'm also a quick study. I've been working on a weather forecaster for a program that I use, and it's working well, for the most part. Here is what I have so far. (Pay no attention to the zs.stuff. That is program specific and has no bearing on the lua coding.) if not http then http = require("socket.http") end local locale = string.gsub(zs.params(1),"%s+","%%20") local page = http.request("http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" .. locale .. "&wuSelect=WEATHER") local location = string.match(page,'title="([%w%s,]+) RSS"') --print("Gathering weather information for " .. location .. ".") --local windspeed = string.match(page,'<span class="nobr"><span class="b">([%d.]+)</span>&nbsp;mph</span>') --print(windspeed) local condition = string.match(page, '<td class="vaM taC"><img src="http://icons-ecast.wxug.com/i/c/a/[%w_]+.gif" width="42" height="42" alt="[%w%s]+" class="condIcon" />') --local image = string.match(page, '<img src="http://icons-ecast.wxug.com/i/c/a/(.+).gif" width="42" height="42" alt="[%w%s]+" class="condIcon" />') local temperature = string.match(page,'pwsvariable="tempf" english="&deg;F" metric="&deg;C" value="([%d.]+)">') local humidity = string.match(page,'pwsvariable="humidity" english="" metric="" value="(%d+)"') zs.say(location) --zs.say("image ./Images/" .. image .. ".gif") zs.say("<color limegreen>Condition:</color> <color white>" .. condition .. "</color>") zs.say("<color limegreen>Temperature: </color><color white>" .. temperature .. "F</color>") zs.say("<color limegreen>Humidity: </color><color white>" .. humidity .. "%</color>") My main issue is this: I changed the 'condition' and added the 'image' variables to what they are now. Even though the line it's supposed to be matching comes directly from the webpage, it fails to match at all. So I'm wondering what it is I'm missing that's preventing this code from working. If I take out the <td class="vaM taC">< img src="http://icons-ecast.wxug.com/i/c/a/[%w_]+.gif" it'll match condition flawlessly. (For whatever reason, I can't get the above line to display correctly, but there is no space between the `< and img) Can anyone point out what is wrong with it? Aside from the pattern matching, I assure you the line is verbatim from the webpage. Another question I had is the ability to match across line breaks. Is there any possible way to do this? The reason why I ask is because on that same page, a few of the things I need to match are broken up on separate lines, and since the actual pattern I'm wanting to match shows up in other places on the page, I need to be able to match across line breaks to get the exact pattern. I appreciate any help in this matter!

    Read the article

  • XSLT fails to load huge XML doc after matching certain elements

    - by krisvandenbergh
    I'm trying to match certain elements using XSLT. My input document is very large and the source XML fails to load after processing the following code (consider especially the first line). <xsl:template match="XMI/XMI.content/Model_Management.Model/Foundation.Core.Namespace.ownedElement/Model_Management.Package/Foundation.Core.Namespace.ownedElement"> <rdf:RDF> <rdf:Description rdf:about=""> <xsl:for-each select="Foundation.Core.Class"> <xsl:for-each select="Foundation.Core.ModelElement.name"> <owl:Class rdf:ID="@Foundation.Core.ModelElement.name" /> </xsl:for-each> </xsl:for-each> </rdf:Description> </rdf:RDF> </xsl:template> Apparently the XSLT fails to load after "Model_Management.Model". The PHP code is as follows: if ($xml->loadXML($source_xml) == false) { die('Failed to load source XML: ' . $http_file); } It then fails to perform loadXML and immediately dies. I think there are two options now. 1) I should set a maximum executing time. Frankly, I don't know how that I do this for the built-in PHP 5 XSLT processor. 2) Think about another way to match. What would be the best way to deal with this? The input document can be found at http://krisvandenbergh.be/uml_pricing.xml Any help would be appreciated! Thanks.

    Read the article

  • sample java code for approximate string matching or boyer-moore extended for approximate string matc

    - by Dolphin
    Hi I need to find 1.mismatch(incorrectly played notes), 2.insertion(additional played), & 3.deletion (missed notes), in a music piece (e.g. note pitches [string values] stored in a table) against a reference music piece. This is either possible through exact string matching algorithms or dynamic programming/ approximate string matching algos. However I realised that approximate string matching is more appropriate for my problem due to identifying mismatch, insertion, deletion of notes. Or an extended version of Boyer-moore to support approx. string matching. Is there any link for sample java code I can try out approximate string matching? I find complex explanations and equations - but I hope I could do well with some sample code and simple explanations. Or can I find any sample java code on boyer-moore extended for approx. string matching? I understand the boyer-moore concept, but having troubles with adjusting it to support approx. string matching (i.e. to support mismatch, insertion, deletion). Also what is the most efficient approx. string matching algorithm (like boyer-moore in exact string matching algo)? Greatly appreciate any insight/ suggestions. Many thanks in advance

    Read the article

  • Maximum bipartite graph (1,n) "matching"

    - by Imre Kelényi
    I have a bipartite graph. I am looking for a maximum (1,n) "matching", which means that each vertex from partitation A has n associated vertices from partition B. The following figure shows a maximum (1,3) matching in a graph. Edges selected for the matching are red and unselected edges are black. This differs from the standard bipartite matching problem where each vertex is associate with only one other vertex, which could be called (1,1) matching with this notation. If the matching cardinality (n) is not enforced but is an upper bound (vertices from A can have 0 < x <= n associated vertices from B), then the maximum matching can be found easily by transforming the graph to a flow network and finding the max flow. However, this does not guarantee that the maximum number of vertices from A will have n associated pairs from B.

    Read the article

  • Numerical Pattern Matching

    - by Timothy Strimple
    A project I'm researching requires some numerical pattern matching. My searches haven't turned up many relevant hits since most results tend to be around text pattern matching. The idea is we'll have certain wave patterns we'll need to be watching for and trying to match incoming data vs the wave database we will be building. Here is and example of one of the wave patterns we'll need to be matching against. There is clearly a pattern there, but the peaks will not have the exact same values, but the overall shape of the wave iterations will be very similar. Does anyone have any advice on how to go about storing and later matching these patterns, and / or other search terms I can use to find more information on the subject of pattern matching? Thanks, Tim.

    Read the article

  • Lua pattern matching vs. regular expressions

    - by harald
    hello, i'm currently learning lua. regarding pattern-matching in lua i found the following sentence in the lua documentation on lua.org: Nevertheless, pattern matching in Lua is a powerful tool and includes some features that are difficult to match with standard POSIX implementations. as i'm familiar with posix regular expressions i would like to know if there are any common samples where lua pattern matching is "better" compared to regular expression -- or did i misinterpret the sentence? and if there are any common examples: why is any of pattern-matching vs. regular expressions better suited? thanks very much, harald

    Read the article

  • string matching algorithms used by lucene

    - by iamrohitbanga
    i want to know the string matching algorithms used by Apache Lucene. i have been going through the index file format used by lucene given here. it seems that lucene stores all words occurring in the text as is with their frequency of occurrence in each document. but as far as i know that for efficient string matching it would need to preprocess the words occurring in the Documents. example: search for "iamrohitbanga is a user of stackoverflow" (use fuzzy matching) in some documents. it is possible that there is a document containing the string "rohit banga" to find that the substrings rohit and banga are present in the search string, it would use some efficient substring matching. i want to know which algorithm it is. also if it does some preprocessing which function call in the java api triggers it.

    Read the article

  • pattern matching in .Net consistent with IsolatedStorageFile.GetFileNames() pattern matching

    - by Mick N
    Is the pattern matching logic used by this API exposed for reuse somewhere in the .Net Framework? Something of the form FilePatternMatch( string searchPattern, stringfileNameToTest ) is what I'm looking for. I'm implementing a temporary workaround for WP7 not filtering the results for this overload and I'd like the solution to both provide a consistent experience and avoid reinventing this functionality if it is exposed. If the behaviour is not exposed for reuse, a regular expression solution (like glob pattern matching in .NET) will suffice and would save me spending the time to test the fine details of what the behaviour should be. Perhaps one of the answers posted in the thread linked above is correct. Since I haven't confirmed the exact behaviour as yet, I wasn't able to determine this at a glance. Feel free to point me to one of those answers if you know it is behaviouraly an exact match to the API referenced in the question title. I could assume the pattern matching is consistent with how DOS handled * and ? in 8.3 file names (I'm familiar with behavioural nuances of that implementation), but it's reasonable to assume Microsoft has evolved pattern matching behaviour for file names in the decade+ since so I thought I would check before proceeding on that assumption.

    Read the article

  • Approximate string matching with a letter confusion matrix?

    - by zigglenaut
    I'm trying to model a phonetic recognizer that has to isolate instances of words (strings of phones) out of a long stream of phones that doesn't have gaps between each word. The stream of phones may have been poorly recognized, with letter substitutions/insertions/deletions, so I will have to do approximate string matching. However, I want the matching to be phonetically-motivated, e.g. "m" and "n" are phonetically similar, so the substitution cost of "m" for "n" should be small, compared to say, "m" and "k". So, if I'm searching for [mein] "main", it would match the letter sequence [meim] "maim" with, say, cost 0.1, whereas it would match the letter sequence [meik] "make" with, say, cost 0.7. Similarly, there are differing costs for inserting or deleting each letter. I can supply a confusion matrix that, for each letter pair (x,y), gives the cost of substituting x with y, where x and y are any letter or the empty string. I know that there are tools available that do approximate matching such as agrep, but as far as I can tell, they do not take a confusion matrix as input. That is, the cost of any insertion/substitution/deletion = 1. My question is, are there any open-source tools already available that can do approximate matching with confusion matrices, and if not, what is a good algorithm that I can implement to accomplish this?

    Read the article

  • Algorithm for multiple word matching in a text, count the number of every matched word

    - by 66
    I have noticed that it has solutions for matching multiple words in a given text, such as below: http://stackoverflow.com/questions/1099985/algorithm-for-multiple-word-matching-in-text If I want to know exactly the number of appearances of each matched word in the text, my solution is like this: step 1: using ac-algorithm to obtain the maching words; step 2: count the number of each word obtained in step 1 is there a faster way? Thx~

    Read the article

  • Aligning music notes using String matching algorithms or Dynamic Programming

    - by Dolphin
    Hi I need to compare 2 sets of musical pieces (i.e. a playing-taken in MIDI format-note details extracted and saved in a database table, against sheet music-taken into XML format). When evaluating playing against sheet music (i.e.note details-pitch, duration, rhythm), note alignment needs to be done - to identify missed/extra/incorrect/swapped notes that from the reference (sheet music) notes. I have like 1800-2500 notes in one piece approx (can even be more-with polyphonic, right now I'm doing for monophonic). So will I have to have all these into an array? Will it be memory overloading or stack overflow? There are string matching algorithms like KMP, Boyce-Moore. But note alignment can also be done through Dynamic Programming. How can I use Dynamic Programming to approach this? What are the available algorithms? Is it about approximate string matching? Which approach is much productive? String matching algos like Boyce-Moore, or dynamic programming? How can I assess which is more effective? Greatly appreciate any insight or suggestions Thanks in advance

    Read the article

  • Ranking based string matching algorithm..for Midi Music

    - by Taha
    i am working on midi music project. What i am trying to do is:- matching the Instrument midi track with the similar instrument midi track... for example Flute track in a some midi music is matched against the Flute track in some other music midi file... After matching ,the results should come ranking wise according to their similarity.. Like 1) track1 2) track2 3) track3 I have this sort of string coming from my midi music .. F4/0.01282051282051282E4/0.01282051282051282Eb4/0.01282051282051282 D4/0.01282051282051282C#4/0.01282051282051282C4/0.01282051282051282 Which ranking algorithm with good metrics should i use for such data ? Thanking you in anticipation!

    Read the article

  • Matching of tuples

    - by Jack
    From what I understood I can use pattern-matching in a match ... with expression with tuples of values, so something like match b with ("<", val) -> if v < val then true else false | ("<=", val) -> if v <= val then true else false should be correct but it gives me a syntax error as if the parenthesis couldn't be used: File "ocaml.ml", line 41, characters 14-17: Error: Syntax error: ')' expected File "ocaml.ml", line 41, characters 8-9: Error: This '(' might be unmatched referring on first match clause.. Apart from that, can I avoid matching strings and applying comparisons using a sort of eval of the string? Or using directly the comparison operator as the first element of the tuple?

    Read the article

  • Problem with pattern matching in ocaml

    - by Antony
    I wrote the function used to decompose a Boolean function, the problem is that the compilation I get this : "Warning 5: this function application is partial, maybe some arguments are missing." How can I solve this problem? I've set wrong the patter matching or I can not run this operation with pattern matching The code is the following: let rec decomposition state_init state prec formula = match formula with And form -> (fun () -> let f1 = List.hd form in let f2 = And(List.tl form )in let new_state = Forms (state_init,f1) in decomposition state_init new_state state f1; decomposition state_init new_state state f2; Hashtbl.add graph new_state (("",false,state :: []) , []) ; let x = Hashtbl.find graph state in let succ = state :: snd x in let (desc,last,ptrs) = fst x in Hashtbl.replace graph state ( ("And-node",last,ptrs) , succ))

    Read the article

  • pattern matching in Bash

    - by Tim
    Hi, Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$ filename=$(basename $pathandfile) bash-3.2$ echo $filename ff.txt bash-3.2$ echo ${filename##*.} txt bash-3.2$ echo ${filename%.*} ff I was wondering what does ## and % mean in the patterns. How is the patten matching working? Thanks and regards!

    Read the article

  • Matching unmatched strings based on a unknown pattern

    - by Polity
    Alright guys, i really hurt my brain over this one and i'm curious if you guys can give me any pointers towards the right direction i should be taking. The situation is this: Lets say, i have a collection of strings (let it be clear that the pattern of this strings is unknown. For a fact, i can say that the string contain only signs from the ASCII table and therefore, i dont have to worry about weird Chinese signs). For this example, i take the following collection of strings (note that the strings dont have to make any human sence so dont try figguring them out :)): "[001].[FOO].[TEST] - 'foofoo.test'", "[002].[FOO].[TEST] - 'foofoo.test'", "[003].[FOO].[TEST] - 'foofoo.test'", "[001].[FOO].[TEST] - 'foofoo.test.sample'", "[002].[FOO].[TEST] - 'foofoo.test.sample'", "-001- BAR.[TEST] - 'bartest.xx1", "-002- BAR.[TEST] - 'bartest.xx1" Now, what i need to have is a way of finding logical groups (and subgroups) of these set of strings, so in the above example, just by rational thinking, you can combine the first 3, the 2 after that and the last 2. Also the resulting groups from the first 5 can be combined in one main group with 2 subgroups, this should give you something like this: { { "[001].[FOO].[TEST] - 'foofoo.test'", "[002].[FOO].[TEST] - 'foofoo.test'", "[003].[FOO].[TEST] - 'foofoo.test'", } { "[001].[FOO].[TEST] - 'foofoo.test.sample'", "[002].[FOO].[TEST] - 'foofoo.test.sample'", } { "-001- BAR.[TEST] - 'bartest.xx1", "-002- BAR.[TEST] - 'bartest.xx1" } } Sorry for the layout above but indenting with 4 spaces doesnt seem to work correctly (or im frakk'n it up). Anyways, I'm not sure how to approach this problem (how to get the result desired as indicated above). First of, i thought of creating a huge set of regexes which would parse most known patterns but the amount of different patterns is just to huge that this isn't realistic. Another think i thought of was parsing each indidual word within a string (so strip all non alphabetic or numeric characters and split by those), and if X% matches, i can assume the strings belong to the same group. (where X wil probably be around 80/90). However, i find the area of speculation kinda big. For example, when matching strings with each 20 words, the change of hitting above 80% is kinda big (that means that 4 words can differ), however when matching only 8 words, 2 words at most can differ. My question to you is, what would be a logical approach in the above situation? Thanks in advance!

    Read the article

  • OCaml: Matching with any negative

    - by nicotine
    Is there a way to get pattern matching to match my value with any negative number? It does not matter what the negative number is I just need to match with any negative. I have accomplished what I want with this simple code: let y = if(n < 0) then 0 else n in match y with 0 -> [] | _ -> [x] @ clone x (n - 1) But I want to eliminate that if statement and just get it to check it as another case in the match statement

    Read the article

  • Stereo Matching - Dynamic Programming

    - by Varun
    Hi, I am supposed to implement Dynamic programming algorithm for Stereo matching problem. I have read 2 research papers but still haven't understood as to how do I write my own c++ program for that ! Is there any book or resource that's available somewhere that I can use to get an idea as to how to start coding actually ? Internet search only gives me journal and conference papers regarding Dynamic Programming but not how to implement the algorithm step by step. Thanks Varun

    Read the article

  • Perl pattern matching with zero width assertion

    - by Simone
    Hi everyone, I can't get why this code work: $seq = 'GAGAGAGA'; my $regexp = '(?=((G[UCGA][GA]A)|(U[GA]CG)|(CUUG)))'; # zero width match while ($seq =~ /$regexp/g){ # globally my $pos = pos($seq) + 1; # position of a zero width matching print "$1 position $pos\n"; } I know this is a zero width match and it dosn't put the matched string in $&, but why does it put it in $1? thank you!

    Read the article

  • Django approximate matching of unicode strings with ascii equivalents

    - by c
    I have the following model and instance: class Bashable(models.Model): name = models.CharField(max_length=100) >>> foo = Bashable.objects.create(name=u"piñata") Now I want to be able to search for objects, but using ascii characters rather than unicode, something like this: >>> Bashable.objects.filter(name__lookslike="pinata") Is there a way in Django to do this sort of approximate string matching, using ascii stand-ins for the unicode characters in the database? Here is a related question, but for Apple's Core Data.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >