How to infer one-to-one/one-to-many relationship? We have a file with IP addresses patterns as shown below:
 source IP    ,,,,,,,    Dest IP

 10.10.1.41   ,,,,,,,  12.13.67.89

 67.34.6.8    ,,,,,,,  34.67.8.90

 10.10.1.41   ,,,,,,,  12.13.67.89

 10.10.1.41   ,,,,,,,  12.13.67.89

where ,,,,,,, represents other IP's.
Based on this table we need to train a NLP engine that can infer the relationship between IPs. For example, it could be another column as below:
,,,,,,,    RelationType

,,,,,,,    one to many
,,,,,,,    many to one
,,,,,,,    one to one

How can we infer this relationship?
 A: Use the mappings function in the utilities package
You can examine functional mappings between variables in a data-frame using the mappings function in the utilities package in R.  This function takes an input data-frame and examines whether there are mappings between the variables.  By default the function examines only the factor variables, but you can examine all variables in the data by setting all.vars = TRUE.  (Bear in mind that mappings between non-factor variables should be interpreted with caution; continuous variables are almost always in a one-to-one mapping because they do not have duplicate values.)  Here is an example of a mock dataset containing five factor variables, with a number of mappings between them.
#Create data frame 
VAR1 <- c(0,1,2,2,0,1,2,0,0,1)
VAR2 <- c('A','B','B','B','A','B','B','A','A','B')
VAR3 <- c(1:10)
VAR4 <- c('A','B','C','D','A','B','D','A','A','B')
VAR5 <- c(1:5,1:5)
DATA <- data.frame(VAR1 = factor(VAR1),
                   VAR2 = factor(VAR2),
                   VAR3 = factor(VAR3),
                   VAR4 = factor(VAR4),
                   VAR5 = factor(VAR5))
DATA

   VAR1 VAR2 VAR3 VAR4 VAR5
1     0    A    1    A    1
2     1    B    2    B    2
3     2    B    3    C    3
4     2    B    4    D    4
5     0    A    5    A    5
6     1    B    6    B    1
7     2    B    7    D    2
8     0    A    8    A    3
9     0    A    9    A    4
10    1    B   10    B    5

We can examine the mappings using the R code below.  As you can see, the output of the function shows you all the functional relationships that hold between the factors, and it also tells you which factors are "redundant" (i.e., functions of other factors).  By default the output includes a DAG plot showing the mappings between the factors.
#Examine mappings in the data
library(utilities)
MAPS <- mappings(DATA)
MAPS


Mapping analysis for data-frame DATA containing 5 factors (analysis ignores NA values) 

There were 7 mappings identified: 
 
     VAR1 → VAR2 
     VAR3 → VAR1 
     VAR3 → VAR2 
     VAR3 → VAR4 
     VAR3 → VAR5 
     VAR4 → VAR1 
     VAR4 → VAR2 

Redundant factors: 
 
     VAR1 
     VAR2 
     VAR4 
     VAR5 

Non-Redundant factors: 
 
     VAR3


As can be seen from the output and the plot, the only non-redundant factor in the data-frame is VAR3; all other factor variables are functions of this variable.  (This can aslo be confirmed by looking at the values in the data-frame.)
