Convert SAS Compged function to Python - python

For project requirements, I am converting all the SAS codes to python, I got stuck where for 2 string matching, SAS inbuilt COMPGED function is used. I need the same score so need to convert it into Python code rather than using other libraries like fuzzywuzzy.
Please help if possible, just need some starter code to understand how to build it.
COMPGED

Getting exact match is going to be extremely complex. You will need to produce your own implementation of the generalised edit distance.
A good starting point might be here:
https://www.python-course.eu/levenshtein_distance.php

Related

Any python library for Bezier curve approximation with biarcs?

I am in need of a simple python library which can perform Bezier curve approximation algorithm with biarcs (biarc interpolation). I am looking for something like the algorithm explained at approximating-bezier-curves-by-biarcs which also includes CSharp implementation.
I have tried searching, for similar implementation in python. I found some but they were inside in CNC controllers code like gcodetools. Extracting just the part I need, seems to be complicated. And couldn't find any simple ones, which just implement the algorithm.
Before I try to convert CSharp code to python, I want to check here if any such python script already exists. Please share anything you think might be helpful.

Change Regular Expression to NFA and then to DFA in python using Thomsons Construction and Subset Construction

I need to convert the Regular Expression inputted having alphabets = {a,b} and the operations to be included are Concatenation, Union, Kleene Closure, somewhat of the form (a|b)*abab.
Would someone suggest how I can implement it in Python? Is there any function or so in Python for this, and if so, please tell me how to use it. If not, then please tell me how to code it from scratch. I have been trying to figure out how to write an effective code for this, but each time I have an error or I have wrong output.
The Answer to the above question has been put on github. The link for the same is =>
Compilers

Parsing a parenthesis

I'm trying to make a calculator in Python 3 (just to learn). I want to be able to evaluate (just as an example) "5 * ( 2 + 1 )^2" from an input(). I would like to be able to detect if parenthesis are closed or contain another set of parenthesis. I also need to be able to isolate the information within so I can evaluate it in the proper order.
I realize that this could be a significant chunk of code, so if you could point me in the right direction I would be very grateful. I'm looking for links to documentation, function names, and any hints you could provide to help me.
A stack based calculator is what you are looking for !
http://en.wikipedia.org/wiki/Reverse_Polish_notation
This is a classic stack data structure practice problem. There are two approaches you can use, one being converting from infix to post/prefix notation which is considerably easier to process but still require the additional step of converting, or you can go and directly evaluate the expression.
Here is a good starting point on the subject, a basic implementation of a stack and some more in-depth information about your subject. Starting from there, you should easily find your way, otherwise give me a comment and I'll try to help you out.

how does python' set difference work internally?

Recently, i am looking through some python modules to understand their behavior and how optimized their implementation are. Can any one tell what algorithm does python use to perform the set difference operations. One possible way to achieve set difference is by using hash tables which will involve an extra N space. I tried to find the source code of set operations but i am not able to find out the code location. Please help.
A set in python is a hash itself. So implementing difference for it is not as hard as you imagine. Looking from a higher level how does one implement set difference? Iterate over one of the collections and add to the result all elements that are not present in the other sequence.

Matlab function equivalent for Python (Flood Fill)

Quick question, I'm looking for a python function that performs the equivalent job that matlab's imfill.m does. I realize that python has openCV but I have been unable to get that to work properly and am trying to find a substitute for it. The part of imfill that I'm trying to replicate is the 'holes' part of it.
I have a mask that I've generated but I'm trying to fill in all regions that are surrounded by 'land' and leave only the water regions unfilled in.
If this isn't clear enough please let me know and I can try and be more specific. Thank you for your time.
I was able to find a function within scipy that performed similar to what imfill does. It's called binary_fill_holes and it can be found here for anyone that is having the same problem as myself.
Although I can't take full/any real credit for finding it since it was answered here to one of my other questions PIL Plus/imToolkit replacements by unutbu.

Categories

Resources