JSON to create a tree with getorgchart - getorgchart

I work with getOrgChart to create a tree.
I would like to do it in JSON except that it does not keep the order of the keys.
Is it really necessary to have an ordered JSON as in the exemple?
(Id; Name; Title; ...)
([{"Id":"1","ParentId":"","Name":"Luke Coleman","Title":"ESL teacher","Address":"31 Dalgarno Street COOCOOBOONAH NSW 2380","Phone":"(02) 6780 6577","Visa":null,"Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-19.jpg"},{"Id":"2","ParentId":"1","Name":"Zara Potter","Title":"Bricklayer","Address":"74 Main Street RAMCO SA 5322","Phone":null,"Visa":"4556 6703 4539 1908","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-20.jpg"},{"Id":"3","ParentId":"1","Name":"Mohammed Cook","Title":"Nursing aide","Address":null,"Phone":"(03) 5300 7404","Visa":"4716 4797 6315 4724","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-1.jpg"},{"Id":"4","ParentId":"1","Name":"Harley Birch","Title":"Reservation agent","Address":"70 Cornish Street WILLIAMS RAAF VIC 3027","Phone":"(03) 8336 9859","Visa":"5442 1396 6319 2111","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-3.jpg"},{"Id":"5","ParentId":"2","Name":"Maya Ford","Title":"Reservation agent","Address":"70 Cornish Street WILLIAMS RAAF VIC 3027","Phone":"(03) 8336 9859","Visa":"5442 1396 6319 2111","Image":"http://www.getorgchart.com/GetOrgChart/getorgchart-demos/images/f-5.jpg"}]);
Because on my side, when creating the JSON that is created automatically, I get the id in 2nd position and I read that we could not change the order.
{"Statut":"Test","id":106,"Image":"Test.gif","Nom":"Test","Heure":"17-05-2018 14:41:55","parentId":"","Compteur":10000}

You can explicitly specify the idField and parentIdField
Here is an example:
var orgChart = new getOrgChart(peopleElement, {
idField: "id",
parentIdField: "parentId"
...
});

Related

access to nested array in tabular

i have a json array with nested arrays. How can I access them in tabulator
the array contains a list of flights
data = [
flights
flights.price
flights.departure // departure // Frankfurt
flights.arrival // final destination // Houston
flights .... etc
flights.route
flights.route[0].from // flight #1 Frankfurt
flights.route[0].to // flight #1 Washington
flights.route[1].from // flight #2 Washington
flights.route[1].to // flight #2 Houston
....
]
How can i access the route[X].from and list it as value in Tabulator?
I already have read about nested fields (e.g user.name), but how can you access arrays if they have no names but only numbers?
Use data tree for nested data
data:tableDataNested,
dataTree:true,

LinqToExcel:How to get specific row in Excel

I have an excel that looks like
ID Name DepartmentID Ext
1298 Alice AA1152 1221
1299 Andrew AA1152 1235
2894 Jack AA1152 1285
2723 Daniel AA1152 4239
All employees are in the same department, and I want to get the DepartmentID from excel to link to the department name in database.
I've read this tutorial http://www.codeproject.com/Articles/659643/Csharp-Query-Excel-and-CSV-Files-Using-LinqToExcel but it has to read the entire file and access sequentially in foreach loop.
How can I get only one row from excel using LinqToExcel library?
Thanks a lot.
You should be able to use First() to return only the first result :
var artistAlbums = from a in excelFile.Worksheet(sheetName) select a;
var firstAlbum = artistAlbums.First();
And to get one specific row, combine Skip() and First(), for example :
var fifthAlbum = artistAlbums.Skip(4).First();
Try something like this
var excelData = new ExcelQueryFactory(excelFileName);
var yourRow = from c in excelData.Worksheet<YourMappedClass>(WorksheetName) where c.Id==SomeValue select c;
There are quite a few other things you can accomplish as well as explained in their github page.

making link between a person name and pronoun in GATE

