Old thread here:
viewtopic.php?f=50&t=24908
Note: The code corrupted when I pasted it into code tags previously so I have added it to the Google drive link listed in the Version 1 thread above. It's called "SS_Fuzzy_V1.0.au3". Just copy that to your c:\temp folder and open and run it in the Scite Editor.
There were a few issues with the old code, primarily the pattern matching between the BF market names and the ones used by SofaScore. In many cases the team names used are completely different, site by site. The download code was also indiscriminate, in that data for all live matches was being pulled on each loop - not very efficient.
So, I hit on the idea of creating an input\output loop in Guardian via the Import & Export CSV Rules, using only markets where the baf was deployed. The code then knows which markets to query for on SofaScore plus it allows for much more complex pattern matching in the code.
I'm using a 3 part pattern match now.
1. 2 strings match exactly in both match names, ignoring commonly used words
2. An algo using the Damerau–Levenshtein distance to return the edit distance between the 2 strings. i.e how many single character edits are needed to match them
(https://en.wikipedia.org/wiki/Damerau-L ... n_distance for any bored enough to check

3. A simple check on whether we have an age match i.e U19, U23 etc or a womens match. There are often matches played the same time\day where the only difference is the "U19", "(W)" in the market name
Where we have 2 matches that both pattern match, I'm then ranking on the shortest Damerau–Levenshtein distance to determine which is the correct match
A step through then looks like this:
1. Deploy baf to required Match Odds markets in Guardian using a coupon\filter etc
2. Run script in Scite (Same install instructions as Version 1)
3. Baf creates a file in C:\Temp\CSV_Output with the market name appended, when an inplay state is detected
4. Script picks up exported file name, deletes it and checks if there is a pattern matched market listed in SS and it doesnt already exist, if so it queries its Event ID and adds it to an array to be queried each loop, until match end
5. Script queries the API for each match with an EventID, and returns the score, stats and momentum data to the import CSV for Guardian to import
6. At match end (status set in the API), the market is deleted from our query list automatically
Notes:
You should be able to leave the script running 24/7 as it is self maintainiing. I left it on all weekend with no crashes. Just load and apply your baf to the days markets daily etc
Scores, stats and Momentum are pulled for each match automatically. Where SS are only publishing the score or a cut down set of data then only those will be created in the import CSV. Momentum and stats tend to only be available for major leagues
I've changed the default value of all the SV's to 0, so you may want to cater for those in your automation i.e Is Not 0
SV's returned can be checked in the exported CSV file but I've added in a few more for the Momentum Graph
Note: Graph is on a 0 axis so 0 to +99 is in favour of Home, 0 to -99 in favour of Away
5MinAvgPressure (Average of last 5 mins)
10MinAvgPressure (Average of last 5 mins)
MatchAvgPressure (Average of Entire match)
Momentum1 (Current Momentum, 1m interval)
Momentum2 (Current Momentum -1, 1m interval)
Momentum3 etc
Momentum4
Momentum5
Time = 0
5MinPeakResult (Highest Momentum value in last 5m)
10MinPeakResult (Highest Momentum value in last 10m)
5MinLowResult (Lowest Momentum value in last 5m)
10MinLowResult (Lowest Momentum value in last 10m)
1HHighResult1 (at 45m, this returns the highest + peak in the 1st half)
1HHighResult2 (at 45m, this returns the 2nd highest + peak in the 1st half)
1HLowResult1 (at 45m, this returns the lowest - peak in the 1st half)
1HLowResult2 (at 45m, this returns the 2nd lowest - peak in the 1st half)
I put the last 4 in so the automation would have a handle on decent first half pressure for each team, ready for any 2nd half entries, without having to refer to individual stats
Note: The SV for Time is only available where there is a momentum graph as its uses the number of datapoints for the graph. It is more accurate than using BA in play time however as the 2nd half always starts on minute 46, irrelevant of 1st half ET
IMPORTANT:You need to create the following directory C:\Temp\CSV_Output manually, prior to using the baf\script for the first time
I've included an experimental 2nd Half LTD baf to demo the SV's created. No idea how this one plays out in real life. It does however , populate the watch list with the time, score and key stats (if available) via alert rules, so you can see at a glance whats happening in the game.
if you only want the stats data, then just delete everything but the first 4 lines in the baf, or copy those to your own.
Capture.JPG
I ran this all weekend and the pattern matching checked out on every match I looked at, though there were so many games I cant guarantee every one was 100% - too much work for one person lol
Anyway, hope this is useful. I've enjoyed the challenge of creating it and learnt quite a bit along the way
Cheers
Stu