public NRCRecord FindRecord(WordEx word) { if (!loaded) { throw new InvalidOperationException("Not loaded"); } NRCRecord nrcRecord = null; foreach (var text in word.GetPossibleText()) { nrcRecord = FindRecord(text); if (nrcRecord != null) { break; } } if (nrcRecord == null) { return(null); } nrcRecord = (NRCRecord)nrcRecord.Clone(); if (word.IsInverted) { nrcRecord.Invert(); } return(nrcRecord); }
public object Clone() { NRCRecord record = new NRCRecord(Word); record.IsAnger = IsAnger; record.IsAnticipation = IsAnticipation; record.IsDisgust = IsDisgust; record.IsFear = IsFear; record.IsJoy = IsJoy; record.IsNegative = IsNegative; record.IsPositive = IsPositive; record.IsSadness = IsSadness; record.IsSurprise = IsSurprise; record.IsTrust = IsTrust; return(record); }
private void ReadDataFromInternalStream(IDictionaryStream stream) { int index = 0; foreach (var record in stream.ReadDataFromStream(int.Parse)) { if (!table.TryGetValue(record.Item1, out var nrcRecord)) { nrcRecord = new NRCRecord(record.Item1); table[record.Item1] = nrcRecord; index = 0; } index++; if (record.Item2 == 0) { continue; } switch (index) { case 1: nrcRecord.IsAnger = true; break; case 2: nrcRecord.IsAnticipation = true; break; case 3: nrcRecord.IsDisgust = true; break; case 4: nrcRecord.IsFear = true; break; case 5: nrcRecord.IsJoy = true; break; case 6: nrcRecord.IsNegative = true; break; case 7: nrcRecord.IsPositive = true; break; case 8: nrcRecord.IsSadness = true; break; case 9: nrcRecord.IsSurprise = true; break; case 10: nrcRecord.IsTrust = true; break; default: throw new ArgumentOutOfRangeException("index", index.ToString()); } } }
public void ExtractData(NRCRecord record) { Interlocked.Increment(ref total); if (record == null) { return; } bool added = false; if (record.IsAnger) { added = true; Interlocked.Increment(ref anger); } if (record.IsAnticipation) { added = true; Interlocked.Increment(ref anticipation); } if (record.IsDisgust) { added = true; Interlocked.Increment(ref disgust); } if (record.IsFear) { added = true; Interlocked.Increment(ref fear); } if (record.IsJoy) { added = true; Interlocked.Increment(ref joy); } if (record.IsSadness) { added = true; Interlocked.Increment(ref sadness); } if (record.IsSurprise) { added = true; Interlocked.Increment(ref surprise); } if (record.IsTrust) { added = true; Interlocked.Increment(ref trust); } if (added) { Interlocked.Increment(ref totalSentiment); } }