本文整理汇总了C#中Annotation类的典型用法代码示例。如果您正苦于以下问题:C# Annotation类的具体用法?C# Annotation怎么用?C# Annotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Annotation类属于命名空间,在下文中一共展示了Annotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Analyze
/// <summary>
/// Executes Sentiment and EntitiesMentioned analysis.
/// </summary>
public IOutcome<AnalysisResult> Analyze(StanfordCoreNLP pipeline, string text)
{
//Create annotated document
Annotation doc = new Annotation(text);
pipeline.annotate(doc);
//Validate
var sentences = doc.get(typeof(CoreAnnotations.SentencesAnnotation));
if (sentences == null)
return Outcomes.Outcomes
.Failure<AnalysisResult>()
.WithMessage("No sentences detected.");
//Analyze
var result = new AnalysisResult()
{
Sentiment = GetSentiment((ArrayList)sentences),
MentionedEntities = GetMentions(doc)
};
return Outcomes.Outcomes
.Success<AnalysisResult>()
.WithValue(result);
}
示例2: ShowDialog
/// <summary>
/// Prompts the user to edit an annotation.
/// </summary>
public Annotation ShowDialog(Session session, Annotation annotation, string caption)
{
if (caption != null)
{
this.Text = caption;
}
m_session = session;
if (annotation == null)
{
annotation = new Annotation();
annotation.AnnotationTime = DateTime.UtcNow;
annotation.UserName = Environment.GetEnvironmentVariable("USERNAME");
annotation.Message = "<insert your message here>";
}
AnnotationTimeDP.Value = annotation.AnnotationTime;
UserNameTB.Text = annotation.UserName;
CommentTB.Text = annotation.Message;
if (ShowDialog() != DialogResult.OK)
{
return null;
}
annotation = new Annotation();
annotation.AnnotationTime = AnnotationTimeDP.Value;
annotation.UserName = UserNameTB.Text;
annotation.Message = CommentTB.Text;
return annotation;
}
示例3: GetInstance
/// <summary>
/// Creates a <c>Parameter</c> using the provided constructor
/// and the XML annotation. The parameter produced contains all
/// information related to the constructor parameter. It knows the
/// name of the XML entity, as well as the type.
/// </summary>
/// <param name="method">
/// this is the constructor the parameter exists in
/// </param>
/// <param name="label">
/// represents the XML annotation for the contact
/// </param>
/// <returns>
/// returns the parameter instantiated for the field
/// </returns>
public Parameter GetInstance(Constructor method, Annotation label, int index) {
Constructor factory = GetConstructor(label);
if(!factory.isAccessible()) {
factory.setAccessible(true);
}
return (Parameter)factory.newInstance(method, label, index);
}
示例4: StanfordCoreNlpDemoThatChangeCurrentDirectory
public void StanfordCoreNlpDemoThatChangeCurrentDirectory()
{
const string Text = "Kosgi Santosh sent an email to Stanford University. He didn't get a reply.";
// Annotation pipeline configuration
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.setProperty("sutime.binders", "0");
// we should change current directory so StanfordCoreNLP could find all the model files
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(Config.JarRoot);
var pipeline = new edu.stanford.nlp.pipeline.StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
// Annotation
var annotation = new Annotation(Text);
pipeline.annotate(annotation);
// Result - Pretty Print
using (var stream = new ByteArrayOutputStream())
{
pipeline.prettyPrint(annotation, new PrintWriter(stream));
Console.WriteLine(stream.toString());
}
this.CustomAnnotationPrint(annotation);
}
示例5: AddInnerClassAnnotation
/// <summary>
/// Create an android InnerClass annotation and attach it to the given provider.
/// </summary>
public static void AddInnerClassAnnotation(this IAnnotationProvider provider, string simpleName, AccessFlags accessFlags)
{
var annotation = new Annotation { Type = new ClassReference("dalvik/annotation/InnerClass"), Visibility = AnnotationVisibility.System };
annotation.Arguments.Add(new AnnotationArgument("name", simpleName));
annotation.Arguments.Add(new AnnotationArgument("accessFlags", (int)accessFlags));
provider.Annotations.Add(annotation);
}
示例6: Main
static void Main()
{
// Path to the folder with models extracted from `stanford-corenlp-3.7.0-models.jar`
var jarRoot = @"..\..\..\..\paket-files\nlp.stanford.edu\stanford-corenlp-full-2016-10-31\models";
// Text for processing
var text = "Kosgi Santosh sent an email to Stanford University. He didn't get a reply.";
// Annotation pipeline configuration
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, parse, ner,dcoref");
props.setProperty("ner.useSUTime", "0");
// We should change current directory, so StanfordCoreNLP could find all the model files automatically
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
// Annotation
var annotation = new Annotation(text);
pipeline.annotate(annotation);
// Result - Pretty Print
using (var stream = new ByteArrayOutputStream())
{
pipeline.prettyPrint(annotation, new PrintWriter(stream));
Console.WriteLine(stream.toString());
stream.close();
}
}
示例7: GetDepencencies
/// <summary>
/// Gets depeendencies from sentence.
/// </summary>
/// <param name="annotation"></param>
/// <returns></returns>
private NotenizerDependencies GetDepencencies(Annotation annotation)
{
Tree tree;
NotenizerDependency dep;
GrammaticalStructure gramStruct;
NotenizerDependencies dependencies;
NotenizerDependency nsubjComplement;
TreebankLanguagePack treeBankLangPack;
java.util.Collection typedDependencies;
GrammaticalStructureFactory gramStructFact;
tree = annotation.get(typeof(TreeCoreAnnotations.TreeAnnotation)) as Tree;
treeBankLangPack = new PennTreebankLanguagePack();
gramStructFact = treeBankLangPack.grammaticalStructureFactory();
gramStruct = gramStructFact.newGrammaticalStructure(tree);
typedDependencies = gramStruct.typedDependenciesCollapsed();
dependencies = new NotenizerDependencies();
foreach (TypedDependency typedDependencyLoop in (typedDependencies as java.util.ArrayList))
{
dep = new NotenizerDependency(typedDependencyLoop);
dependencies.Add(dep);
if (dep.Relation.IsNominalSubject())
{
nsubjComplement = new NotenizerDependency(typedDependencyLoop);
nsubjComplement.TokenType = dep.TokenType == TokenType.Dependent ? TokenType.Governor : TokenType.Dependent;
dependencies.Add(nsubjComplement);
}
}
return dependencies;
}
示例8: GetAnnotationDetail
public static Annotation GetAnnotationDetail(Guid annotationId, SqlDataAccess sda)
{
Annotation returnValue = new Annotation();
try
{
#region | SQL QUERY |
string query = @"SELECT
A.AnnotationId
,A.MimeType
,A.FileName
,A.DocumentBody
FROM
Annotation A
WHERE
A.AnnotationId = '{0}'";
#endregion
DataTable dt = sda.getDataTable(string.Format(query, annotationId));
if (dt != null && dt.Rows.Count > 0)
{
returnValue.AnnotationId = (Guid)dt.Rows[0]["AnnotationId"];
returnValue.MimeType = dt.Rows[0]["MimeType"] != DBNull.Value ? dt.Rows[0]["MimeType"].ToString() : string.Empty;
returnValue.FileName = dt.Rows[0]["FileName"] != DBNull.Value ? dt.Rows[0]["FileName"].ToString() : string.Empty;
returnValue.File = dt.Rows[0]["DocumentBody"] != DBNull.Value ? dt.Rows[0]["DocumentBody"].ToString() : string.Empty;
}
}
catch (Exception)
{
}
return returnValue;
}
示例9: Create
/// <summary>
/// Create annotations for all included attributes
/// </summary>
public static void Create(AssemblyCompiler compiler, ICustomAttributeProvider attributeProvider,
IAnnotationProvider annotationProvider, DexTargetPackage targetPackage, bool customAttributesOnly = false)
{
if (!attributeProvider.HasCustomAttributes)
return;
var annotations = new List<Annotation>();
foreach (var attr in attributeProvider.CustomAttributes)
{
var attributeType = attr.AttributeType.Resolve();
if (!attributeType.HasIgnoreAttribute())
{
Create(compiler, attr, attributeType, annotations, targetPackage);
}
}
if (annotations.Count > 0)
{
// Create 1 IAttributes annotation
var attrsAnnotation = new Annotation { Visibility = AnnotationVisibility.Runtime };
attrsAnnotation.Type = compiler.GetDot42InternalType("IAttributes").GetClassReference(targetPackage);
attrsAnnotation.Arguments.Add(new AnnotationArgument("Attributes", annotations.ToArray()));
annotationProvider.Annotations.Add(attrsAnnotation);
}
if (!customAttributesOnly)
{
// Add annotations specified using AnnotationAttribute
foreach (var attr in attributeProvider.CustomAttributes.Where(IsAnnotationAttribute))
{
var annotationType = (TypeReference) attr.ConstructorArguments[0].Value;
var annotationClass = annotationType.GetClassReference(targetPackage, compiler.Module);
annotationProvider.Annotations.Add(new Annotation(annotationClass, AnnotationVisibility.Runtime));
}
}
}
示例10: WidgetActions
internal WidgetActions(
Annotation parent,
PdfDirectObject baseObject
)
: base(parent, baseObject)
{
}
示例11: AddToAnnotationCache
private void AddToAnnotationCache(Annotation key)
{
if (_annotCache.ContainsKey(key))
RemoveFromAnnotationCache(key);
_annotCache.Add(key, AnnotationRendererFactory.Default.Create(key));
}
示例12: VisitAnnotation
protected internal virtual Annotation VisitAnnotation(Annotation annotation)
{
if (annotation == null) return null;
annotation.Declaration = Visit(annotation.Declaration);
annotation.Argument = VisitValue(annotation.Argument);
return annotation;
}
示例13: StoreContentChangedEventArgs
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
#region Constructors
/// <summary>
/// Creates an instance of AnnotationUpdatedEventArgs with the
/// specified action and annotation.
/// </summary>
/// <param name="action">the action that was performed on an annotation</param>
/// <param name="annotation">the annotation that was updated</param>
public StoreContentChangedEventArgs(StoreContentAction action, Annotation annotation)
{
if (annotation == null)
throw new ArgumentNullException("annotation");
_action = action;
_annotation = annotation;
}
示例14: TextBlock
internal TextBlock(int spanStart, int spanEnd, string type, string text, Annotation annotation)
{
mSpanStart = spanStart;
mSpanEnd = spanEnd;
mType = type;
mText = text;
mAnnotation = annotation;
}
示例15: AddAnnotation
public void AddAnnotation(Annotation annotation)
{
if (annotation != null)
{
Annotations.Add(annotation);
if (this.AnnotationAdded != null)
this.AnnotationAdded(annotation);
}
}