I am new to ionic framework and I had stuck in the following issue :
data.json:
{ "speakers" : [
{
"name":"Mr Bellingham",
"shortname":"Barot_Bellingham",
"reknown":"Royal Academy of Painting and Sculpture",
"bio":"Barot has just finished his final year at The Royal Academy of Painting and Sculpture, where he excelled in glass etching paintings and portraiture. Hailed as one of the most diverse artists of his generation, Barot is equally as skilled with watercolors as he is with oils, and is just as well-balanced in different subject areas. Barot's collection entitled \"The Un-Collection\" will adorn the walls of Gilbert Hall, depicting his range of skills and sensibilities - all of them, uniquely Barot, yet undeniably different"
},
{
"name":"Jonathan G. Ferrar II",
"shortname":"Jonathan_Ferrar",
"reknown":"Artist to Watch in 2012",
"bio":"The Artist to Watch in 2012 by the London Review, Johnathan has already sold one of the highest priced-commissions paid to an art student, ever on record. The piece, entitled Gratitude Resort, a work in oil and mixed media, was sold for $750,000 and Jonathan donated all the proceeds to Art for Peace, an organization that provides college art scholarships for creative children in developing nations"
},
{
"name":"Hillary Hewitt Goldwynn-Post",
"shortname":"Hillary_Goldwynn",
"reknown":"New York University",
"bio":"Hillary is a sophomore art sculpture student at New York University, and has already won all the major international prizes for new sculptors, including the Divinity Circle, the International Sculptor's Medal, and the Academy of Paris Award. Hillary's CAC exhibit features 25 abstract watercolor paintings that contain only water images including waves, deep sea, and river."
},
{
"name":"Hassum Harrod",
"shortname":"Hassum_Harrod",
"reknown":"Art College in New Dehli",
"bio":"The Art College in New Dehli has sponsored Hassum on scholarship for his entire undergraduate career at the university, seeing great promise in his contemporary paintings of landscapes - that use equal parts muted and vibrant tones, and are almost a contradiction in art. Hassum will be speaking on \"The use and absence of color in modern art\" during Thursday's agenda."
},
{
"name":"Jennifer Jerome",
"shortname":"Jennifer_Jerome",
"reknown":"New Orleans, LA",
"bio":"A native of New Orleans, much of Jennifer's work has centered around abstract images that depict flooding and rebuilding, having grown up as a teenager in the post-flood years. Despite the sadness of devastation and lives lost, Jennifer's work also depicts the hope and togetherness of a community that has persevered. Jennifer's exhibit will be discussed during Tuesday's Water in Art theme."
},
{
"name":"LaVonne L. LaRue",
"shortname":"LaVonne_LaRue",
"reknown":"Chicago, IL",
"bio":"LaVonne's giant-sized paintings all around Chicago tell the story of love, nature, and conservation - themes that are central to her heart. LaVonne will share her love and skill of graffiti art on Monday's schedule, as she starts the painting of a 20-foot high wall in the Rousseau Room of Hotel Contempo in front of a standing-room only audience in Art in Unexpected Places."
},
{
"name":"Constance Olivia Smith",
"shortname":"Constance_Smith",
"reknown":"Fullerton-Brighton-Norwell Award",
"bio":"Constance received the Fullerton-Brighton-Norwell Award for Modern Art for her mixed-media image of a tree of life, with jewel-adorned branches depicting the arms of humanity, and precious gemstone-decorated leaves representing the spouting buds of togetherness. The daughter of a New York jeweler, Constance has been salvaging the discarded remnants of her father's jewelry-making since she was five years old, and won the New York State Fair grand prize at the age of 8 years old for a gem-adorned painting of the Manhattan Bridge."
},
{
"name":"Riley Rudolph Rewington",
"shortname":"Riley_Rewington",
"reknown":"Roux Academy of Art, Media, and Design",
"bio":"A first-year student at the Roux Academy of Art, Media, and Design, Riley is already changing the face of modern art at the university. Riley's exquisite abstract pieces have no intention of ever being understood, but instead beg the viewer to dream, create, pretend, and envision with their mind's eye. Riley will be speaking on the \"Art of Abstract\" during Thursday's schedule"
},
{
"name":"Xhou Ta",
"shortname":"Xhou_Ta",
"reknown":"China International Art University",
"bio":"A senior at the China International Art University, Xhou has become well-known for his miniature sculptures, often the size of a rice granule, that are displayed by rear projection of microscope images on canvas. Xhou will discuss the art and science behind his incredibly detailed works of art."
}
]}
app.js :
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller('ListController', ['$scope','$http',function($scope,$http){
$http.get('js/data.json').success(function(data){
$scope.artists = data;
});
}])
index.html :
<ion-content ng-controller="ListController" class="has-subheader">
<ion-list>
<ion-item ng-repeat='item in artists' class="item-thumbnail-left item-text-wrap">
<img src="img/{{item.shortname}}_tn.jpg">
<h2>{{item.shortname}}</h2>
<h3>{{item.reknown}}</h3>
<p>
{{item.bio}}
</p>
</ion-item>
</ion-list>
</ion-content>
As you all can see I am trying to list down the data from data.json file but it does not display any data. On console-Network tab I am able to see it call to data.json file but in html it is unable to display. What I am doing wrong? Please help me on this, thanks in advance
Try like this
ng-repeat='item in artists.speakers'
instead of
ng-repeat='item in artists'
Related
I'm using bert pre-trained model for question and answering. It's returning correct result but with lot of spaces between the text
The code is below :
def get_answer_using_bert(question, reference_text):
bert_model = BertForQuestionAnswering.from_pretrained('bert-large-uncased-whole-word-masking-finetuned-squad')
bert_tokenizer = BertTokenizer.from_pretrained('bert-large-uncased-whole-word-masking-finetuned-squad')
input_ids = bert_tokenizer.encode(question, reference_text)
input_tokens = bert_tokenizer.convert_ids_to_tokens(input_ids)
sep_location = input_ids.index(bert_tokenizer.sep_token_id)
first_seg_len, second_seg_len = sep_location + 1, len(input_ids) - (sep_location + 1)
seg_embedding = [0] * first_seg_len + [1] * second_seg_len
model_scores = bert_model(torch.tensor([input_ids]),
token_type_ids=torch.tensor([seg_embedding]))
ans_start_loc, ans_end_loc = torch.argmax(model_scores[0]), torch.argmax(model_scores[1])
result = ' '.join(input_tokens[ans_start_loc:ans_end_loc + 1])
result = result.replace('#', '')
return result
Followed by code below :
reference_text = 'Mukesh Dhirubhai Ambani was born on 19 April 1957 in the British Crown colony of Aden (present-day Yemen) to Dhirubhai Ambani and Kokilaben Ambani. He has a younger brother Anil Ambani and two sisters, Nina Bhadrashyam Kothari and Dipti Dattaraj Salgaonkar. Ambani lived only briefly in Yemen, because his father decided to move back to India in 1958 to start a trading business that focused on spices and textiles. The latter was originally named Vimal but later changed to Only Vimal His family lived in a modest two-bedroom apartment in Bhuleshwar, Mumbai until the 1970s. The family financial status slightly improved when they moved to India but Ambani still lived in a communal society, used public transportation, and never received an allowance. Dhirubhai later purchased a 14-floor apartment block called Sea Wind in Colaba, where, until recently, Ambani and his brother lived with their families on different floors.'
question = 'What is the name of mukesh ambani brother?'
get_answer_using_bert(question, reference_text)
And the output is :
'an il am ban i'
Can anyone help me how to fix this issue. It would be really helpful.
You can just use the tokenizer decode function:
bert_tokenizer.decode(input_ids[ans_start_loc:ans_end_loc +1])
Output:
'anil ambani'
In case you do not want to use decode, you can use:
result.replace(' ##', '')
I am using axios to retrieve data from Wikipedia Api. This is the code I have writtent.
let axiosData = function(){
let searchString = $('#searchString').val();
console.log(searchString);
let Url = "https://en.wikipedia.org/w/api.php?action=opensearch&search="+ searchString +
"&origin=*&callback=";
axios.get(Url)
.then(function(res){
var linkLists = res.data;
console.log(linkLists);
})
.catch(function(){
console.log("Error")
});
return false;
}
$('form').submit(axiosData);
I am able to get an output when I console log it. Which is the following: In this case I am searching for the name Jon Snow. How am able to access the json?
/**/(["jon snow",["Jon Snow (character)","Jon Snow (journalist)","Jon Snow","John Snow (cricketer)","Jon Snoddy","John Snow","Jon Snodgrass (musician)","Jon Snodgrass","John Snow College, Durham","John Snow, Inc"],["Jon Snow is a fictional character in the A Song of Ice and Fire series of fantasy novels by American author George R. R.","Jonathan George Snow HonFRIBA (born 28 September 1947) is an English journalist and television presenter.","Jon Snow may refer to:","John Augustine Snow (born 13 October 1941) is a retired English cricketer. He played for Sussex and England in the 1960s and 1970s.","Jon Snoddy is an American technology expert who is currently the Advanced Development Studio Executive SVP at Walt Disney Imagineering.","John Snow (15 March 1813 \u2013 16 June 1858) was an English physician and a leader in the development of anaesthesia and medical hygiene.","Jon Snodgrass is \"the guy with the glasses from Drag the River\".","Jon Snodgrass is a Panamanian author, born on July 27, 1941 in Col\u00f3n, Panama to John Alphonso and Olivia Jane (Chestnut) Snodgrass.","John Snow College is one of 16 constituent colleges of the University of Durham in England. The College takes its name from the nineteenth-century Yorkshire physician Dr John Snow.","John Snow, Inc. (JSI) is a public health research and consulting firm in the United States and around the world."],["https://en.wikipedia.org/wiki/Jon_Snow_(character)","https://en.wikipedia.org/wiki/Jon_Snow_(journalist)","https://en.wikipedia.org/wiki/Jon_Snow","https://en.wikipedia.org/wiki/John_Snow_(cricketer)","https://en.wikipedia.org/wiki/Jon_Snoddy","https://en.wikipedia.org/wiki/John_Snow","https://en.wikipedia.org/wiki/Jon_Snodgrass_(musician)","https://en.wikipedia.org/wiki/Jon_Snodgrass","https://en.wikipedia.org/wiki/John_Snow_College,_Durham","https://en.wikipedia.org/wiki/John_Snow,_Inc"]])
At The beginning of the json has '/**/(' and at the end ')' characters which have cut by substring. After parsed it.
let Url = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=jon%20snow&origin=*&callback=";
axios.get(Url)
.then(function(res){
console.log(res);
var linkLists = JSON.parse(res.data.substring(5, res.data.length-1));
console.log(linkLists)
})
.catch(function(){
console.log("Error...")
});
If res.data is the JSON response for your http request you can parse that into JSON with the JSON.parse() function
var linkJSON = JSON.parse(res.data)
That will give you the json data in the linkJSON object.
I am having issues on converting JSON data to readable text. Right now it comes out something like this:
{"id":82,"url":"http://www.tvmaze.com/shows/82/game-of-thrones","name":"Game of Thrones","type":"Scripted","language":"English","genres":["Drama","Adventure","Fantasy"],"status":"Running","runtime":60,"premiered":"2011-04-17","schedule":{"time":"21:00","days":["Sunday"]},"rating":{"average":9.3},"weight":10,"network":{"id":8,"name":"HBO","country":{"name":"United States","code":"US","timezone":"America/New_York"}},"webChannel":null,"externals":{"tvrage":24493,"thetvdb":121361,"imdb":"tt0944947"},"image":{"medium":"http://static.tvmaze.com/uploads/images/medium_portrait/53/132622.jpg","original":"http://static.tvmaze.com/uploads/images/original_untouched/53/132622.jpg"},"summary":"<p>Based on the bestselling book series <em>A Song of Ice and Fire</em> by George R.R. Martin, this sprawling new HBO drama is set in a world where summers span decades and winters can last a lifetime. From the scheming south and the savage eastern lands, to the frozen north and ancient Wall that protects the realm from the mysterious darkness beyond, the powerful families of the Seven Kingdoms are locked in a battle for the Iron Throne. This is a story of duplicity and treachery, nobility and honor, conquest and triumph. In the <em>\"Game of Thrones\"</em>, you either win or you die.</p>","updated":1485102249,"_links":{"self":{"href":"http://api.tvmaze.com/shows/82"},"previousepisode":{"href":"http://api.tvmaze.com/episodes/729575"},"nextepisode":{"href":"http://api.tvmaze.com/episodes/937256"}}}
How would I go about converting this data so I can view it as ID, Name, Genre etc.?
If you just want to print it to the console, try something like this:
var json = '{"id":82,"url":"http://www.tvmaze.com/shows/82/game-of-thrones","name":"Game of Thrones","type":"Scripted","language":"English","genres":["Drama","Adventure","Fantasy"],"status":"Running","runtime":60,"premiered":"2011-04-17","schedule":{"time":"21:00","days":["Sunday"]},"rating":{"average":9.3},"weight":10,"network":{"id":8,"name":"HBO","country":{"name":"United States","code":"US","timezone":"America/New_York"}},"webChannel":null,"externals":{"tvrage":24493,"thetvdb":121361,"imdb":"tt0944947"},"image":{"medium":"http://static.tvmaze.com/uploads/images/medium_portrait/53/132622.jpg","original":"http://static.tvmaze.com/uploads/images/original_untouched/53/132622.jpg"},"summary":"<p>Based on the bestselling book series <em>A Song of Ice and Fire</em> by George R.R. Martin, this sprawling new HBO drama is set in a world where summers span decades and winters can last a lifetime. From the scheming south and the savage eastern lands, to the frozen north and ancient Wall that protects the realm from the mysterious darkness beyond, the powerful families of the Seven Kingdoms are locked in a battle for the Iron Throne. This is a story of duplicity and treachery, nobility and honor, conquest and triumph. In the <em>Game of Thrones</em>, you either win or you die.</p>","updated":1485102249,"_links":{"self":{"href":"http://api.tvmaze.com/shows/82"},"previousepisode":{"href":"http://api.tvmaze.com/episodes/729575"},"nextepisode":{"href":"http://api.tvmaze.com/episodes/937256"}}}'
var obj = jQuery.parseJSON(json)
function printLine(obj){
for( var i in obj){
if(typeof obj[i] != 'object') console.log(i + ": " +obj[i]);
else printLine(obj[i]);
}
}
printLine(obj);
I have the following problem. When using https://itunes.apple.com/lookup?id=284910350 i get response like this
{
"resultCount":1,
"results": [
{"kind":"software", "features":["iosUniversal"],
"supportedDevices":["iPadMini4G", "iPhone4S",
"iPhone5s", "iPadThirdGen4G", "iPodTouchourthGen",
"iPhone4", "iPad23G", "iPad2Wifi", "iPadFourthGen",
"iPadFourthGen4G", "iPhone-3GS", "iPhone5c", "iPadThirdGen",
"iPadMini", "iPodTouchFifthGen", "iPhone5"], "isGameCenterEnabled":false,
"screenshotUrls":["http://a5.mzstatic.com/us/r30/Purple2/v4/3d/60/77/3d60774b-12f1-3e6b-ae57-28a64e8f1067/screen1136x1136.jpeg",
"http://a3.mzstatic.com/us/r30/Purple/v4/dd/88/1c/dd881c35-51b3-3033-cef2-08b3deebaa87/screen1136x1136.jpeg",
"http://a4.mzstatic.com/us/r30/Purple4/v4/0c/98/a5/0c98a5a2-f13b-9e36-f027-8fe9a54f141e/screen1136x1136.jpeg",
"http://a4.mzstatic.com/us/r30/Purple6/v4/2f/ae/15/2fae15cd-555c-275a-7d59-235fcf402309/screen1136x1136.jpeg"],
"ipadScreenshotUrls":["http://a1.mzstatic.com/us/r30/Purple/v4/fb/b2/2d/fbb22d69-9454-d3a3-dd4d-d555ae7ae85c/screen480x480.jpeg",
"http://a2.mzstatic.com/us/r30/Purple/v4/e4/bc/11/e4bc1125-67e1-4ece-b67e-5d6839b77eee/screen480x480.jpeg",
"http://a4.mzstatic.com/us/r30/Purple6/v4/93/97/b7/9397b7eb-61cb-ae88-c4e3-c8710079c95e/screen480x480.jpeg",
"http://a4.mzstatic.com/us/r30/Purple2/v4/96/da/60/96da606a-90f7-dc96-9a48-a80ead4be3d8/screen480x480.jpeg"],
"artworkUrl60":"http://a1150.phobos.apple.com/us/r30/Purple/v4/d3/38/b6/d338b6ed-cca7-e4e2-7080-e4dbaa6124a8/57.png",
"artworkUrl512":"http://a255.phobos.apple.com/us/r30/Purple4/v4/c6/6c/92/c66c92d2-58eb-60dc-1ab8-d9ac3b980d12/mzl.tdhykqjc.png",
"artistViewUrl":"https://itunes.apple.com/us/artist/yelp/id284910353?uo=4",
"artistId":284910353, "artistName":"Yelp", "price":0.00, "version":"7.9.2",
"description":"Top-ranked Yelp for your iPhone or iPad has over 50 million reviews on businesses
worldwide \u2014 all in the palm of your hand. Whether you are looking for a pizzeria that is open
now or a coffee shop nearby, Yelp is your local guide to finding just the place to eat, shop, drink,
relax, and play.\n\n\u2022 Discover great local businesses.\n\u2022 Search for nearby restaurants,
shops, and services.\n\u2022 Filter search results by neighborhood, distance, rating, price, and what\u2019s
open now.\n\u2022 Read millions of reviews written by a community of active, expert locals.
\n\u2022 Get to know a business through beautiful photos.\n\u2022 Find great Deals offered by your
favorite local businesses.\n\u2022 Look up addresses and phone numbers, call a business, or make reservations
directly from the app.\n\u2022 Write reviews, check-in to businesses, upload photos, and add tips
of your own!",
"currency":"USD",
"genres":["Travel", "Navigation"], "genreIds":["6003", "6010"], "releaseDate":"2008-07-11T07:00:00Z",
"sellerName":"Yelp, Inc.", "bundleId":"com.yelp.yelpiphone", "trackId":284910350, "trackName":"Yelp",
"primaryGenreName":"Travel", "primaryGenreId":6003,
"releaseNotes":"New in v7.9.2:
\n\u2022 Fixed another bug. Boom.\n\nNew in v7.9.1:\n\u2022 Bug fixes and other improvements
\n\nNew in v7.9:\n\u2022 Our iPhone business page has a hot new modern look just in time for the summer.
\n\u2022 Have you ever uploaded a photo that you later regretted? Yup, us too. Now you can delete
these photos straight from your app.", "minimumOsVersion":"6.0", "formattedPrice":"Free", "wrapperType":"software",
"trackCensoredName":"Yelp", "languageCodesISO2A":["NB", "CS", "DA", "NL", "EN", "FI", "FR", "DE", "IT",
"JA", "PL", "PT", "ES", "SV", "TR"], "fileSizeBytes":"30911255", "contentAdvisoryRating":"12+", "averageUserRatingForCurrentVersion":4.0,
"userRatingCountForCurrentVersion":230, "artworkUrl100":"http://a255.phobos.apple.com/us/r30/Purple4/v4/c6/6c/92/c66c92d2-58eb-60dc-1ab8-d9ac3b980d12/mzl.tdhykqjc.png",
"trackViewUrl":"https://itunes.apple.com/us/app/yelp/id284910350?mt=8&uo=4", "trackContentRating":"12+",
"averageUserRating":4.0, "userRatingCount":189759}]
}
is there any chance that i would be able to get using https://itunes.apple.com/lookup?id=284910350 + some extra parameters on changed url result like this:
{
"resultCount":1,
"results": [
{ "price":0.00, "formattedPrice":"Free"}]
}
Because i just need the price and formated price when i provide app ID, so i can reduce data transfering.
So, I've been using SQL for ever. It's all I know, really, but I really want to understand how to conceptualize document data.
{
"MBS":{
"name":"Mirrodin Besieged",
"code":"MBS",
"releaseDate":"2011-02-04",
"border":"black",
"type":"expansion",
"block":"Scars of Mirrodin",
"cards":[
{"layout":"normal",
"type":"Creature — Human Knight",
"types":["Creature"],
"colors":["White"],
"multiverseid":214064,
"name":"Hero of Bladehold",
"subtypes":["Human", "Knight"],
"cmc":4,
"rarity":"Mythic Rare",
"artist":"Austin Hsu",
"power":"3",
"toughness":"4",
"manaCost":"{2}{W}{W}",
"text":"Battle cry (Whenever this creature attacks, each other attacking creature gets +1/+0 until end of turn.)\n\nWhenever Hero of Bladehold attacks, put two 1/1 white Soldier creature tokens onto the battlefield tapped and attacking.",
"number":"8",
"watermark":"Mirran",
"rulings":[
{"date":"2011-06-01", "text":"Whenever Hero of Bladehold attacks, both abilities will trigger. You can put them onto the stack in any order. If the token-creating ability resolves first, the tokens each get +1/+0 until end of turn from the battle cry ability."},
{"date":"2011-06-01", "text":"You choose which opponent or planeswalker an opponent controls that each token is attacking when it is put onto the battlefield."},
{"date":"2011-06-01", "text":"Although the tokens are attacking, they never were declared as attacking creatures (for purposes of abilities that trigger whenever a creature attacks, for example)."}
],
"imageName":"hero of bladehold",
"foreignNames":[
{"language":"Chinese Traditional", "name":"銳鋒城塞勇士"},
{"language":"Chinese Simplified", "name":"锐锋城塞勇士"},
{"language":"French", "name":"Héroïne de Fortcoutel"},
{"language":"German", "name":"Held der Klingenfeste"},
{"language":"Italian", "name":"Eroina di Rifugio delle Lame"},
{"language":"Japanese", "name":"刃砦の英雄"},
{"language":"Portuguese (Brazil)", "name":"Herói de Bladehold"},
{"language":"Russian", "name":"Герой Блэйдхолда"},
{"language":"Spanish", "name":"Héroe de Fortaleza del Filo"}
],
"printings":["Mirrodin Besieged"]},
{next card...},
{next card...},
{next card...},
{last card...}
]
},
{next set...},
{next set...},
{last set...}
}
So, I have a json file of all of the cards from Magic: The Gathering. The json is 'segmented' into the different sets. So, if I were to import this somehow into a noSQL database (mongoDB):
what would constitute a document?
Is each set a document?
Is each card a document?
What would be a good structure?
How does the querying work at that point... is it just a giant 'text search' if I'm looking for something?
Just looking for some sort of insight to wrap my head around noSQL.