Convert query a query builder - laravel

Possible query a laravel query builder,lo que trato de hacer son las operaciones para calcular el descuto salarial de un dia faltado y si cuenta con prestamo tambien descontarlo
select empleado.sueldo_inci,empleado.sal_diario,
((empleado.sueldo_inci-empleado.sal_diario)-Prestamo.descuento)
as final,Prestamo.descuento from empleado
inner join Prestamo on empleado.idemp=1

\DB::table('empleado')
->join('prestamo', 'empleado.id', 'prestado.empleado_id')
->select(['empleado.sueldo_inci', 'empleado.sal_diario', 'prestamo.descuento'])
->selectRaw('(empleado.sueldo_inci - empleado.sal_diario - prestamo.descuento) AS final')
->get()

Related

Controle de vagas de estacionamento usando pilhas e filas [closed]

Closed. This question is not written in English. It is not currently accepting answers.
Stack Overflow is an English-only site. The author must be able to communicate in English to understand and engage with any comments and/or answers their question receives. Don't translate this post for the author; machine translations can be inaccurate, and even human translations can alter the intended meaning of the post.
Closed 2 days ago.
Improve this question
Fa¸ca uma classe que fa¸ca o controle de um estacionamento com capacidade para 10 carros. Essa classe
deve ser controlada por um menu (rodando em loop) que permita ao usu´ario:
• Adicionar um novo carro. Nesse caso o usu´ario deve fornecer o n´umero da vaga e a placa do carro.
Caso a vaga esteja livre o carro dever´a ser colocado na vaga, caso contr´ario, o usu´ario dever´a ser
informado;
• Liberar um novo carro. O usu´ario dever´a fornecer um n´umero de vaga e a placa daquela vaga
dever´a ser retirada;
• Verificar status. Deve retornar a ocupa¸c˜ao atual do estacionamento no formato ”n´umero da vaga
Placa do carro” para as vagas ocupadas ou ”n´umero da vaga - Vazio” para as vagas vazias;
• Sair do programa.
alguem pode me ajudar com este exercicio? estou com dificuldades
estou usando metedo de pilhas para este, mais nao consigo localizar uma vaga vazia, e nao consigo tirar um veiculo da vaga

HMTLUnit how to get IMG url in javascript?

