I have a word template with .docx format,
my question:
Can I get a list of tag names from the rich text content control
that I have declared in the template like inside table and other else? and how?
(this is the example of template)
Can I call a parameter from the return response database using a
string? and how to retrieve deeper level data like this? (example are below)
{
"id": "293",
"user": "315",
"userNavigation": {
"id": "314",
"name": "insomnia"
},
"department": [
{
"id": "2",
"name": "Tech"
},
{
"id": "1",
"name": "Bio"
},
],
}
I've used two libraries
OpenXml
TemplateEngine.Docx: https://bitbucket.org/unit6ru/templateengine/src/master/
I do not use third party services because they are not paid.
Related
I'm building a bot with bot framework composer (V2)
I want to create a multiple choice action, with choices that I get from a API call.
Api Choices
[
{
"id": 0,
"name": "One",
"active": true
},
{
"id": 1,
"name": "Two",
"active": true
},
{
"id": 2,
"name": "Three",
"active": true
},
{
"id": 3,
"name": "Four",
"active": true
},
{
"id": 4,
"name": "Five",
"active": true
}
]
How do I bind this choices in the multiple choice action?
I assume that you are able to call API and got the data in array format, suppose it got stored in dialog.response.
So what you need to do is,
Add a For each item: Loop and configure it as shown in screenshot.
Next, add Edit an Array Property in the loop and configure it as shown in screenshot
Now, at the end, you need to add Multi-Choice(that you have already added) and give dialog.choices in Array of choices
I have tested this flow till the bot sent card with multiple choice.
We're using Azure Cognitive Search as our search engine for searching for images. The analyzer is Lucene standard and when a user searches for "scottish landscapes" some of our users claim that their image is missing. They will then have to add the keyword "landscapes" in their images so that the search engine can find them.
Changing the analyzer to "en-lucene" or "en-microsoft" only seemed to have way smaller search results, which we didn't like for our users.
Azure Cognitive Search does not seem to distinguish singular and plural words. To resolve the issue, I created a dictionary in the database, used inflection and tried manipulating the search terms:
foreach (var term in terms)
{
if (ps.IsSingular(term))
{
// check with db
var singular = noun.GetSingularWord(term);
if (!string.IsNullOrEmpty(singular))
{
var plural = ps.Pluralize(term);
keywords = keywords + " " + plural;
}
}
else
{
// check with db
var plural = noun.GetPluralWord(term);
if (!string.IsNullOrEmpty(plural))
{
var singular = ps.Singularize(term);
keywords = keywords + " " + singular;
}
}
}
My solution is not 100% ideal but it would be nicer if Azure Cognitive Search can distinguish singular and plural words.
UPDATE:
Custom Analyzers may be the answer to my problem, I just need to find the right token filters.
UPDATE:
Below is my custom analyzer. It removes html constructs, apostrophes, stopwords and converts them to lowercase. The tokenizer is MicrosoftLanguageStemmingTokenizer and it reduces the words to its root words so it's apt for plural to singular scenario (searching for "landscapes" returns "landscapes" and "landscape")
"analyzers": [
{
"name": "p4m_custom_analyzer",
"#odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",
"charFilters": [
"html_strip",
"remove_apostrophe"
],
"tokenizer": "custom_tokenizer",
"tokenFilters": [
"lowercase",
"remove_stopwords"
]
}
],
"charFilters": [
{
"name": "remove_apostrophe",
"#odata.type":"#Microsoft.Azure.Search.MappingCharFilter",
"mappings": ["'=>"]
}
],
"tokenizers": [
{
"name": "custom_tokenizer",
"#odata.type":"#Microsoft.Azure.Search.MicrosoftLanguageStemmingTokenizer",
"isSearchTokenizer": "false"
}
],
"tokenFilters": [
{
"name": "remove_stopwords",
"#odata.type": "#Microsoft.Azure.Search.StopwordsTokenFilter"
}
]
I have yet to figure out the other way around. If the user searches for "apple" it should return "apple" and "apples".
Both en.lucene and en.microsoft should have helped with this, you shouldn't need to manually expand inflections on your side. I'm surprised to hear you see less recall with them. Generally speaking I would expect higher recall with those than the standard analyzer. Do you by any chance have multiple searchable fields with different analyzers? That could interfere. Otherwise, it would be great to see a specific case (a query/document pair along with the index definition) to investigate further.
As a quick test, I used this small index definition:
{
"name": "inflections",
"fields": [
{
"name": "id",
"type": "Edm.String",
"searchable": false,
"filterable": true,
"retrievable": true,
"sortable": false,
"facetable": false,
"key": true
},
{
"name": "en_ms",
"type": "Edm.String",
"searchable": true,
"filterable": false,
"retrievable": true,
"sortable": false,
"facetable": false,
"key": false,
"analyzer": "en.microsoft"
}
]
}
These docs:
{
"id": "1",
"en_ms": "example with scottish landscape as part of the sentence"
},
{
"id": "2",
"en_ms": "this doc has one apple word"
},
{
"id": "3",
"en_ms": "this doc has two apples in it"
}
For this search search=landscapes I see these results:
{
"value": [
{
"#search.score": 0.9631388,
"id": "1",
"en_ms": "example with scottish landscape as part of the sentence"
}
]
}
And for search=apple I see:
{
"value": [
{
"#search.score": 0.51188517,
"id": "3",
"en_ms": "this doc has two apples in it"
},
{
"#search.score": 0.46152657,
"id": "2",
"en_ms": "this doc has one apple word"
}
]
}
I'm using DocumentDB on azure and I don't want the auto-generated GUID that it gives me for an id on the top layer...example:
{
"data": {
"Name": "Brian",
"Last": "Coolest",
"gender": "m"
},
"id": "7c572c3f-2ee1-43c9-bfb9-63b67542658d"
}
how do i turn that id into:
{
"data": {
"Name": "Brian",
"Last": "Coolest",
"gender": "m"
},
"id": "Brian"
}
on the creation of the document, is this possible? Thanks!
here is the method:
client.CreateDocumentAsync(
UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), JsonSerializedDocument);
example of json structure:
{
"data": {
"id": "113118",
"url": "/v1/rentalUnits/202020202",
Yes, if you add your own field named "id" populate the field before you save the document, then DocDb will use the id you specified. But, that means you have to control the uniqueness of the primary keys otherwise the next document that you save with "id":"Brian" will obviously overwrite the previous document.
I want to deserialize a json that I get as result of a REST query (the json string can not be changed) to a dictionary type.
The json string looks something like this:
{
"collection": {
"useful": true
"attributes": {
"ObjectID": "ObjectID",
"Name": "Name",
"FirstID": "FirstID",
"LastID": "LastID",
"Count": "5",
},
"Type": "Polyline",
"features": [{
"attributes": {
"length": 0.10879009704943393
"time": 0.3822371137674949,
"text": "some text",
"ABC": -2209161600000,
"Type": "SomeType"
}
}]
}
}
I create boolean property for 'useful' and integer for 'count' etc. but I have a problem with the 'attributes'. As you can see, in each section (and per result) I get different 'attributes'.
I need to deserialize them into some generic collection like dictionary or list of KeyValuePair. the problem is, as stated in msdn (here - http://msdn.microsoft.com/en-us/library/bb412170.aspx) "Dictionaries are not a way to work directly with JSON".
How can I do it if so?
My application is silverlight 5, .Net 4, VS 2010.
Thanks in advance!
I'm having a few problems trying to consume my JSON Data from a web URL and put it into my Class Array.
My class looks something like this;
public class User
{
String Name;
String Serial;
String Email;
}
Where my JSON data looks like
{ "name": "cname", "value": [ "Joe Bloggs"] },
{ "name": "serialnumber", "value": [ "231212312" ] },
{ "name": "gender", "value": [ "male" ] },
{ "name": "email", "value": [ "jbloggs#domain.com" ] },
I want to pop this into a User Class Array so that it would be somthing like
User myUsers[] = new User[100];
I have the data downloaded using a StreamReader, but I'm lost as to where to start. I've tried out DataContractJsonSerializer and a few others but can't find any basic guides on the web where to start.
I should note that I want to only grab the values listed in the class and not extras such as Gender etc.
If someone could provide a basic sample of both the class and the program implementation to read the data that would be great.
Thanks,
CM888.
I Highly Reccomend looking into this library:
Json.NET
It has many great features, but the best is that it's designed to mimic LINQ to XML. You can use it very similarly.
Using this library you could parse your json into objects and work with them & linq queries to build up your user array.
To expand on my comment above: (Unrelated to question or answer)
What i meant was i was curious why your JSON wasn't strctured like this:
[
{"cname": "Joe Bloggs", "serialnumber": "231313213", "gender": "male", "email": "jbloggs#domain.com"},
{"cname": "Another Dude", "serialnumber": "345345345", "gender": "male", "email": "another#dude.com"}
]