本文整理汇总了C#中Feature.getRelationshipNeighbor方法的典型用法代码示例。如果您正苦于以下问题:C# Feature.getRelationshipNeighbor方法的具体用法?C# Feature.getRelationshipNeighbor怎么用?C# Feature.getRelationshipNeighbor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feature
的用法示例。
在下文中一共展示了Feature.getRelationshipNeighbor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RelationshipAnalogy
private string RelationshipAnalogy(Feature old, Feature newOld, Feature prevOfCurr, Feature current)
{
string return_message = "";
/*Console.WriteLine("old: " + old.Data);
Console.WriteLine("new: " + newOld.Data);
Console.WriteLine("relationship: " + old.getRelationshipNeighbor(newOld.Data));
Console.WriteLine("previous of current: " + prevOfCurr.Data);
Console.WriteLine("current: " + current.Data);
Console.WriteLine("relationship: " + prevOfCurr.getRelationshipNeighbor(current.Data));
*/
// Senten Patterns list - for 3 nodes
List<string> sentencePatterns = new List<string>();
Random rnd = new Random();
//Define A1, B1, A2, B2, R1,and R2.
// Node A1 has relationship R1 with node B1.
// Node A2 has relaitonship R2 with node B2.
// AND R1 and R2 are in the same list inside equivalent_relationship list.
string a1 = "";
string b1 = "";
string a2 = "";
string b2 = "";
string r1 = "";
string r2 = "";
//Check equivalent and similarity
bool found = false;
bool directional = false;
//Check if the relationship is a directional word.
if (Directional_Words.Contains(old.getRelationshipNeighbor(newOld.Data))
|| Directional_Words.Contains(newOld.getRelationshipNeighbor(old.Data)))
{
directional = true;
}//end if
foreach (List<string> list in equivalent_relationships)
{
if (found == true) break;
if ((list.Contains(old.getRelationshipNeighbor(newOld.Data)) && list.Contains(prevOfCurr.getRelationshipNeighbor(current.Data)))
|| old.getRelationshipNeighbor(newOld.Data).Equals(prevOfCurr.getRelationshipNeighbor(current.Data)))
{
a1 = old.Data;
b1 = newOld.Data;
a2 = prevOfCurr.Data;
b2 = current.Data;
r1 = old.getRelationshipNeighbor(newOld.Data);
r2 = prevOfCurr.getRelationshipNeighbor(current.Data);
found = true;
}
else if ((list.Contains(newOld.getRelationshipNeighbor(old.Data)) && list.Contains(current.getRelationshipNeighbor(prevOfCurr.Data)))
|| newOld.getRelationshipNeighbor(old.Data).Equals(current.getRelationshipNeighbor(prevOfCurr.Data)))
{
a1 = newOld.Data;
b1 = old.Data;
a2 = current.Data;
b2 = prevOfCurr.Data;
r1 = newOld.getRelationshipNeighbor(old.Data);
r2 = current.getRelationshipNeighbor(prevOfCurr.Data);
found = true;
}
else if ((list.Contains(newOld.getRelationshipNeighbor(old.Data)) && list.Contains(prevOfCurr.getRelationshipNeighbor(current.Data)))
|| newOld.getRelationshipNeighbor(old.Data).Equals(prevOfCurr.getRelationshipNeighbor(current.Data)))
{
a1 = newOld.Data;
b1 = old.Data;
a2 = prevOfCurr.Data;
b2 = current.Data;
r1 = newOld.getRelationshipNeighbor(old.Data);
r2 = prevOfCurr.getRelationshipNeighbor(current.Data);
found = true;
}
else if ((list.Contains(old.getRelationshipNeighbor(newOld.Data)) && list.Contains(current.getRelationshipNeighbor(prevOfCurr.Data)))
|| old.getRelationshipNeighbor(newOld.Data).Equals(current.getRelationshipNeighbor(prevOfCurr.Data)))
{
a1 = old.Data;
b1 = newOld.Data;
a2 = current.Data;
b2 = prevOfCurr.Data;
r1 = old.getRelationshipNeighbor(newOld.Data);
r2 = current.getRelationshipNeighbor (prevOfCurr.Data);
found = true;
}
}
//If there is a blank relationship, no analogy may be made.
if (r1.Equals("") || r2.Equals(""))
return "";
//if a1 equals a2 and b1 equals b2, no analogy may be made.
if (a1.Equals(a2) && b1.Equals(b2))
return "";
//If the relationship is directional and b1 does NOT equal b2, then
//no analogy may be made.
if (directional && !(b1.Equals(b2)))
{
return "";
}//end if
//if (old.getRelationshipNeighbor(newOld.Data).Equals(prevOfCurr.getRelationshipNeighbor(current.Data)) &&
//.........这里部分代码省略.........
示例2: LeadingTopic
//optional parameter for_additional_info, if set true, will avoid any actual leading statements
//except for relationship mentions. If no relationship mention can be made, then blank string
//is returned.
private string LeadingTopic(Feature last, Feature first, bool for_additional_info = false)
{
string return_message = "";
string first_data_en = first.Data;
string first_data_cn = first.Data;
if (first.Data.Contains("##"))
{
first_data_en = first.Data.Split(new string[] { "##" }, StringSplitOptions.None)[0];
first_data_cn = first.Data.Split(new string[] { "##" }, StringSplitOptions.None)[1];
}
Console.WriteLine("In LeadingTopic, first_data_en " + first_data_en + " first_data_cn " + first_data_cn);
string last_data_en = last.Data;
string last_data_cn = last.Data;
if (last.Data.Contains("##"))
{
last_data_en = last.Data.Split(new string[] { "##" }, StringSplitOptions.None)[0];
last_data_cn = last.Data.Split(new string[] { "##" }, StringSplitOptions.None)[1];
}
Console.WriteLine("In LeadingTopic, last_data_en " + last_data_en + " last_data_cn " + last_data_cn);
//First is the current node (the one that has just been traversed to)
//A set of possible lead-in statements.
List<string> lead_in_statements = new List<string>();
lead_in_statements.Add("{There's also " + first_data_en + ".} " + "##" + "{还有" + first_data_cn + "呢。} " + "##");
lead_in_statements.Add("{But let's talk about " + first_data_en + ".} " + "##" + "{我们来聊聊" + first_data_cn + "吧。} " + "##");
lead_in_statements.Add("{And have I mentioned " + first_data_en + "?} " + "##" + "{之前我说过" + first_data_cn + "吗?} " + "##");
lead_in_statements.Add("{Now, about " + first_data_en + ".} " + "##" + "{接下来是" + first_data_cn + "。} " + "##");
lead_in_statements.Add("{Now, let's talk about " + first_data_en + ".} " + "##" + "{接着我们说说" + first_data_cn + "吧。} " + "##");
lead_in_statements.Add("{I should touch on " + first_data_en + ".} " + "##" + "{我要谈谈关于" + first_data_cn + "。} " + "##");
lead_in_statements.Add("{Have you heard of " + first_data_en + "?} " + "##" + "{你听说过" + first_data_cn + "吗?} " + "##");
//A set of lead-in statements for non-novel nodes
List<string> non_novel_lead_in_statements = new List<string>();
non_novel_lead_in_statements.Add("{There's also " + first_data_en + ".} " + "##" + "{还有" + first_data_cn + "呢。} " + "##");
non_novel_lead_in_statements.Add("{Let's talk about " + first_data_en + ".} " + "##" + "{我们谈谈" + first_data_cn + "吧。} " + "##");
non_novel_lead_in_statements.Add("{I'll mention " + first_data_en + " real quick.} " + "##" + "{我想简要提提" + first_data_cn + "。} " + "##");
non_novel_lead_in_statements.Add("{So, about " + first_data_en + ".} " + "##" + "{那么,说说" + first_data_cn + "。} " + "##");
non_novel_lead_in_statements.Add("{Now then, about " + first_data_en + ".} " + "##" + "{现在谈谈" + first_data_cn + "吧。} " + "##");
non_novel_lead_in_statements.Add("{Let's talk about " + first_data_en + " for a moment.} " + "##" + "{我们聊一会儿" + first_data_cn + " 吧。} " + "##");
non_novel_lead_in_statements.Add("{Have I mentioned " + first_data_en + "?} " + "##" + "{之前我说过" + first_data_cn + "吗?} " + "##");
non_novel_lead_in_statements.Add("{Now, about " + first_data_en + ".} " + "##" + "{接着是" + first_data_cn + "。} " + "##");
non_novel_lead_in_statements.Add("{Now, let's talk about " + first_data_en + ".} " + "##" + "{现在我们谈谈" + first_data_cn + "吧。} " + "##");
non_novel_lead_in_statements.Add("{I should touch on " + first_data_en + ".} " + "##" + "{我要说说" + first_data_cn + "。} " + "##");
//A set of lead-in statements for novel nodes
//TODO: Author these again; things like let's talk about something different now.
List<string> novel_lead_in_statements = new List<string>();
novel_lead_in_statements.Add("{Let's talk about something different. " + "##" + "{我们聊点别的吧。" + "##");
novel_lead_in_statements.Add("{Let's talk about something else. " + "##" + "{我们说点其他的吧。" + "##");
novel_lead_in_statements.Add("{Let's switch gears. " + "##" + "{我们换个话题吧。" + "##");
Random rand = new Random();
// Check if there is a relationship between two nodes
if (last.getNeighbor(first.Data) != null || first.getNeighbor(last.Data) != null)
{
string relationship_neighbor_en = last.getRelationshipNeighbor(first.Data);
string relationship_neighbor_cn = last.getRelationshipNeighbor(first.Data);
string relationship_parent_en = last.getRelationshipParent(first.Data);
string relationship_parent_cn = last.getRelationshipParent(first.Data);
Console.WriteLine("In LeadingTopic, relationship_neighbor_en " + relationship_neighbor_en + " relationship_neighbor_cn " + relationship_neighbor_cn);
if (relationship_neighbor_en.Contains("##"))
{
relationship_neighbor_en = relationship_neighbor_en.Split(new string[] { "##" }, StringSplitOptions.None)[0];
relationship_neighbor_cn = relationship_neighbor_cn.Split(new string[] { "##" }, StringSplitOptions.None)[1];
}
if (relationship_parent_en.Contains("##"))
{
relationship_parent_en = relationship_parent_en.Split(new string[] { "##" }, StringSplitOptions.None)[0];
relationship_parent_cn = relationship_parent_cn.Split(new string[] { "##" }, StringSplitOptions.None)[1];
}//end if
// Check if last has first as its neighbor
if (!last.getRelationshipNeighbor (first.Data).Equals("")
&& !(last.getRelationshipNeighbor (first.Data) == null))
{
return_message = "{" + last_data_en + " " + relationship_neighbor_en + " "
+ first_data_en + ".} " + "##" + "{" + last_data_cn + " " + relationship_neighbor_cn + " "
+ first_data_cn + ".} " + "##";
return return_message;
}//end if
// If last is a child node of first (first is a parent of last)
else if (!last.getRelationshipParent (first.Data).Equals("")
&& !(last.getRelationshipParent(first.Data) == null))
{
return_message = "{" + last_data_en + " " + relationship_parent_en + " "
+ first_data_en + ".} " + "##" + "{" + last_data_cn + " " + relationship_parent_cn + " "
+ first_data_cn + ".} " + "##";
return return_message;
}//end else if
}//end if
//.........这里部分代码省略.........