Is it possible to make a link between a person name and its PRP? in GATE E.g i have document "Maria Sharapova is a tennis player from russia. She participates in international tennis tournament. She is known for winning Wimbledon, US Open and Australian Open titles as for her looks, decibel-breaking grunts and commercial savvy - all of which made her the world's highest-paid female athlete." i want to annotate the "she" as "Maria Sharapova". I have written the following JAPE rule which identifies a pattern having a PRP after a person name
Phase: Simple
Input: Lookup Token Split
Options: control = appelt
Rule:joblookup
(
({Lookup.majorType == person_first}|
{Lookup.majorType == person_full})
({Token.kind==word})+
{Split.kind==internal}
{Token.category==PRP}
):sameathlete
-->
:sameathlete.sameAthlete1 = {kind="athlete", rule="same-athlete"}
How can i make the annotation that from She means we are talking about the same person whose name is mentioned 1 or 2 sentence before??
Please help
Have you tried Co-reference PR for gate?

Train model using Named entity

I am looking on standford corenlp using the Named Entity REcognizer.I have different kinds of input text and i need to tag it into my own Entity.So i started training my own model and it doesnt seems to be working.
For eg: my input text string is "Book of 49 Magazine Articles on Toyota Land Cruiser 1956-1987 Gold Portfolio http://t.co/EqxmY1VmLg http://t.co/F0Vefuoj9Q"
I go through the examples to train my own models and and look for only some words that I am interested in.
My jane-austen-emma-ch1.tsv looks like this
Toyota PERS
Land Cruiser PERS
From the above input text i am only interested in those two words. The one is
Toyota and the other word is Land Cruiser.
The austin.prop look like this
trainFile = jane-austen-emma-ch1.tsv
serializeTo = ner-model.ser.gz
map = word=0,answer=1
useClassFeature=true
useWord=true
useNGrams=true
noMidNGrams=true
useDisjunctive=true
maxNGramLeng=6
usePrev=true
useNext=true
useSequences=true
usePrevSequences=true
maxLeft=1
useTypeSeqs=true
useTypeSeqs2=true
useTypeySequences=true
wordShape=chris2useLC
Run the following command to generate the ner-model.ser.gz file
java -cp stanford-corenlp-3.4.1.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop austen.prop
public static void main(String[] args) {
String serializedClassifier = "edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz";
String serializedClassifier2 = "C:/standford-ner/ner-model.ser.gz";
try {
NERClassifierCombiner classifier = new NERClassifierCombiner(false, false,
serializedClassifier2,serializedClassifier);
String ss = "Book of 49 Magazine Articles on Toyota Land Cruiser 1956-1987 Gold Portfolio http://t.co/EqxmY1VmLg http://t.co/F0Vefuoj9Q";
System.out.println("---");
List<List<CoreLabel>> out = classifier.classify(ss);
for (List<CoreLabel> sentence : out) {
for (CoreLabel word : sentence) {
System.out.print(word.word() + '/' + word.get(AnswerAnnotation.class) + ' ');
}
System.out.println();
}
} catch (ClassCastException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Here is the output I am getting
Book/PERS of/PERS 49/O Magazine/PERS Articles/PERS on/O Toyota/PERS Land/PERS Cruiser/PERS 1956-1987/PERS Gold/O Portfolio/PERS http://t.co/EqxmY1VmLg/PERS http://t.co/F0Vefuoj9Q/PERS
which i think its wrong.I am looking for Toyota/PERS and Land Cruiser/PERS(Which is a multi valued fied.
Thanks for the Help.Any help is really appreciated.
I believe you should also put examples of 0 entities in your trainFile. As you gave it, the trainFile is just too simple for the learning to be done, it needs both 0 and PERSON examples so it doesn't annotate everything as PERSON. You're not teaching it about your not-of-interest entities. Say, like this:
Toyota PERS
of 0
Portfolio 0
49 0
and so on.
Also, for phrase-level recognition you should look into regexner, where you can have patterns (patterns are good for us). I'm working on this with the API and I have the following code:
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, regexner");
props.put("regexner.mapping", customLocationFilename);
with the following customLocationFileName:
Make Believe Town figure of speech ORGANIZATION
( /Hello/ [{ ner:PERSON }]+ ) salut PERSON
Bachelor of (Arts|Laws|Science|Engineering) DEGREE
( /University/ /of/ [{ ner:LOCATION }] ) SCHOOL
and text: Hello Mary Keller was born on 4th of July and took a Bachelor of Science. Partial invoice (€100,000, so roughly 40%) for the consignment C27655 we shipped on 15th August to University of London from the Make Believe Town depot. INV2345 is for the balance.. Customer contact (Sigourney Weaver) says they will pay this on the usual credit terms (30 days).
The output I get
Hello Mary Keller is a salut
4th of July is a DATE
Bachelor of Science is a DEGREE
$ 100,000 is a MONEY
40 % is a PERCENT
15th August is a DATE
University of London is a ORGANIZATION
Make Believe Town is a figure of speech
Sigourney Weaver is a PERSON
30 days is a DURATION
For more info on how to do this you can look at the example that got me going.
The NERClassifier* is word level, that is, it labels words, not phrases. Given that, the classifier seems to be performing fine. If you want, you can hyphenate words that form phrases. So in your labeled examples and in your test examples, you would make "Land Cruiser" to "Land_Cruiser".

How do you form a compound query using Bing Marketplace API?

I have an application that is using the new Bing API from the Azure Datamarketplace. I used to be able to query the Bing API using a simple syntax using OR AND, etc. That doesn't seem to work in the new API.
Old syntax:
"Jacksonville Jaguars" OR "NFL Jaguars" OR "Atlanta Falcons"
That would give me a query with any of those phrases (I am making a rt_Sports query for news).
I am calling HttpEncode on the query first, but am still not getting results. It works if I remove all the " marks, but then I am getting results sometimes for news about Falcons and Jaguars (the animals)... Not what I wanted.
Anyone have any idea how you can form a query that takes multiple phrases?
I have tried to not use the OR, not use the ', use a ", use the | instead of OR. All of these work against BING the website, just not in the API.
I just tried this via Bing and got 36 Million results:
NFL Football | Seattle Seahawks | New York Giants | Dallas Cowboys | New Orleans Saints | New England Patriots | Jacksonville Jaguars
Same thing in the API returns 0.
I got an email from a friend who I also emailed this question out to and his thought was that I was going about it wrong. That there should be a way to form a LINQ query off the Bing object with multiple where clauses.
But I don't see how that would be possible. You allow a BingSearchContainer and then call the News method on the container. The News method has only a single Query parameter.
var bingContainer = new Bing.BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search"));
bingContainer.Credentials = new NetworkCredential(App.BingAPIAccountKey, App.BingAPIAccountKey);
string unifiedQuery = "NFL Football | Jacksonville Jaguars | Atlanta Falcons";
var newsQuery = bingContainer.News(unifiedQuery, null, "en-US", "Strict", null, null, null, "rt_Sports", "Relevance");
newsQuery.BeginExecute(BingNewsResultLoadedCallback, newsQuery);
Try changing unifiedQuery to the following:
var unifiedQuery = "'NFL Football' or 'Jacksonville Jaguars' or 'Atlanta Falcons'";
I tried something very similar to your sample code, using this format for the query string, and it worked for me:
var bingUri = new Uri("https://api.datamarket.azure.com/Bing/Search/v1/", UriKind.Absolute);
var bingContainer = new BingSearchContainer(bingUri);
bingContainer.Credentials = new NetworkCredential(BingAPIUserName, BingAPIAccountKey);
var unifiedQuery = "'NFL Football' or 'Jacksonville Jaguars' or 'Atlanta Falcons'";
var newsQuery = bingContainer.News(unifiedQuery, null, "en-US", "Strict", null, null, null, "rt_Sports", "Relevance");
var results = newsQuery.Execute();
foreach (var item in results)
{
Console.WriteLine(item.Title);
}
Here are my results:
Fantasy Football 2012: Ranking the Top 25 RBs
NFL Football No Longer Just a Sunday Game
Ravens Notebook: Ed Reed decided to play in game vs. Falcons since he 'wasn't doing anything else'
PrimeSport Partners with Jacksonville Jaguars to Offer Tickets and Official Fan
Packages for all Home and Away Games in 2012 Season
Jaguars cut former Ravens wide receiver Lee Evans
Falcons left tackle Baker finally feels healthy
Jaguars release veteran WR Lee Evans
NFC West: 2012 NFL Training Camp
Atlanta Falcons 2012 NFL TV Schedule
Jaguars training camp: Veteran WR Lee Evans released
Jaguars score 18 points in second half to beat Giants 32-31
Jacksonville Jaguars put running back Maurice Jones-Drew on reserve/did not report list
Postcard from camp: Falcons
Questions abound as NFL preseason opens in earnest
NFL fantasy football: Ryan Mathews loses value
The format for the unifiedQuery string is basically the OData URI query string format. For a full description of how these query strings work, check out the OData URI conventions documentation at http://www.odata.org/documentation/uri-conventions.

Resources