The following are two arrays:
import difflib
import scipy
import numpy
a1=numpy.array(['198.129.254.73','134.55.221.58','134.55.219.121','134.55.41.41','198.124.252.101'], dtype='|S15')
b1=numpy.array(['198.124.252.102','134.55.41.41','134.55.219.121','134.55.219.137','134.55.220.45', '198.124.252.130'],dtype='|S15')
difflib.get_close_matches(a1[-1],b1,2)
output:
['198.124.252.130', '198.124.252.102']
shouldnt '198.124.252.102'
be the closest match for '198.124.252.101'
?
I looked at the documentation where they have specified about some floating type weights but no information on algorithm use.
I am in need to find if the absolute difference between the last two octet is 1 (provided the first three octets are same).
So I am finding the closest string first and then checking that closest string for the above condition.
Is there any other function or way to achieve this? Also how does get_close_matches()
behave?
ipaddr
doesnt seem to have such a manipulation for ips.