Skip to content

Commit 99bdad5

Browse files
Merge branch 'develop'
2 parents 9b2372f + d800920 commit 99bdad5

File tree

7 files changed

+264
-16
lines changed

7 files changed

+264
-16
lines changed

rosette_api/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
//
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.33.0.0")]
35-
[assembly: AssemblyVersion("1.33.0.0")]
36-
[assembly: AssemblyFileVersion("1.33.0.0")]
34+
// [assembly: AssemblyVersion("1.36.0.0")]
35+
[assembly: AssemblyVersion("1.36.0.0")]
36+
[assembly: AssemblyFileVersion("1.36.0.0")]

rosette_api/RecordSimilarityConverter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
1818
if (value is UnknownFieldRecord)
1919
{
2020
serializer.Serialize(writer, ((UnknownFieldRecord)value).Data);
21+
} else if (value is NumberRecord) {
22+
writer.WriteValue(((NumberRecord)value).Number);
23+
} else if (value is BooleanRecord) {
24+
writer.WriteValue(((BooleanRecord)value).Boolean);
2125
} else {
2226
writer.WriteValue(value.ToString());
2327
}

rosette_api/RecordSimilarityField.cs

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,201 @@ public override string ToString()
692692
}
693693
}
694694

695+
/// <summary>
696+
/// Class for representing a string record
697+
/// </summary>
698+
[JsonConverter(typeof(UnfieldedRecordSimilarityConverter))]
699+
public class StringRecord : RecordSimilarityField
700+
{
701+
public const string DATA = "data";
702+
703+
/// <summary>
704+
/// Gets and sets the string record
705+
/// </summary>
706+
[JsonProperty(PropertyName = DATA)]
707+
public string Text { get; set;}
708+
709+
/// <summary>
710+
/// No-args constructor
711+
/// </summary>
712+
public StringRecord() { }
713+
714+
/// <summary>
715+
/// Constructor
716+
/// </summary>
717+
/// <param name="data">The string record</param>
718+
public StringRecord(string data)
719+
{
720+
this.Text = data;
721+
}
722+
723+
/// <summary>
724+
/// Equals override
725+
/// </summary>
726+
/// <param name="obj">The object to compare</param>
727+
/// <returns>True if equal</returns>
728+
public override bool Equals(object obj)
729+
{
730+
if (obj is StringRecord)
731+
{
732+
StringRecord other = obj as StringRecord;
733+
return this.Text == other.Text;
734+
}
735+
else
736+
{
737+
return false;
738+
}
739+
}
740+
741+
/// <summary>
742+
/// Hashcode override
743+
/// </summary>
744+
/// <returns>The hashcode</returns>
745+
public override int GetHashCode()
746+
{
747+
return this.Text != null ? this.Text.GetHashCode() : 1;
748+
}
749+
750+
/// <summary>
751+
/// ToString override.
752+
/// </summary>
753+
/// <returns>This string record as a string</returns>
754+
public override string ToString()
755+
{
756+
return this.Text;
757+
}
758+
}
759+
760+
/// <summary>
761+
/// Class for representing a number record
762+
/// </summary>
763+
[JsonConverter(typeof(UnfieldedRecordSimilarityConverter))]
764+
public class NumberRecord : RecordSimilarityField
765+
{
766+
public const string DATA = "data";
767+
768+
/// <summary>
769+
/// Gets and sets the number record
770+
/// </summary>
771+
[JsonProperty(PropertyName = DATA)]
772+
public double Number { get; set; }
773+
774+
/// <summary>
775+
/// No-args constructor
776+
/// </summary>
777+
public NumberRecord() { }
778+
779+
/// <summary>
780+
/// Constructor
781+
/// </summary>
782+
/// <param name="data">The number record</param>
783+
public NumberRecord(double data)
784+
{
785+
this.Number = data;
786+
}
787+
788+
/// <summary>
789+
/// Equals override
790+
/// </summary>
791+
/// <param name="obj">The object to compare</param>
792+
/// <returns>True if equal</returns>
793+
public override bool Equals(object obj)
794+
{
795+
if (obj is NumberRecord)
796+
{
797+
NumberRecord other = obj as NumberRecord;
798+
return this.Number == other.Number;
799+
}
800+
else
801+
{
802+
return false;
803+
}
804+
}
805+
806+
/// <summary>
807+
/// Hashcode override
808+
/// </summary>
809+
/// <returns>The hashcode</returns>
810+
public override int GetHashCode()
811+
{
812+
return this.Number.GetHashCode();
813+
}
814+
815+
/// <summary>
816+
/// ToString override.
817+
/// </summary>
818+
/// <returns>This number record as a string</returns>
819+
public override string ToString()
820+
{
821+
return this.Number.ToString();
822+
}
823+
}
824+
825+
/// <summary>
826+
/// Class for representing a boolean record
827+
/// </summary>
828+
[JsonConverter(typeof(UnfieldedRecordSimilarityConverter))]
829+
public class BooleanRecord : RecordSimilarityField
830+
{
831+
public const string DATA = "data";
832+
833+
/// <summary>
834+
/// Gets and sets the boolean record
835+
/// </summary>
836+
[JsonProperty(PropertyName = DATA)]
837+
public bool Boolean { get; set; }
838+
839+
/// <summary>
840+
/// No-args constructor
841+
/// </summary>
842+
public BooleanRecord() { }
843+
844+
/// <summary>
845+
/// Constructor
846+
/// </summary>
847+
/// <param name="data">The boolean record</param>
848+
public BooleanRecord(bool data)
849+
{
850+
this.Boolean = data;
851+
}
852+
853+
/// <summary>
854+
/// Equals override
855+
/// </summary>
856+
/// <param name="obj">The object to compare</param>
857+
/// <returns>True if equal</returns>
858+
public override bool Equals(object obj)
859+
{
860+
if (obj is BooleanRecord)
861+
{
862+
BooleanRecord other = obj as BooleanRecord;
863+
return this.Boolean == other.Boolean;
864+
}
865+
else
866+
{
867+
return false;
868+
}
869+
}
870+
871+
/// <summary>
872+
/// Hashcode override
873+
/// </summary>
874+
/// <returns>The hashcode</returns>
875+
public override int GetHashCode()
876+
{
877+
return this.Boolean.GetHashCode();
878+
}
879+
880+
/// <summary>
881+
/// ToString override.
882+
/// </summary>
883+
/// <returns>This boolean record as a string</returns>
884+
public override string ToString()
885+
{
886+
return this.Boolean.ToString().ToLower();
887+
}
888+
}
889+
695890
/// <summary>
696891
/// Class for representing an unknown field
697892
/// </summary>

