Add label to webform options in Drupal 8 - drupal

I'm trying to group the option values by categories, and I want to add a label for each category. For example:
group A
Doctor: Doctor
group B
Nurse: Nurse
Student: Student
Others: Others
Can I do that without custom or alter function? My YAML:
Doctor: Doctor
Nurse: Nurse
Student: Student
Others: Others

I found out the solution.
Ex:
pets:
- Cat
- Dog
- Goldfish

Related

Understanding the results of Vespa BERT embeddings

I am copying parts of the Simple Semantic Search sample application at https://github.com/vespa-engine/sample-apps/tree/master/simple-semantic-search to get started with dense vector search.
I have indexed our website, dividing every page in paragraph-size docs. Some docs only consist of a name of a person (a single <div> on the website)
With many queries these very short docs get ranked on top although there is no apparent similarity. Querying for "teacher" gives the results below. Why do "Kelly Tracey" and "Luke Hanley" have such a high similarity?
Doc
Relevance score
Professor Jake Dalton
0.4810788561826608
Kelly Tracey
0.4618036348887372
Prof. Sarah Jacoby
0.4605411864409834
Luke Hanley
0.45709536853590715
Dr. Elizabeth McDougal
0.4570338357051837
Casey Kemp
0.4508383490617062
I removed the bm25 part of the ranker for testing
rank-profile simple_semantic inherits default{
inputs {
query(e) tensor<float>(x[384])
}
first-phase {
expression: closeness(field, myEmbedding)
}
}
Query
params = {
"yql": "select * from kvp_semantic_2 where {targetHits: 100}nearestNeighbor(myEmbedding, e)",
"input.query(e)": 'embed({"teacher"})',
"ranking.profile": "simple_semantic",
"hits": 10
}
The component in services.xml is straight from the sample app
<component id="bert" class="ai.vespa.embedding.BertBaseEmbedder" bundle="model-integration">
<config name="embedding.bert-base-embedder">
<transformerModel path="model/minilm-l6-v2.onnx"/>
<tokenizerVocab path="model/bert-base-uncased.txt"/>
</config>
</component>
The same happens with many other queries, like "biography", but not with some, like "translator".
The model here is just 90 Mb. I don't think you can expect it to contain information about which individual humans are teachers or similar.
When you query for teacher the 6 docs you retrieve are all names of humans and at least two of them are even professors. I think that's pretty good.

How to get recommendations based on previous orders in neo4j?

I am trying to work on neo4j for the first time. I have written the following:
LOAD CSV WITH HEADERS FROM "file:///restaurant_data.csv" AS data
MERGE(n1:Customer{Name:data.Name, Latitude:toFloat(data.Latitude),Longitude:toFloat(data.Longitude)})
MERGE(n2:Orders{OrderId:data.Order_ID,OrderTimestamp:data.Order_ts,FoodName:data.Food_Item})
MERGE(n3:Restaurant{RestaurantName:data.Restaurant, RestLat:toFloat(data.Rest_lat), RestLong:toFloat(data.Rest_long)})
MERGE (n1)-[r1:PLACES_ORDER]->(n2)
MERGE (n2)-[r2:BELONGS_TO]->(n3)
MERGE (n3)-[r3:SERVES]->(n2)
RETURN *;
i can share the csv if needed.
I want to find recommendation of restaurant for customer based on his top 5 previous orders by order_timestamp and distance between restaurant and customer should be less than 5 kms.
MATCH(n1:Customer{Name:"Angy"})
MATCH(n1)-[:PLACES_ORDER]->(n2:Orders)<-[:SERVES]-(rec:Restaurant)
RETURN n2.FoodName, n2.OrderTimestamp, n3.RestaurantName
ORDER BY n2.OrderTimestamp
LIMIT 5
This gives me only top 5 orders, how do I find restaurants serving those orders?
My file link: https://docs.google.com/spreadsheets/d/e/2PACX-1vTc35TBanV3Uk5gbCeEFeJkm2YAhbJPLnpS0KzmYErVRulvbXCWdSZ7xiKUfnCZQQUt-1ArabgmAGmL/pubhtml
Your query did not work. This worked:
MATCH(:Customer{Name:"Angy"})-[:PLACES_ORDER]->(o:Orders)
WITH o ORDER BY o.OrderTimestamp DESC LIMIT 5
WITH [o.FoodName] as foods
MATCH (r:Restaurant)-[:SERVES]->(n:Orders)
WHERE (n.FoodName in foods)
RETURN distinct r.RestaurantName,foods

Looping through a dataframes, collecting data, creating new dataframes