For HTMLunit prof here, can you tell if it's possible to get each url present in a javascript code.
For example, in this code, i'd like to get each ".jpg" url :
I mean, alle images in "photos" variable.
Thank you for your help
<script ngappstate>var ngAppState = {"advertising":{"triggerImbvpjs":false},"authentication":{"isBusy":false},"property":{"estate":{"id":8345497,"publisherId":785672,"pubDate":"2019-09-17T10:08:13.000+02:00","photos":["https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907"],"picturesResized":[{"lastModificationDate":"2019-09-17T10:09:19.080+02:00","ordering":1,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_1.jpg?cache=2019091009080","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.gif?cache=2019091009080","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.110+02:00","ordering":2,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_2.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.330+02:00","ordering":3,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_3.jpg?cache=2019091009330","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.gif?cache=2019091009347","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.347+02:00","ordering":4,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_4.jpg?cache=2019091009347","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.gif?cache=2019091009423","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.673+02:00","ordering":5,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_5.jpg?cache=2019091009673","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.gif?cache=2019091009673","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.737+02:00","ordering":6,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_6.jpg?cache=2019091009737","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.gif?cache=2019091009750","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.843+02:00","ordering":7,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_7.jpg?cache=2019091009843","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.gif?cache=2019091009860","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.970+02:00","ordering":8,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_8.jpg?cache=2019091009970","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.gif?cache=2019091009983","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.030+02:00","ordering":9,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_9.jpg?cache=2019091009030","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.gif?cache=2019091009047","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.110+02:00","ordering":11,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_A.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.250+02:00","ordering":12,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_B.jpg?cache=2019091009250","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.gif?cache=2019091009453","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":13,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_C.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.gif?cache=2019091009547","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":14,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_D.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.gif?cache=2019091009657","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":15,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_E.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":16,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_F.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":17,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_G.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":18,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_H.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":19,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_I.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":20,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_J.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":21,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_K.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":22,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_L.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.gif?cache=2019091009920","pictureOrientation":"LANDSCAPE"}],"flags":{"new":true,"defaultOrderingScore":1,"priceOrderingScore":279000,"dateOrderingScore":"2019-09-17T10:08:13.657+02:00","pricem2orderScore":0,"adQualityScore":90.87},"adType":"M","energy":{"energyConsumption":495,"yearlyTheoreticalTotalEnergyConsumption":109187,"EPCScore":"F","CO2emission":null,"EPCreferenceNumber":"20190811002958","Heating":"Gas","doubleGlazing":true,"epcreferenceNumber":"20190811002958"},"media":[{"type":"VIRTUAL_TOUR","content":{"value":"https://my.matterport.com/show/?m=jXVimgXaXwY&lang=fr&help=2&lp=1&hl=0&ts=1&st=5000&guides=0&qs=1' f"}}],"mainType":"HOUSE","subtype":"HOUSE","geographical":{"geo":{"latitude":50.4037765,"longitude":4.395336},"geoPoint":{"latitude":50.4037765,"longitude":4.395336},"hasSeaView":false,"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"}},"buyRent":"BUY","transactionSubtype":"BUY_REGULAR","activationStatus":"CODE_STATUS_ACTIVATED","description":{"title":"Magnifique maison de maitre 4 façades entièrement rénovée, 4","description":"!!!Rue de Cartier 56 Commune de Marchienne - au - Pont!!! https://www.youtube.com/watch?v=k_pd8XSxgoE ou n'hésitez pas à cliquer sur l'onglet MEDIA (sur la première photo) pour une visite virtuelle interactive. VISITES ET RENSEIGNEMENTS AU 0487 34 34 83 - Magnifique maison de maitre 4 façades entièrement rénovée, 4 chambres avec jardin. Comprenant caves, hall d'entrée, living, cuisine, bureau, salle de bains avec wc, double vasques, baignoire, douche italienne. 1°: hall de nuit, deux chambres. Au 2°: hall de nuit, deux chambres. Chauffage central au gaz, châssis TV PVC, plancher béton à tous les niveaux, cuisine Ducati prix d'achat 56.000€, alarme, adoucisseur d'eau. FAIRE OFFRE A PARTIR DE 279.000€. DESCRIPTIF COMPLET SUR LE","moreInfo":"WWW.LOPPORTUNITE.BE A TITRE INFORMATIF ET NON CONTRACTUEL."},"general":{"netFloorArea":220,"frontageNumber":4,"buildingCondition":"JUST_RENOVATED","availability":""},"interior":{"bedrooms":4,"bathroomNumber":1,"toiletsNumber":1,"kitchenSetup":"Installed","cellarProperty":true},"buildingRegulation":{"planningPermissionObtained":"NOT_SPECIFIED","asBuiltPlan":"NO","subdivisionPermit":"NOT_SPECIFIED","possiblePriorityPurchaseRight":"NOT_SPECIFIED","proceedingsForBreachOfPlanningRegulations":"NOT_SPECIFIED","floodZoneInfo":null},"financial":{"vatProfile":"VAT_INCLUDED","salePrice":279000,"cadastralIncome":803,"priceBasedOn":false,"isMinimumBid":false,"isPriceBased":false},"soldInfo":{"sold":false,"soldLabel":"NO_LABEL"},"contactInfo":{"phone":"+3271799549","email":"lopportunite#omniwebsites.be","mobile":"","idclient":785672,"clientType":"AGE","title":"L' OPPORTUNITE","location":{"geo":{"latitude":50.4115438,"longitude":4.381455},"geoPoint":{"latitude":50.4115438,"longitude":4.381455},"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"}},"logo":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","www":"http://www.lopportunite.be","ipiNo":"503906","referenceWithinSoftware":"2655","referenceWithinAgency":"2655 - 868","responsible":""},"land":{"surfaceAreaOfPlot":230}},"publishers":[{"id":785672,"ipiNo":"503906","geoPoint":{"latitude":50.4115438,"longitude":4.381455},"name":"L' OPPORTUNITE","logoUri":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","email":"lopportunite#omniwebsites.be","phones":["+3271799549"],"address":"Rue des Combattants 37","zip":6031,"locality":"Monceau-sur-sambre","description":{"text":"Nous vendons rapidement votre maison, appartement, immeuble de rapport, terrain,… et ce au meilleur prix.\r\n\r\n- ESTIMATION DE VOTRE BIEN\r\n- SERVICE PERSONNALISE A NOTRE CLIENTELE\r\n- MISSION DE VENTE CLAIRE ET PRECISE\r\n- PUBLICITE CIBLEE, VISITES ORGANISEES","language":"fr"},"timetable":{},"contactHours":"MT","contactHoursGsm":"MT","emails":[{"contactInformation":"lopportunite#omniwebsites.be","usage":"DEFAULT"}],"landLines":[{"contactInformation":"+3271799549","usage":"DEFAULT"}],"faxMachines":[{"contactInformation":"+3271315405","usage":"DEFAULT"}],"country":"be"}],"media":null,"status":1}};</script>
You wouldnt do something like that with htmlunit. Instead use Regular Expressions to search for those links. You can use this regular expression for the task: (http([a-zA-Z\/:\.0-9_]*)?.jpg). The example looks like this:
var reg= /(http([a-zA-Z\/:\.0-9_]*)?.jpg)/g;
var ngAppState = {"advertising":{"triggerImbvpjs":false},"authentication":{"isBusy":false},"property":{"estate":{"id":8345497,"publisherId":785672,"pubDate":"2019-09-17T10:08:13.000+02:00","photos":["https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907"],"picturesResized":[{"lastModificationDate":"2019-09-17T10:09:19.080+02:00","ordering":1,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.jpg?cache=2019091009047","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_1.jpg?cache=2019091009080","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_1.gif?cache=2019091009080","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.110+02:00","ordering":2,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.jpg?cache=2019091009097","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_2.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_2.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.330+02:00","ordering":3,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_3.jpg?cache=2019091009330","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_3.gif?cache=2019091009347","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.347+02:00","ordering":4,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.jpg?cache=2019091009330","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_4.jpg?cache=2019091009347","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_4.gif?cache=2019091009423","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.673+02:00","ordering":5,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.jpg?cache=2019091009657","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_5.jpg?cache=2019091009673","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_5.gif?cache=2019091009673","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.737+02:00","ordering":6,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.jpg?cache=2019091009737","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_6.jpg?cache=2019091009737","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_6.gif?cache=2019091009750","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.843+02:00","ordering":7,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.jpg?cache=2019091009843","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_7.jpg?cache=2019091009843","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_7.gif?cache=2019091009860","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:19.970+02:00","ordering":8,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.jpg?cache=2019091009953","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_8.jpg?cache=2019091009970","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_8.gif?cache=2019091009983","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.030+02:00","ordering":9,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.jpg?cache=2019091009017","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_9.jpg?cache=2019091009030","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_9.gif?cache=2019091009047","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.110+02:00","ordering":11,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.jpg?cache=2019091009093","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_A.jpg?cache=2019091009110","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_A.gif?cache=2019091009110","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.250+02:00","ordering":12,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.jpg?cache=2019091009233","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_B.jpg?cache=2019091009250","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_B.gif?cache=2019091009453","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":13,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.jpg?cache=2019091009453","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_C.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_C.gif?cache=2019091009547","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":14,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_D.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_D.gif?cache=2019091009657","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":15,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_E.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_E.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":16,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.jpg?cache=2019091009560","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_F.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_F.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.467+02:00","ordering":17,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.jpg?cache=2019091009467","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_G.jpg?cache=2019091009467","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_G.gif?cache=2019091009717","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":18,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_H.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_H.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":19,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_I.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_I.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.873+02:00","ordering":20,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.jpg?cache=2019091009717","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_J.jpg?cache=2019091009873","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_J.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":21,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.jpg?cache=2019091009873","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_K.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_K.gif?cache=2019091009907","pictureOrientation":"LANDSCAPE"},{"lastModificationDate":"2019-09-17T10:09:20.907+02:00","ordering":22,"pictureFormatLarge":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.jpg?cache=2019091009907","pictureFormatMedium":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/M_8345497_L.jpg?cache=2019091009907","pictureFormatSmall":"https://static.immoweb.be/photos/0/8/3/4/5/4/9/7/8345497_L.gif?cache=2019091009920","pictureOrientation":"LANDSCAPE"}],"flags":{"new":true,"defaultOrderingScore":1,"priceOrderingScore":279000,"dateOrderingScore":"2019-09-17T10:08:13.657+02:00","pricem2orderScore":0,"adQualityScore":90.87},"adType":"M","energy":{"energyConsumption":495,"yearlyTheoreticalTotalEnergyConsumption":109187,"EPCScore":"F","CO2emission":null,"EPCreferenceNumber":"20190811002958","Heating":"Gas","doubleGlazing":true,"epcreferenceNumber":"20190811002958"},"media":[{"type":"VIRTUAL_TOUR","content":{"value":"https://my.matterport.com/show/?m=jXVimgXaXwY&lang=fr&help=2&lp=1&hl=0&ts=1&st=5000&guides=0&qs=1' f"}}],"mainType":"HOUSE","subtype":"HOUSE","geographical":{"geo":{"latitude":50.4037765,"longitude":4.395336},"geoPoint":{"latitude":50.4037765,"longitude":4.395336},"hasSeaView":false,"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Montigny-le-Tilleul","postalcode":"6110","street":"Rue de Cartier","number":"56","box":"","buildingName":"","region":"WALLONIE"}},"buyRent":"BUY","transactionSubtype":"BUY_REGULAR","activationStatus":"CODE_STATUS_ACTIVATED","description":{"title":"Magnifique maison de maitre 4 façades entièrement rénovée, 4","description":"!!!Rue de Cartier 56 Commune de Marchienne - au - Pont!!! https://www.youtube.com/watch?v=k_pd8XSxgoE ou n'hésitez pas à cliquer sur l'onglet MEDIA (sur la première photo) pour une visite virtuelle interactive. VISITES ET RENSEIGNEMENTS AU 0487 34 34 83 - Magnifique maison de maitre 4 façades entièrement rénovée, 4 chambres avec jardin. Comprenant caves, hall d'entrée, living, cuisine, bureau, salle de bains avec wc, double vasques, baignoire, douche italienne. 1°: hall de nuit, deux chambres. Au 2°: hall de nuit, deux chambres. Chauffage central au gaz, châssis TV PVC, plancher béton à tous les niveaux, cuisine Ducati prix d'achat 56.000€, alarme, adoucisseur d'eau. FAIRE OFFRE A PARTIR DE 279.000€. DESCRIPTIF COMPLET SUR LE","moreInfo":"WWW.LOPPORTUNITE.BE A TITRE INFORMATIF ET NON CONTRACTUEL."},"general":{"netFloorArea":220,"frontageNumber":4,"buildingCondition":"JUST_RENOVATED","availability":""},"interior":{"bedrooms":4,"bathroomNumber":1,"toiletsNumber":1,"kitchenSetup":"Installed","cellarProperty":true},"buildingRegulation":{"planningPermissionObtained":"NOT_SPECIFIED","asBuiltPlan":"NO","subdivisionPermit":"NOT_SPECIFIED","possiblePriorityPurchaseRight":"NOT_SPECIFIED","proceedingsForBreachOfPlanningRegulations":"NOT_SPECIFIED","floodZoneInfo":null},"financial":{"vatProfile":"VAT_INCLUDED","salePrice":279000,"cadastralIncome":803,"priceBasedOn":false,"isMinimumBid":false,"isPriceBased":false},"soldInfo":{"sold":false,"soldLabel":"NO_LABEL"},"contactInfo":{"phone":"+3271799549","email":"lopportunite#omniwebsites.be","mobile":"","idclient":785672,"clientType":"AGE","title":"L' OPPORTUNITE","location":{"geo":{"latitude":50.4115438,"longitude":4.381455},"geoPoint":{"latitude":50.4115438,"longitude":4.381455},"postal":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"},"postalAddr":{"country":"BE","province":"Hainaut","district":"Charleroi","locality":"Monceau-sur-sambre","postalcode":"6031","street":"Rue des Combattants 37","number":"","box":"","region":"WALLONIE"}},"logo":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","www":"http://www.lopportunite.be","ipiNo":"503906","referenceWithinSoftware":"2655","referenceWithinAgency":"2655 - 868","responsible":""},"land":{"surfaceAreaOfPlot":230}},"publishers":[{"id":785672,"ipiNo":"503906","geoPoint":{"latitude":50.4115438,"longitude":4.381455},"name":"L' OPPORTUNITE","logoUri":"https://static.immoweb.be/logos/785672.gif?cache=2017061204440","email":"lopportunite#omniwebsites.be","phones":["+3271799549"],"address":"Rue des Combattants 37","zip":6031,"locality":"Monceau-sur-sambre","description":{"text":"Nous vendons rapidement votre maison, appartement, immeuble de rapport, terrain,… et ce au meilleur prix.\r\n\r\n- ESTIMATION DE VOTRE BIEN\r\n- SERVICE PERSONNALISE A NOTRE CLIENTELE\r\n- MISSION DE VENTE CLAIRE ET PRECISE\r\n- PUBLICITE CIBLEE, VISITES ORGANISEES","language":"fr"},"timetable":{},"contactHours":"MT","contactHoursGsm":"MT","emails":[{"contactInformation":"lopportunite#omniwebsites.be","usage":"DEFAULT"}],"landLines":[{"contactInformation":"+3271799549","usage":"DEFAULT"}],"faxMachines":[{"contactInformation":"+3271315405","usage":"DEFAULT"}],"country":"be"}],"media":null,"status":1}};
var text = JSON.stringify(ngAppState);
while((result = reg.exec(text)) !== null) {
console.log(result[0]);
}

termvector counting keywords in Elasticsearch

I am using elasticsearch 1.5.2.
I want to get the number of time that every keyword is repeated on a stored products in my index.
keywords are : sauces, crèmes, gâteaux.
these are my products:
POST test/prod
{
"titre": "product 1",
"catégorie": "Epicerie",
"informations": "Sauces, potages, crèmes & gâteaux. / Composé exclusivement d'amidon de maïs, il vous permet d'alléger vos gâteaux et crêpes ou bien d'épaissir vos sauces, soupes et crèmes. Il rend vos desserts onctueux et légers : il suffit simplement de remplacer la moitié de votre farine par la fécule de maïs. // Poids net : 0,400 kg // Veuillez contacter notre responsable de mise en marché : Distribué par Système U - BP 30159 - 94533 Rungis cedex"
}
POST test/prod
{
"titre": "product 2",
"catégorie": "Fruits",
"informations": "A conserver dans un endoit frais et sec. Idée recette: Madeleines fourrées au chocolat Ingrédients (pour une vingtaine de madeleines) : 100g de farine, 90g fécule de maïs,1 sachet de levure, 3 oeufs,125g de sucre,190g de beurre,1cuillère à soupe d'eau de fleur d'oranger, 1 vingtaine de carrés de chocolat Préparation : Mélangez la farine, la fécule et la levure. Ajoutez le sucre et les oeufs battus. Faites fondre le beurre à feu doux et incorporer le au précédent mélange. Mélangez bien et laissez reposer la pâte une heure au réfrigérateur. Préchauffez le four à 220°C. Beurrez les moules à madeleine, garnissez les moules de moitié, ajoutez au centre un petit carré de chocolat et recouvrez de l'appareil à madeleine. Enfournez pour 5 minutes puis baissez le four à 180°C et poursuivez la cuisson 5 minutes. Sortez les madeleines, laissez-les tiédir et démoulez-les."
}
I want to get a result in order desc like this for example:
product 1:
sauces repeated :9
crèmes repeated :8
gâteaux repeated: 2
product 2:
sauces repeated :8
crèmes repeated :6
gâteaux repeated: 4
I used termvector in only one field, however I want to get the result from all document. It was like this:
POST test/prod/1/_termvector
{
"fields" : ["informations"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}
But I get as a result a very long list which contains all words in this field. I want only as a result my 3 keywords.

AWK: Compare two files and calculate a percentage based on differences

I have two files as these..
What I need is to count the number of times each ID appears on each file and calculate the difference to obtain percentage of success. Furthermore, when the third column of the first file contains the word NONE and the same column of the second file contains a number, indicate that has been obtained category for that ID.
File 1:
ID;Coments;Category
2;es un anuncio interesante que le puede servir para alguien;321
3;es un anuncio de un banco que quiere presentarse como una compañía;NONE
4;es un anuncio de un banco que ofrece prestamos para empresas.;70
5;credito pyme bana para hacer crecer tu negocio;50
5;credito pyme bana para hacer crecer tu negocio;52
5;credito pyme bana para hacer crecer tu negocio;70
5;credito pyme bana para hacer crecer tu negocio;71
6;comercial que te hace pensar en considerar a bana para poner tu negocio;50
6;comercial que te hace pensar en considerar a bana para poner tu negocio;71
7;este anuncio da una breve explicación sobre el tratamiento de hemodialisis;50
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;50
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;52
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;70
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;71
9;bonito;NONE
File 2:
ID;Coments;Category
2;es un anuncio interesante que le puede servir para alguien;321
3;es un anuncio de un banco que quiere presentarse como una compañía;57
4;es un anuncio de un banco que ofrece prestamos para empresas.;50
5;credito pyme bana para hacer crecer tu negocio;52
6;comercial que te hace pensar en considerar a bana para poner tu negocio;50
7;este anuncio da una breve explicación sobre el tratamiento de hemodialisis;210
8;un anucio de bana donde muestra que se puede pedir un crédito para emprender;50
9;bonito;303
Desired Output:
For the ID-2, we have achieved a 100% success rate.
For the ID-3, we have achieved a category.
For the ID-4, we have achieved a 100% success rate.
For the ID-5, we achieved a 25% success rate.
For the ID-5, we achieved a 50% success rate.
For the ID-7, we have achieved a 100% success rate.
For the ID-8, we have achieved a 25% success rate.
For the ID-9, we have achieved a category.
One approach could be this small. But of course, I need to calculate percentages and print it on like my desired output format.
awk 'BEGIN { FS=OFS=";" } NR==FNR{cnt[$1]++; next} { cnt2[$1]++;} END{ for (ID in cnt){ print ID, "CAT: "cnt[ID],"Manual: "cnt2[ID];}}'
Awk is for this
awk -F ';' '
FNR==1{next}
FNR==NR{C1[$1]++;N1[$1]=($3!~/NONE/);next}
{C2[$1]++;if($3!~/NONE/)N2[$1]++}
END{
for(c in C1){
if((N1[c]==0)&&(C2[c]>0)&&(N2[c]>0)){
S="we have achieved a category."
}
else S=sprintf( "we have achieved a %d%% success rate.", C2[c]*100/C1[c])
printf "For the ID-%d, %s\n", c, S
}
}' file1 file2

Searching at bibliographyc list (prolog)

I have this prolog code:
libro(autor('Chomsky', 'Noah'),
titulo('Aspectos de la Teoría de la sintaxis'),
editorial('Madrid', 'Aguilar'),
fecha(1970)).
libro(autor('Matthews', 'P'),
titulo('Inflectional Morphology'),
editorial('Cambridge', 'Cambridge University Press'),
fecha(1972)).
libro(autor('Chomsky', 'Noah'),
titulo('Estructuras sintácticas'),
editorial('Mexico', 'Siglo XXI'),
fecha(1974)).
I need to find all books written by Chomsky (in my case). What is the rutine to obtain them?
Thank You
You just need to match on the pattern autor('Chomsky',_) as below:
?- libro(autor('Chomsky',_),T,E,Y).
T = titulo('Aspectos de la Teoría de la sintaxis'),
E = editorial('Madrid', 'Aguilar'),
Y = fecha(1970) ;
T = titulo('Estructuras sintácticas'),
E = editorial('Mexico', 'Siglo XXI'),
Y = fecha(1974).
You need to type a semicolon to fetch the next result.
You could also use findall to get all results as a list, for example:
?- findall(libro(T,E,Y),libro(autor('Chomsky',_),T,E,Y),R).
R = [libro(titulo('Aspectos de la Teoría de la sintaxis'), editorial('Madrid', 'Aguilar'), fecha(1970)), libro(titulo('Estructuras sintácticas'), editorial('Mexico', 'Siglo XXI'), fecha(1974))].

Resources