rosette_api/RecordSimilarityFieldInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public static class RecordFieldType
1414
public const string RniName = "rni_name";
1515
public const string RniDate = "rni_date";
1616
public const string RniAddress = "rni_address";
17+
public const string RniString = "rni_string";
18+
public const string RniNumber = "rni_number";
19+
public const string RniBoolean = "rni_boolean";
1720
}
1821

1922
/// <summary>

rosette_api/rosette_api.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>rosette_api</id>
5-
<version>1.33.0</version>
5+
<version>1.36.0</version>
66
<description>.Net (C#) Binding for Babel Street Analytics API</description>
77
<!-- TODO update these once there is a user on Nuget -->
88
<authors>basistech</authors>

rosette_apiExamples/record_similarity.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ static void Main(string[] args)
3434
string dobField = "dob";
3535
string dob2Field = "dob2";
3636
string addrField = "addr";
37+
string jobField = "jobTitle";
38+
string ageField = "age";
39+
string retiredField = "isRetired";
3740
string dobHyphen = "1993-04-16";
3841

3942
// Creating the request object
@@ -42,10 +45,13 @@ static void Main(string[] args)
4245
{ primaryNameField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniName, Weight = 0.5 } },
4346
{ dobField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniDate, Weight = 0.2 } },
4447
{ dob2Field, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniDate, Weight = 0.1 } },
45-
{ addrField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniAddress, Weight = 0.5 } }
48+
{ addrField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniAddress, Weight = 0.5 } },
49+
{ jobField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniString, Weight = 0.2 } },
50+
{ ageField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniNumber, Weight = 0.4 } },
51+
{ retiredField, new RecordSimilarityFieldInfo { Type = RecordFieldType.RniBoolean, Weight = 0.05 } }
4652
};
4753

48-
RecordSimilarityProperties properties = new RecordSimilarityProperties { Threshold = 0.7, IncludeExplainInfo = false };
54+
RecordSimilarityProperties properties = new RecordSimilarityProperties { Threshold = 0.7, IncludeExplainInfo = true };
4955

5056
RecordSimilarityRecords records = new RecordSimilarityRecords {
5157
Left = new List<Dictionary<string, RecordSimilarityField>>
@@ -55,27 +61,34 @@ static void Main(string[] args)
5561
{ primaryNameField, new FieldedNameRecord { Text = "Ethan R", Language = "eng", LanguageOfOrigin = "eng", Script = "Latn", EntityType = "PERSON"} },
5662
{ dobField, new UnfieldedDateRecord { Date = dobHyphen} },
5763
{ dob2Field, new FieldedDateRecord { Date = "04161993", Format = "MMddyyyy"} },
58-
{ addrField, new UnfieldedAddressRecord { Address = "123 Roadlane Ave"}}
64+
{ addrField, new UnfieldedAddressRecord { Address = "123 Roadlane Ave"} },
65+
{ jobField, new StringRecord { Text = "software engineer"} }
5966
},
6067
new Dictionary<string, RecordSimilarityField>
6168
{
6269
{ primaryNameField, new FieldedNameRecord { Text = "Evan R"} },
63-
{ dobField, new FieldedDateRecord { Date = dobHyphen} }
70+
{ dobField, new FieldedDateRecord { Date = dobHyphen} },
71+
{ ageField, new NumberRecord { Number = 47.344 } },
72+
{ retiredField, new BooleanRecord { Boolean = false } }
6473
}
6574
},
6675
Right = new List<Dictionary<string, RecordSimilarityField>>
6776
{
6877
new Dictionary<string, RecordSimilarityField>
6978
{
7079
{ primaryNameField, new FieldedNameRecord { Text = "Seth R", Language = "eng"} },
71-
{ dobField, new FieldedDateRecord { Date = dobHyphen} }
80+
{ dobField, new FieldedDateRecord { Date = dobHyphen} },
81+
{ jobField, new StringRecord { Text = "manager"} },
82+
{ retiredField, new BooleanRecord { Boolean = true } }
7283
},
7384
new Dictionary<string, RecordSimilarityField>
7485
{
7586
{ primaryNameField, new UnfieldedNameRecord { Text = "Ivan R"} },
7687
{ dobField, new FieldedDateRecord { Date = dobHyphen} },
7788
{ dob2Field, new FieldedDateRecord { Date = "1993/04/16"} },
78-
{ addrField, new FieldedAddressRecord { HouseNumber = "123", Road = "Roadlane Ave"} }
89+
{ addrField, new FieldedAddressRecord { HouseNumber = "123", Road = "Roadlane Ave"} },
90+
{ ageField, new NumberRecord { Number = 72 } },
91+
{ retiredField, new BooleanRecord { Boolean = true } }
7992
}
8093
}
8194
};

0 commit comments

Comments
 (0)