I have the below dataframe (in reality it spans a couple hundred rows of the same data).
project_number hours team_member project_lead team_member_email
RR711-132 4 Isaac Bell Dan Case ib#blank.com
RR711-135 10 Isaac Bell Lawrence Cowan ib#blank.com
USU887-101 50 Keith Olsen Aaron Anderson aa#blank.com
VE902-102 30 Chase Harmon Isaac Bell ch#blank.com
SS99-133 50 Chase Harmon Jack Spain ch#blank.com
The goal is to send an email to the team member, that includes a table with the details of the project_number, hours, and the project lead.
I am using RDCOMClient to send out the email, and the "purrr" package to loop over the vectors.
mail_fun <- function(name, mail) {
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = mail
outMail[["subject"]] = "Project hours for next week"
outMail[["HTMLBody"]] = paste0("Dear ", name, "<p>Testing sending hours through R</>")
## send it
outMail$Send()
}
map2(test.df$team_member, test.df$email, ~mail_fun(name = .x, mail = .y))
I know the code needs modification, but the looping works as well as the sending of the email. What I cannot figure out, is how to create a table (dataframe) that is specifically for the team_member and have it sent through email.
For example, an email would be sent to Isaac Bell, and in the body of that email would be a table that looked like this (I don't know how to make a good-looking table here):
Isaac,
You have been assigned the following hours to the following project for this week:
Project Number Hours Project Lead
RR711-132 4 Dan Case
RR711-135 10 Lawrence Cowan
The key here is to use the split() function. Create dataframes within a list for each individual team member and then loop through those dataframes and send the email.

woocommerce variation displaying all option even if it's not related to that variantion

Hello,
I have 2 variation in woocommerce first is series and second is name like this:
Series : and Name :
in Series two type of Series A and B
in Name lots of names
Series : Name:
A ANNN1,ANNN2,ANNN3
B BMMM1,BMMM2,BMMM3
Like you can See A-Name is related to A series and B-Name to B series
But when see product page Name: variation shows all option
Even I choose Series A or B
ANNN1
ANNN2
ANNN3
BMMM1
BMMM2
BMMM3
So what I should I do to show specific Name to related that Series Like this
If I choose Series A
Series: A
Name: ANNN1
ANNN2
ANNN3
If I choose Series B
Series : B
Name :BMMM1
BMMM2
BMMM3
Check out this plugin and scroll down where it says "Set dependency between the options"
https://yithemes.com/themes/plugins/yith-woocommerce-product-add-ons/
You can even test out the features before buying by going on to this website http://plugins.yithemes.com/yith-woocommerce-product-add-ons/product/custom-post/ and using the top botton for launching admin demo

Getting numbers on Y-axis to show up as percentages with code from a Highcharts code generator tool?

I'm the founder of a nonprofit news org that is a member of INN (The Institute for Nonprofit News). Some of us members have our wordpress news sites hosted for free through INN and therefore, cannot just install any plugins we want. INN must approve that first.
So the only way I have been able to use Highcharts is through this tool from Builtvisible that is a Highcharts code generator: https://builtvisible.com/highcharts-generator/
I've made a column chart here that is for a newborn screening story and is the Top-10 hospitals with the highest percentage of late samples. So when I hover over each bar I just want the tooltip to display 73%, instead of 73 like it does right now.
Any help would be greatly appreciated. I'm not very knowledgeable with coding and have tried a few things, even contacting the person who built this code generator but I can't figure out how to make it work. For another column chart also I have the same issue but I need it to separate the thousands with a comma instead of a space. So I would like 1,000 to read like that, instead of 1 000.
Here is my code from the generator where I need it to display percentages:
<div id="chart_container"></div><script src="//code.highcharts.com/adapters/standalone-framework.js"></script><script src="//code.highcharts.com/highcharts.js"></script><script>new Highcharts.Chart({"chart":{"backgroundColor":"#fefefe","renderTo":"chart_container","type":"column"},"title":{"text":"Top-10 facilities for lateness"},"colors":["#476974","#3ca1c1","#4ccbf4","#96dff6","#c9e8f6"],"legend":{"enabled":true,"margin":30},"xAxis":{"tickWidth":0,"labels":{"y":20},"categories":["Facilities with the highest overall percentage of late samples"]},"yAxis":{"tickWidth":0,"labels":{"y":-5},"title":{"text":"Percentage (%)"}},"series":[{"name":"NE MT HLTH SERVICES WOLF POINT","data":[73]},{"name":"CLARK FORK VALLEY HOSPITAL","data":[71]},{"name":"MARCUS DALY HOSPITAL","data":[68]},{"name":"ST JOSEPH HOSPITAL","data":[65]},{"name":"SIDNEY HEALTH CENTER","data":[64]},{"name":"THE BIRTH CENTER, MISSOULA","data":[63]},{"name":"GLENDIVE MEDICAL CENTER","data":[59]},{"name":"FRANCES MAHON DEAC HOSPITAL","data":[57]},{"name":"ST LUKE HOSPITAL","data":[55]},{"name":"CABINET PEAKS MEDICAL CENTER","data":[53]}]});</script>
Here is the other column chart where I would like the thousands to be separated by a comma when you hover over each column and it brings up the tool tip. This is also code from the Builtvisible Highcharts code generator:
<div id="chart_container2"></div>
<script src="//code.highcharts.com/adapters/standalone-framework.js"></script><script src="//code.highcharts.com/highcharts.js"></script><script>// <![CDATA[
new Highcharts.Chart({"chart":{"backgroundColor":"#fefefe","renderTo":"chart_container2","type":"column"},"title":{"text":"Wisconsin Lab: On-Time Performance"},"colors":["#6AA121","#2069A1","#A12069","#96dff6","#c9e8f6"],"legend":{"enabled":true,"margin":30},"xAxis":{"tickWidth":0,"labels":{"y":20},"categories":["2011","2012","2013","2014"]},"yAxis":{"tickWidth":0,"labels":{"y":-5},"title":{"text":"Number of samples on-time vs. late"}},"series":[{"name":"On-time","data":[7006,5492,5589,7069]},{"name":"Late","data":[3857,4979,5189,4105]},{"name":"Very Late","data":[701,1075,1074,776]}]});
// ]]></script>
This "tool code" is just regular Highcharts code, and does nothing more than generate it for you.
For the first chart you can use valueSuffix to add a percentage sign after the value. Code:
plotOptions: {
column: {
tooltip: {
valueSuffix: '%'
}
}
}
For the second chart you can use the global thousandSep option to get comma separators. Code:
Highcharts.setOptions({
lang: {
thousandsSep: ','
}
});
See this JSFiddle demonstration of both code segments.

Resources