public override Object Perform(Object obj) { Debug.WriteLine("Adding text clipping"); bool isSemanticText = GetArgumentBoolean(SemanticOperationNamedArguments.SemanticText, false); Object contextObject = GetArgumentObject(SemanticOperationNamedArguments.Text); String context = (contextObject != null) ? contextObject.ToString() : null; // TODO use html context -- need methods to strip tags to set regular context from it. Object htmlContextObject = GetArgumentObject(SemanticOperationNamedArguments.HtmlContext); String htmlContext = (htmlContextObject != null) ? htmlContextObject.ToString() : null; if (context != null) { Document sourceDocument = ResolveSourceDocument(); //We will do something smarter here later when we have interest vectors. TextClipping textClipping = new TextClipping(sessionScope.MetaMetadataRepository.GetMMByName(DocumentParserTagNames.TextTag)); //textClipping.setText(createGist(context)); textClipping.Media.Text = new MetadataString(context); //textClipping.Context = new MetadataString(context); textClipping.SourceDoc = sourceDocument; sourceDocument.AddClipping(textClipping); } return(null); }
/* public override Object Perform(Object obj) * { * return null; * } */ public override Object Perform(Object obj) { Document source = ResolveSourceDocument(); Image image = (Image)GetArgumentObject(SemanticOperationNamedArguments.Metadata); if (image == null) { ParsedUri imagePURL = (ParsedUri)GetArgumentObject(SemanticOperationNamedArguments.ImagePurl); /* if (imagePURL != null) * { * image = sessionScope.GetOrConstructImage(imagePURL); * * //TODO -- if it already exists: (1) do we need to download?? * // (2) should we merge metadata * } */ } else { //TODO add to global collections?! if already there merge! } if (image != null && image.Location != null) { image.SemanticsSessionScope = sessionScope as SemanticsSessionScope; Document mixin = (Document)GetArgumentObject(SemanticOperationNamedArguments.Mixin); if (mixin != null) { image.AddMixin(mixin); } Object captionObject = GetArgumentObject(SemanticOperationNamedArguments.Caption); String caption = (captionObject != null) ? captionObject.ToString() : null; int width = GetArgumentInteger(SemanticOperationNamedArguments.Width, 0); int height = GetArgumentInteger(SemanticOperationNamedArguments.Height, 0); ParsedUri hrefPURL = (ParsedUri)GetArgumentObject(SemanticOperationNamedArguments.Href); Document outlink = (Document)GetArgumentObject(SemanticOperationNamedArguments.HrefMetadata); //if (hrefPURL != null & outlink == null) // outlink = sessionScope.GetOrConstructDocument(hrefPURL); ImageClipping imageClipping = image.ConstructClipping(source, outlink, caption, null); source.AddClipping(imageClipping); DocumentClosure imageClosure; if (this.sessionScope is SemanticsSessionScope) { imageClosure = image.GetOrConstructClosure(); if (documentParser != null) { } else { //imageClosure.RequestMetadata(); } } else { image.GetOrConstructClosure(); } return(image); } else { MetaMetadata mm = GetMetaMetadata(); String mmString = mm != null ? mm.Name : "Couldn't getMetaMetadata()"; Debug.WriteLine("Can't createAndVisualizeImgSurrogate because null PURL: " + mmString + " - " + source.Location); } return(null); }