-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathRosetteEvent.cs
More file actions
107 lines (96 loc) · 3.68 KB
/
RosetteEvent.cs
File metadata and controls
107 lines (96 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using static System.Collections.Specialized.BitVector32;
namespace rosette_api
{
/// <summary>
/// A class for representing an identified event and its properties
/// </summary>
[JsonObject(MemberSerialization.OptOut)]
public class RosetteEvent : IEquatable<RosetteEvent>
{
/// <summary>
/// Gets or sets the event type of the extracted event
/// </summary>
[JsonProperty("eventType")]
public String EventType { get; set; }
/// <summary>
/// Gets or sets the list of mentions of the extracted event
/// </summary>
[JsonProperty("mentions")]
public List<EventMention> Mentions { get; set; }
/// <summary>
/// Gets or sets the confidence of the extracted event
/// </summary>
[JsonProperty("confidence")]
public Nullable<double> Confidence { get; set; }
/// <summary>
/// Gets or sets the workspace ID of the extracted event
/// </summary>
[JsonProperty("workspaceId")]
public String workspaceId { get; set; }
/// <summary>
/// Creates an event
/// </summary>
/// <param name="eventType">The description of the event type</param>
/// <param name="mentions">The list of event mentions</param>
/// <param name="id">The confidence this was a correctly labeled event</param>
/// <param name="workspaceId">The specific workspace ID that was used for analysis</param>
public RosetteEvent(String eventType, List<EventMention> mentions, Nullable<double> confidence, string workspaceId)
{
this.EventType = eventType;
this.Mentions = mentions;
this.Confidence = confidence;
this.workspaceId = workspaceId;
}
/// <summary>
/// Equals for RosetteEvent
/// </summary>
/// <param name="other">RosetteEvent</param>
/// <returns></returns>
public bool Equals(RosetteEvent other)
{
return string.Equals(EventType, other.EventType)
&& Mentions.SequenceEqual(other.Mentions)
&& Confidence.Equals(other.Confidence)
&& string.Equals(workspaceId, other.workspaceId);
}
/// <summary>
/// Equals override
/// </summary>
/// <param name="obj">The object to compare against</param>
/// <returns>True if equal</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as RosetteEvent);
}
/// <summary>
/// HashCode override
/// </summary>
/// <returns>The hashcode</returns>
public override int GetHashCode()
{
unchecked
{
var hashCode = (EventType != null ? EventType.GetHashCode() : 0);
hashCode = (hashCode * 401) ^ (Mentions != null ? Mentions.GetHashCode() : 0);
hashCode = (hashCode * 401) ^ (Confidence != null ? Confidence.GetHashCode() : 0);
hashCode = (hashCode * 401) ^ (workspaceId != null ? workspaceId.GetHashCode() : 0);
return hashCode;
}
}
/// <summary>
/// ToString override
/// </summary>
/// <returns>This RosetteEvent in JSON form</returns>
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
}