Mention
Namespace:
DocumentFormat.OpenXml
We found 10 examples in language CSharp for this search.
You will see 39 fragments of code.
Other methods
Other methods
Project:Banco-Bahia-Bot
File:MoneyCommands.cs
Examples:1
[SlashCommand("atm", "Mostra o seu dinheiro ou o de outro usuário")]
public async Task AtmCommand([Summary("user")]IGuildUser mention = null)
{
var discordUser = (IUser)mention ?? Context.User;
if (discordUser.IsBot) return;
User user = UserHandler.GetUser(discordUser.Id);
string reply = $"{discordUser.Mention} tem ${user.money}!";
await RespondAsync(reply, ephemeral: true);
}
Project:Bot
File:MentionTests.cs
Examples:1
[Fact]
public void MentionInitsWithNoArgs()
{
var mention = new Mention();
Assert.NotNull(mention);
Assert.IsType<Mention>(mention);
}
Project:ReviewBot
File:ActivityExtensions.cs
Examples:2
public static IList<Mention> GetUniqueMentionsExceptRecipient(this IMessageActivity activity)
{
return activity.GetMentions()
.Where(m => m.Mentioned.Id != activity.Recipient.Id)
.DistinctBy(m => m.Mentioned.Id)
.ToList();
}
[CanBeNull]
public static Mention GetRecipientMention(this IMessageActivity activity)
{
return activity.GetMentions().FirstOrDefault(m => m.Mentioned.Id == activity.Recipient.Id);
}
Project:BotBuilder-MicrosoftTeams-dotnet
File:MentionTests.cs
Examples:6
/// <summary>
/// @Mention tests with no mention text.
/// </summary>
/// <returns>Task tracking operation.</returns>
[TestMethod]
public async Task AddMention_NoMentionTextAsync()
{
Activity sampleActivity = JsonConvert.DeserializeObject<Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));
await TestHelpers.RunTestPipelineWithActivityAsync(
sampleActivity,
(teamsContext) =>
{
Activity reply = sampleActivity.CreateReply();
reply = teamsContext.AddMentionToText(reply, sampleActivity.From);
Assert.IsTrue(reply.Entities.Count == 1);
Assert.IsInstanceOfType(reply.Entities[0], typeof(Mention));
Assert.IsTrue(reply.Text.Contains((reply.Entities[0] as Mention).Text));
Assert.IsTrue((reply.Entities[0] as Mention).Text.Contains("<at>"));
Assert.IsTrue((reply.Entities[0] as Mention).Text == "<at>" + (reply.Entities[0] as Mention).Mentioned.Name + "</at>");
Assert.IsTrue((reply.Entities[0] as Mention).Text.EndsWith("</at>"));
return Task.CompletedTask;
}).ConfigureAwait(false);
}
/// <summary>
/// @Mention tests with mention text.
/// </summary>
/// <returns>Task tracking operations.</returns>
[TestMethod]
public async Task AddMention_WithMentionTextAsync()
{
Activity sampleActivity = JsonConvert.DeserializeObject<Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));
await TestHelpers.RunTestPipelineWithActivityAsync(
sampleActivity,
(teamsContext) =>
{
Activity reply = sampleActivity.CreateReply();
reply = teamsContext.AddMentionToText(reply, sampleActivity.From, mentionText: "SampleName");
Assert.IsTrue(reply.Entities.Count == 1);
Assert.IsInstanceOfType(reply.Entities[0], typeof(Mention));
Assert.IsTrue(reply.Text.Contains((reply.Entities[0] as Mention).Text));
Assert.IsTrue((reply.Entities[0] as Mention).Text.Contains("SampleName"));
Assert.IsTrue((reply.Entities[0] as Mention).Text == "<at>" + (reply.Entities[0] as Mention).Mentioned.Name + "</at>");
Assert.IsTrue((reply.Entities[0] as Mention).Text.StartsWith("<at>"));
return Task.CompletedTask;
}).ConfigureAwait(false);
}
/// <summary>
/// @Mention tests with no mention text and no username. Expects exception.
/// </summary>
/// <returns>Task tracking operation.</returns>
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public async Task AddMention_WithNoMentionTextAndNoChannelAccountNameAsync()
{
Activity sampleActivity = JsonConvert.DeserializeObject<Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));
await TestHelpers.RunTestPipelineWithActivityAsync(
sampleActivity,
(teamsContext) =>
{
Activity reply = sampleActivity.CreateReply();
reply = teamsContext.AddMentionToText(
reply, new ChannelAccount
{
Id = sampleActivity.From.Id,
});
return Task.CompletedTask;
}).ConfigureAwait(false);
}
/// <summary>
/// @Mention tests with entities instantiated to null (new Activity case).
/// </summary>
/// <returns>Task tracking operation.</returns>
[TestMethod]
public async Task AddMention_WithEntitiesAsNullAsync()
{
Activity sampleActivity = JsonConvert.DeserializeObject<Activity>(File.ReadAllText(@"Jsons\SampleActivityAtMention.json"));
await TestHelpers.RunTestPipelineWithActivityAsync(
sampleActivity,
(teamsContext) =>
{
Activity reply = sampleActivity.CreateReply();
reply.Entities = null;
reply = teamsContext.AddMentionToText(reply, sampleActivity.From);
Assert.IsTrue(reply.Entities.Count == 1);
Assert.IsInstanceOfType(reply.Entities[0], typeof(Mention));
Assert.IsTrue(reply.Text.Contains((reply.Entities[0] as Mention).Text));
Assert.IsTrue((reply.Entities[0] as Mention).Text == "<at>" + (reply.Entities[0] as Mention).Mentioned.Name + "</at>");
return Task.CompletedTask;
}).ConfigureAwait(false);
}
/// <summary>
/// Activity extensions tests for strip mentions with mentions in it.
/// </summary>
/// <returns>Task tracking operation.</returns>
[TestMethod]
public async Task RemoveMentions_StripMentionsWithMentionsInItAsync()
{
Activity sampleActivity = JsonConvert.DeserializeObject<Activity>(File.ReadAllText(@"Jsons\SampleActivity2AtMentions.json"));
await TestHelpers.RunTestPipelineWithActivityAsync(
sampleActivity,
(teamsContext) =>
{
string noMentionText = teamsContext.GetActivityTextWithoutMentions();
Assert.IsTrue(sampleActivity.Text.Contains(noMentionText));
Assert.AreEqual("TestMessage", noMentionText);
return Task.CompletedTask;
}).ConfigureAwait(false);
}
/// <summary>
/// Test to removes mentions from activity with no mentions.
/// </summary>
/// <returns>Task tracking operation.</returns>
[TestMethod]
public async Task RemoveMentions_StripMentionsWithNoMentionsAsync()
{
Activity sampleActivity = JsonConvert.DeserializeObject<Activity>(File.ReadAllText(@"Jsons\SampleActivityNoMentions.json"));
await TestHelpers.RunTestPipelineWithActivityAsync(
sampleActivity,
(teamsContext) =>
{
string noMentionText = teamsContext.GetActivityTextWithoutMentions();
Assert.IsTrue(sampleActivity.Text.Contains(noMentionText));
Assert.AreEqual(sampleActivity.Text, noMentionText);
return Task.CompletedTask;
}).ConfigureAwait(false);
}
Project:Bot
File:ChannelMentionEntityRecognizer.cs
Examples:1
/// <inheritdoc/>
public override Task<RecognizerResult> RecognizeAsync(DialogContext dialogContext, Activity activity, CancellationToken cancellationToken = default, Dictionary<string, string> telemetryProperties = null, Dictionary<string, double> telemetryMetrics = null)
{
var result = new RecognizerResult();
// promote external mention entities from the activity into recognizer result
if (activity.Entities != null)
{
if (result.Entities == null)
{
result.Entities = new JObject();
}
dynamic entities = result.Entities;
// convert activity.entities entity that looks like this:
// {
// "type": "mention",
// "mentioned": {
// "id": "28:0047c760-1f42-4a78-b1bd-9ecd95ec3615",
// "name": "Tess"
// },
// "text": "<at>Tess</at>"
// },
int iStart = 0;
foreach (dynamic entity in activity.Entities.Where(e => e.Type == "mention").Select(e => JObject.FromObject(e)))
{
// into recognizeresult that looks like this:
// "entities": {
// "channelMention": [
// {
// "id": "28:0047c760-1f42-4a78-b1bd-9ecd95ec3615"
// "name":"Tess"
// }
// ],
// "$instance": {
// "channelMention": [
// {
// "startIndex": 10,
// "endIndex": 14,
// "score": 1.0,
// "text": "tess"
// }
// ]
// }
// }
if (entities.channelMention == null)
{
entities.channelMention = new JArray();
}
entities.channelMention.Add(entity.mentioned);
dynamic instance = entities["$instance"];
if (instance == null)
{
instance = new JObject();
entities["$instance"] = instance;
}
if (instance.channelMention == null)
{
instance.channelMention = new JArray();
}
string mentionedText = (string)entity.text;
iStart = activity.Text.IndexOf(mentionedText, iStart, System.StringComparison.InvariantCulture);
if (iStart >= 0)
{
dynamic mentionData = new JObject();
mentionData.startIndex = iStart;
mentionData.endIndex = iStart + mentionedText.Length;
mentionData.text = mentionedText;
mentionData.score = 1.0;
instance.channelMention.Add(mentionData);
// note, we increment so next pass through continues after the token we just processed.
iStart++;
}
}
}
return Task.FromResult(result);
}
Project:VirastarE
File:AbstractResolver.cs
Examples:6
/// <summary>
/// Returns the number of previous entities that resolver should consider.
/// </summary>
/// <returns>
/// the number of previous entities that resolver should consider.
/// </returns>
protected internal virtual int GetNumberEntitiesBack()
{
return mNumberEntitiesBack;
}
/// <summary>
/// The number of entites that should be considered for resolution with the specified discourse model.
/// </summary>
/// <param name="discourseModel">
/// The discourse model.
/// </param>
/// <returns>
/// number of entites that should be considered for resolution.
/// </returns>
protected internal virtual int GetNumberEntitiesBack(DiscourseModel discourseModel)
{
return System.Math.Min(discourseModel.EntityCount, mNumberEntitiesBack);
}
/// <summary>
/// Returns the head parse for the specified mention.
/// </summary>
/// <param name="mention">
/// The mention.
/// </param>
/// <returns>
/// the head parse for the specified mention.
/// </returns>
protected internal virtual Mention.IParse GetHead(Mention.MentionContext mention)
{
return mention.HeadTokenParse;
}
/// <summary>
/// Returns the index for the head word for the specified mention.
/// </summary>
/// <param name="mention">
/// The mention.
/// </param>
/// <returns>
/// the index for the head word for the specified mention.
/// </returns>
protected internal virtual int GetHeadIndex(Mention.MentionContext mention)
{
Mention.IParse[] mentionTokens = mention.TokenParses;
for (int currentToken = mentionTokens.Length - 1; currentToken >= 0; currentToken--)
{
Mention.IParse token = mentionTokens[currentToken];
if (token.SyntacticType != PartsOfSpeech.PossessiveEnding
&& token.SyntacticType != PartsOfSpeech.Comma
&& token.SyntacticType != PartsOfSpeech.SentenceFinalPunctuation)
{
return currentToken;
}
}
return mentionTokens.Length - 1;
}
/// <summary>
/// Returns the text of the head word for the specified mention.
/// </summary>
/// <param name="mention">
/// The mention.
/// </param>
/// <returns>
/// The text of the head word for the specified mention.
/// </returns>
protected internal virtual string GetHeadString(Mention.MentionContext mention)
{
return mention.HeadTokenText.ToLower();
}
/// <summary>
/// Determines if the specified entity is too far from the specified mention to be resolved to it.
/// Once an entity has been determined to be out of range subsequent entities are not considered.
/// </summary>
/// <seealso cref="IsExcluded">
/// </seealso>
/// <param name="mention">
/// The mention which is being considered.
/// </param>
/// <param name="entity">
/// The entity to which the mention is to be resolved.
/// </param>
/// <returns>
/// true is the entity is in range of the mention, false otherwise.
/// </returns>
protected internal virtual bool IsOutOfRange(Mention.MentionContext mention, DiscourseEntity entity)
{
return false;
}
Project:VirastarE
File:AbstractLinker.cs
Examples:6
/// <summary>
/// Removes the specified mention to an entity in the specified discourse model or creates a new entity for the mention.
/// </summary>
/// <param name="mention">
/// The mention to resolve.
/// </param>
/// <param name="discourseModel">
/// The discourse model of existing entities.
/// </param>
protected internal virtual void Resolve(MentionContext mention, DiscourseModel discourseModel)
{
bool validEntity = true; // true if we should add this entity to the dm
bool canResolve = false;
for (int currentResolver = 0; currentResolver < mResolvers.Length; currentResolver++)
{
if (mResolvers[currentResolver].CanResolve(mention))
{
if (mMode == LinkerMode.Test)
{
mEntities[currentResolver] = mResolvers[currentResolver].Resolve(mention, discourseModel);
canResolve = true;
}
else if (mMode == LinkerMode.Train)
{
mEntities[currentResolver] = mResolvers[currentResolver].Retain(mention, discourseModel);
if (currentResolver + 1 != mResolvers.Length)
{
canResolve = true;
}
}
else if (mMode == LinkerMode.Eval)
{
mEntities[currentResolver] = mResolvers[currentResolver].Retain(mention, discourseModel);
//DiscourseEntity rde = resolvers[ri].resolve(mention, discourseModel);
//eval.update(rde == entities[ri], ri, entities[ri], rde);
}
else
{
System.Console.Error.WriteLine("AbstractLinker.Unknown mode: " + mMode);
}
if (currentResolver == mSingularPronounIndex && mEntities[currentResolver] == null)
{
validEntity = false;
}
}
else
{
mEntities[currentResolver] = null;
}
}
if (!canResolve && mRemoveUnresolvedMentions)
{
validEntity = false;
}
DiscourseEntity discourseEntity = CheckForMerges(discourseModel, mEntities);
if (validEntity)
{
UpdateExtent(discourseModel, mention, discourseEntity, mUseDiscourseModel);
}
}
/// <summary>
/// Updates the specified discourse model with the specified mention as coreferent with the specified entity.
/// </summary>
/// <param name="discourseModel">
/// The discourse model
/// </param>
/// <param name="mention">
/// The mention to be added to the specified entity.
/// </param>
/// <param name="entity">
/// The entity which is mentioned by the specified mention.
/// </param>
/// <param name="useDiscourseModel">
/// Whether the mentions should be kept as an entiy or simply co-indexed.
/// </param>
protected internal virtual void UpdateExtent(DiscourseModel discourseModel, MentionContext mention, DiscourseEntity entity, bool useDiscourseModel)
{
if (useDiscourseModel)
{
if (entity != null)
{
if (entity.GenderProbability < mention.GenderProbability)
{
entity.Gender = mention.GetGender();
entity.GenderProbability = mention.GenderProbability;
}
if (entity.NumberProbability < mention.NumberProbability)
{
entity.Number = mention.GetNumber();
entity.NumberProbability = mention.NumberProbability;
}
entity.AddMention(mention);
discourseModel.MentionEntity(entity);
}
else
{
entity = new DiscourseEntity(mention, mention.GetGender(), mention.GenderProbability, mention.GetNumber(), mention.NumberProbability);
discourseModel.AddEntity(entity);
}
}
else
{
if (entity != null)
{
var newEntity = new DiscourseEntity(mention, mention.GetGender(), mention.GenderProbability, mention.GetNumber(), mention.NumberProbability);
discourseModel.AddEntity(newEntity);
newEntity.Id = entity.Id;
}
else
{
var newEntity = new DiscourseEntity(mention, mention.GetGender(), mention.GenderProbability, mention.GetNumber(), mention.NumberProbability);
discourseModel.AddEntity(newEntity);
}
}
}
protected internal virtual DiscourseEntity CheckForMerges(DiscourseModel discourseModel, DiscourseEntity[] discourseEntities)
{
DiscourseEntity firstDiscourseEntity = discourseEntities[0];
for (int discourseEntityIndex = 1; discourseEntityIndex < discourseEntities.Length; discourseEntityIndex++)
{
DiscourseEntity secondDiscourseEntity = discourseEntities[discourseEntityIndex]; //temporary variable
if (secondDiscourseEntity != null)
{
if (firstDiscourseEntity != null && firstDiscourseEntity != secondDiscourseEntity)
{
discourseModel.MergeEntities(firstDiscourseEntity, secondDiscourseEntity, 1);
}
else
{
firstDiscourseEntity = secondDiscourseEntity;
}
}
}
return firstDiscourseEntity;
}
public virtual DiscourseEntity[] GetEntitiesFromMentions(Mention.Mention[] mentions)
{
MentionContext[] extentContexts = ConstructMentionContexts(mentions);
var discourseModel = new DiscourseModel();
for (int extentIndex = 0; extentIndex < extentContexts.Length; extentIndex++)
{
Resolve(extentContexts[extentIndex], discourseModel);
}
return discourseModel.Entities;
}
public virtual void SetEntitiesFromMentions(Mention.Mention[] mentions)
{
GetEntitiesFromMentions(mentions);
}
public virtual void Train()
{
for (int resolverIndex = 0; resolverIndex < mResolvers.Length; resolverIndex++)
{
mResolvers[resolverIndex].Train();
}
}
Project:CreatioTest
File:SocialMentionSearchRuleEntityRepository.ESN.cs
Examples:4
#endregion
#region Methods: Protected
/// <summary>
/// Selects <see cref="SocialMentionSearchRule"/> data
/// and creates <see cref="SocialMentionSearchRuleEntity"/> collection.
/// </summary>
/// <returns><see cref="SocialMentionSearchRuleEntity"/> collection.</returns>
protected List<SocialMentionSearchRuleEntity> GetSocialMentionSearchRules() {
var rules = new List<SocialMentionSearchRuleEntity>();
var pagesSelect = GetSocialMentionSearchRulesSelect();
using (DBExecutor dbExecutor = UserConnection.EnsureDBConnection()) {
using (IDataReader dataReader = pagesSelect.ExecuteReader(dbExecutor)) {
while (dataReader.Read()) {
rules.AddIfNotExists(CreateSocialMentionSearchRuleEntityInstance(dataReader));
}
}
}
return rules;
}
/// <summary>
/// Returns new <see cref="SocialMentionSearchRuleEntity"/> instance, using information
/// from <paramref name="dataReader"/>.
/// </summary>
/// <param name="dataReader"><see cref="IDataReader"/> implementation instance.</param>
/// <returns><see cref="SocialMentionSearchRuleEntity"/> instance.</returns>
private SocialMentionSearchRuleEntity CreateSocialMentionSearchRuleEntityInstance(IDataReader dataReader) {
string entitySchema = dataReader.GetColumnValue<string>("EntitySchema");
string filterByColumn = dataReader.GetColumnValue<string>("FilterByColumn");
string userColumn = dataReader.GetColumnValue<string>("UserColumn");
var rule = new SocialMentionSearchRuleEntity(UserConnection, entitySchema, filterByColumn, userColumn);
return rule;
}
/// <summary>
/// Returns <see cref="SocialMentionSearchRule"/> data select.
/// </summary>
/// <returns><see cref="Select"/> instance.</returns>
protected Select GetSocialMentionSearchRulesSelect() {
var mentionSelect =
new Select(UserConnection).Distinct()
.Column("EntitySchema")
.Column("FilterByColumn")
.Column("UserColumn")
.From("SocialMentionSearchRule");
return mentionSelect;
}
#endregion
#region Methods: Public
/// <summary>
/// Returns <see cref="ContactForMention"/> instance collection using rules
/// from "User mention search rules" lookup.
/// </summary>
/// <param name="searchName">Part of <see cref="Contact"/> name that will be used to filter result list.</param>
/// <returns><see cref="ContactForMention"/> instance collection.</returns>
public List<ContactForMention> GetContactsForMentionByRules(string searchName) {
var contacts = new List<ContactForMention>();
var rules = GetSocialMentionSearchRules();
foreach (SocialMentionSearchRuleEntity rule in rules) {
contacts.AddRangeIfNotExists(rule.GetSocialMentionSearchRuleContacts(searchName));
if (contacts.Count >= ESNFeedModuleService.MentionContactsPageSize) {
break;
}
}
return contacts;
}
Project:lightbus
File:UserMention.xaml.cs
Examples:6
#endregion
#region Private Events
// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void hbImageViewer_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton tmpLinkButton = (HyperlinkButton)sender;
MentionList MentionItem = (MentionList)tmpLinkButton.DataContext;
if (MentionItem != null)
{
imageViewerChildWindow = new ImageViewerChildWindow(MentionItem.UsersItem.FriendName, MentionItem.MiddleSizePic, MentionItem.OriginalSizePic);
imageViewerChildWindow.Show();
}
}
private void hbretweetImageViewer_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton tmpLinkButton = (HyperlinkButton)sender;
MentionList MentionItem = (MentionList)tmpLinkButton.DataContext;
if (MentionItem != null)
{
imageViewerChildWindow = new ImageViewerChildWindow(MentionItem.UsersItem.FriendName, MentionItem.RetweeterItem.MiddleImageURL, MentionItem.RetweeterItem.OriginalImageURL);
imageViewerChildWindow.Show();
}
}
private void everyFiveSeconds_Tick(object sender, EventArgs e)
{
if (Globals.MentionCount != "0")
{
GetMention();
}
}
private void btComment_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton tmpButton = (HyperlinkButton)sender;
MentionList MentionItem = (MentionList)tmpButton.DataContext;
if (MentionItem != null)
{
userCommentChildWindow = new UserCommentChildWindow(MentionItem.FriendTwitterID);
userCommentChildWindow.Show();
}
}
private void btRepost_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton tmpButton = (HyperlinkButton)sender;
MentionList MentionItem = (MentionList)tmpButton.DataContext;
if (MentionItem != null)
{
userMentionChildWindow = new UserMentionChildWindow(MentionItem.FriendTwitterID);
userMentionChildWindow.Show();
}
}
Project:VirastarE
File:MaximumEntropyResolver.cs
Examples:6
public override DiscourseEntity Resolve(Mention.MentionContext expression, DiscourseModel discourseModel)
{
DiscourseEntity discourseEntity;
int entityIndex = 0;
double nonReferentialProbability = NonReferentialResolver.GetNonReferentialProbability(expression);
if (DebugOn)
{
System.Console.Error.WriteLine(this.ToString() + ".resolve: " + expression.ToText() + " -> " + "null " + nonReferentialProbability);
}
for (; entityIndex < GetNumberEntitiesBack(discourseModel); entityIndex++)
{
discourseEntity = discourseModel.GetEntity(entityIndex);
if (IsOutOfRange(expression, discourseEntity))
{
break;
}
if (IsExcluded(expression, discourseEntity))
{
_candidateProbabilities[entityIndex] = 0;
if (DebugOn)
{
Console.Error.WriteLine("excluded " + this.ToString() + ".resolve: " + expression.ToText() + " -> " + discourseEntity + " " + _candidateProbabilities[entityIndex]);
}
}
else
{
string[] features = GetFeatures(expression, discourseEntity).ToArray();
try
{
_candidateProbabilities[entityIndex] = _model.Evaluate(features)[_sameIndex];
}
catch (IndexOutOfRangeException)
{
_candidateProbabilities[entityIndex] = 0;
}
if (DebugOn)
{
Console.Error.WriteLine(this + ".resolve: " + expression.ToText() + " -> " + discourseEntity + " (" + expression.GetGender() + "," + discourseEntity.Gender + ") " + _candidateProbabilities[entityIndex] + " " + string.Join(",", features)); //SupportClass.CollectionToString(lfeatures));
}
}
if (PreferFirstReferent && _candidateProbabilities[entityIndex] > nonReferentialProbability)
{
entityIndex++; //update for nonRef assignment
break;
}
}
_candidateProbabilities[entityIndex] = nonReferentialProbability;
// find max
int maximumCandidateIndex = 0;
for (int currentCandidate = 1; currentCandidate <= entityIndex; currentCandidate++)
{
if (_candidateProbabilities[currentCandidate] > _candidateProbabilities[maximumCandidateIndex])
{
maximumCandidateIndex = currentCandidate;
}
}
if (maximumCandidateIndex == entityIndex)
{
// no referent
return null;
}
else
{
discourseEntity = discourseModel.GetEntity(maximumCandidateIndex);
return discourseEntity;
}
}
/*
protected double getNonReferentialProbability(MentionContext ec) {
if (useFixedNonReferentialProbability) {
return fixedNonReferentialProbability;
}
List lfeatures = getFeatures(ec, null);
string[] features = (string[]) lfeatures.toArray(new string[lfeatures.size()]);
double[] dist = nrModel.eval(features);
return (dist[nrSameIndex]);
}
*/
/// <summary>
/// Returns whether the specified entity satisfies the criteria for being a default referent.
/// This criteria is used to perform sample selection on the training data and to select a single
/// non-referent entity. Typically the criteria is a hueristic for a likely referent.
/// </summary>
/// <param name="discourseEntity">
/// The discourse entity being considered for non-reference.
/// </param>
/// <returns>
/// True if the entity should be used as a default referent, false otherwise.
/// </returns>
protected internal virtual bool defaultReferent(DiscourseEntity discourseEntity)
{
Mention.MentionContext entityContext = discourseEntity.LastExtent;
if (entityContext.NounPhraseSentenceIndex == 0)
{
return true;
}
return false;
}
public override DiscourseEntity Retain(Mention.MentionContext mention, DiscourseModel discourseModel)
{
if (_resolverMode == ResolverMode.Train)
{
DiscourseEntity discourseEntity = null;
bool referentFound = false;
bool hasReferentialCandidate = false;
bool nonReferentFound = false;
for (int entityIndex = 0; entityIndex < GetNumberEntitiesBack(discourseModel); entityIndex++)
{
DiscourseEntity currentDiscourseEntity = discourseModel.GetEntity(entityIndex);
Mention.MentionContext entityMention = currentDiscourseEntity.LastExtent;
if (IsOutOfRange(mention, currentDiscourseEntity))
{
break;
}
if (IsExcluded(mention, currentDiscourseEntity))
{
if (ShowExclusions)
{
if (mention.Id != -1 && entityMention.Id == mention.Id)
{
System.Console.Error.WriteLine(this + ".retain: Referent excluded: (" + mention.Id + ") " + mention.ToText() + " " + mention.IndexSpan + " -> (" + entityMention.Id + ") " + entityMention.ToText() + " " + entityMention.Span + " " + this);
}
}
}
else
{
hasReferentialCandidate = true;
bool useAsDifferentExample = defaultReferent(currentDiscourseEntity);
//if (!sampleSelection || (mention.getId() != -1 && entityMention.getId() == mention.getId()) || (!nonReferentFound && useAsDifferentExample)) {
List<string> features = GetFeatures(mention, currentDiscourseEntity);
//add Event to Model
if (DebugOn)
{
Console.Error.WriteLine(this + ".retain: " + mention.Id + " " + mention.ToText() + " -> " + entityMention.Id + " " + currentDiscourseEntity);
}
if (mention.Id != -1 && entityMention.Id == mention.Id)
{
referentFound = true;
_events.Add(new SharpEntropy.TrainingEvent(Same, features.ToArray()));
discourseEntity = currentDiscourseEntity;
Distances.Add(entityIndex);
}
else if (!PairedSampleSelection || (!nonReferentFound && useAsDifferentExample))
{
nonReferentFound = true;
_events.Add(new SharpEntropy.TrainingEvent(Diff, features.ToArray()));
}
//}
}
if (PairedSampleSelection && referentFound && nonReferentFound)
{
break;
}
if (PreferFirstReferent && referentFound)
{
break;
}
}
// doesn't refer to anything
if (hasReferentialCandidate)
{
NonReferentialResolver.AddEvent(mention);
}
return discourseEntity;
}
else
{
return base.Retain(mention, discourseModel);
}
}
protected internal virtual string GetMentionCountFeature(DiscourseEntity discourseEntity)
{
if (discourseEntity.MentionCount >= 5)
{
return ("mc=5+");
}
else
{
return ("mc=" + discourseEntity.MentionCount);
}
}
/// <summary>
/// Returns a list of features for deciding whether the specified mention refers to the specified discourse entity.
/// </summary>
/// <param name="mention">
/// the mention being considers as possibly referential.
/// </param>
/// <param name="entity">
/// The discourse entity with which the mention is being considered referential.
/// </param>
/// <returns>
/// a list of features used to predict reference between the specified mention and entity.
/// </returns>
protected internal virtual List<string> GetFeatures(Mention.MentionContext mention, DiscourseEntity entity)
{
List<string> features = new List<string>();
features.Add(Default);
features.AddRange(GetCompatibilityFeatures(mention, entity));
return features;
}
public override void Train()
{
if (_resolverMode == ResolverMode.Train)
{
if (DebugOn)
{
System.Console.Error.WriteLine(this.ToString() + " referential");
using (var writer = new System.IO.StreamWriter(_modelName + ".events", false, System.Text.Encoding.Default))
{
foreach (SharpEntropy.TrainingEvent e in _events)
{
writer.Write(e.ToString() + "\n");
}
writer.Close();
}
}
var trainer = new SharpEntropy.GisTrainer();
trainer.TrainModel(new Util.CollectionEventReader(_events), 100, 10);
new BinaryGisModelWriter().Persist(new SharpEntropy.GisModel(trainer), _modelName + ModelExtension);
NonReferentialResolver.Train();
}
}
DocumentFormat.OpenXml.Office2019.Excel.ThreadedComments.Mention : IEnumerable
Constructors :
public Mention()Methods :
public StringValue get_MentionpersonId()public Void set_MentionpersonId(StringValue value = )
public StringValue get_MentionId()
public Void set_MentionId(StringValue value = )
public UInt32Value get_StartIndex()
public Void set_StartIndex(UInt32Value value = )
public UInt32Value get_Length()
public Void set_Length(UInt32Value value = )
public OpenXmlElement CloneNode(Boolean deep = )
public Boolean get_HasChildren()
public String get_InnerXml()
public Void set_InnerXml(String value = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_InnerText()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T oldChild = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()