qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
38,470,462
I have the following: ``` public class Car{ public Car() {//some stuff } private Car [] carmodels ; public Car [] getCarModel() { return this.carmodels; } public void setcarModel(Car [] carmodels ) { this.carmodels = carmodels; } ``` Now on my test class, I have something like this ``` public void main (String [] args) { Car car1= new Car(); car.setcarModel(new Car[5]);//here i create an array of Car for(int i =0;i<5;i++) { // how can i created 5 cars and set them based on index i // car.setCarModel[new Car()]???? } } ``` How can do that? I could use a temp array of type Car which I can pass to my Setter just after the loop. But is there a better way?
2016/07/20
[ "https://Stackoverflow.com/questions/38470462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3841581/" ]
Add a setter that accepts an index: ``` public void setCarModel(int index, Car carModel) { this.cardmodels[index] = carModel; } ``` Then, inside your loop, call ``` car.setCarModel(i, new Car()); ```
``` for(int i =0;i<5;i++) { car.getCarModel()[i] =new Car(); } ``` or Write another overloaded setter by passing index. ``` public void setCarModel(int index, Car c) { carmodels[index] = c; } for(int i =0;i<5;i++) { car.setCarModel(i, new Car()); } ```
38,470,462
I have the following: ``` public class Car{ public Car() {//some stuff } private Car [] carmodels ; public Car [] getCarModel() { return this.carmodels; } public void setcarModel(Car [] carmodels ) { this.carmodels = carmodels; } ``` Now on my test class, I have something like this ``` public void main (String [] args) { Car car1= new Car(); car.setcarModel(new Car[5]);//here i create an array of Car for(int i =0;i<5;i++) { // how can i created 5 cars and set them based on index i // car.setCarModel[new Car()]???? } } ``` How can do that? I could use a temp array of type Car which I can pass to my Setter just after the loop. But is there a better way?
2016/07/20
[ "https://Stackoverflow.com/questions/38470462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3841581/" ]
See the method `getCarModel`? That method returns a `Car[]` right? That means you can do anything you can do on an array on `car1.getCarModel()`! So how do you set an item at an index of an array? You do this: ``` someArray[someIndex] = someValue; ``` If we apply this to the array returned by `car1.getCarModel`, ``` car1.getCarModel()[i] = new Car(); ``` That's the way to do it. Alternatively, you ca write another method in `Car` that sets an item in the car models array: ``` public void setItemInCarModels(int index, Car item) { carModels[index] = item; } ``` Simple! Btw, your model makes no sense...
``` for(int i =0;i<5;i++) { car.getCarModel()[i] =new Car(); } ``` or Write another overloaded setter by passing index. ``` public void setCarModel(int index, Car c) { carmodels[index] = c; } for(int i =0;i<5;i++) { car.setCarModel(i, new Car()); } ```
10,424,848
I have installed all the necessary files from android site, but when I run my emulator it just displays "ANDROID" and nothing else. I am using Intel Dual core (2.20GHz), ASUS motherboard and 3gb of RAM. Whats the prob I couldnt understand.. Even one of my friend using Intel Dual core(1.80GHz) with 1gb of RAM running smoothly then whats my problem.
2012/05/03
[ "https://Stackoverflow.com/questions/10424848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1349138/" ]
The emulator is slow becasue it is, of all things, emulating a completely different architecture (arm), and if it's the first time you've started it it has to create the memory file toi emulate the SD card you told it was there. My bet would be that you simply didn't wait long enough for it to boot up. You can save yourself some time by checking the option to save snapshots and start from them (it'll save you start time after the first time at least). Another emulator speed-up is to open your run configuration for whatever app you are going to run, click on the "Target" tab, and check the box to "Disable Boot Animation".
The Emulator must be booting. Just waiting for it. The time is depending on your machine.
10,424,848
I have installed all the necessary files from android site, but when I run my emulator it just displays "ANDROID" and nothing else. I am using Intel Dual core (2.20GHz), ASUS motherboard and 3gb of RAM. Whats the prob I couldnt understand.. Even one of my friend using Intel Dual core(1.80GHz) with 1gb of RAM running smoothly then whats my problem.
2012/05/03
[ "https://Stackoverflow.com/questions/10424848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1349138/" ]
The emulator is slow becasue it is, of all things, emulating a completely different architecture (arm), and if it's the first time you've started it it has to create the memory file toi emulate the SD card you told it was there. My bet would be that you simply didn't wait long enough for it to boot up. You can save yourself some time by checking the option to save snapshots and start from them (it'll save you start time after the first time at least). Another emulator speed-up is to open your run configuration for whatever app you are going to run, click on the "Target" tab, and check the box to "Disable Boot Animation".
Or you might want to look at the GPU support that comes with the new SDK. It's much faster <http://android-developers.blogspot.com/2012/04/faster-emulator-with-better-hardware.html>
8,324,359
I am a beginner in Java programming. Using JavaMail API, I wrote a program to send emails. Now I need to create a front end and connect those. I use only Notepad to write programs, I don't use any IDE. How to create front end easily and connect to my program? My program is: ```java import javax.mail.*; import javax.mail.internet.*; import java.util.Properties; import java.util.*; public class Mailer { public void Mailer() throws Exception { String usrname; String pwd; Scanner in = new Scanner(System.in); System.out.println("\nEnter the gmail user name :"); usrname = in.next(); System.out.println("\nEnter the Password :"); pwd = in.next(); String HOST_NAME = "smtp.gmail.com"; int HOST_PORT = 465; Properties props = new Properties(); props.put("mail.transport.protocol", "smtps"); props.put("mail.smtps.host", HOST_NAME); props.put("mail.smtps.auth", "true"); Session mailSession = Session.getDefaultInstance(props); Transport transport = mailSession.getTransport(); String toadd; System.out.println("\nEnter the Recipient Address:"); toadd = in.next(); MimeMessage message = new MimeMessage(mailSession); System.out.println("\nEnter the Subject:"); String sub = in.nextLine(); message.setSubject(sub); System.out.println("\nEnter the message body:"); String body = in.nextLine(); message.setContent(body, "text/plain"); message.addRecipient(Message.RecipientType.TO, new InternetAddress(toadd)); transport.connect(HOST_NAME, HOST_PORT, usrname, pwd); transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO)); transport.close(); System.out.println("Mail Sent successfully!!!!"); System.exit(0); } public static void main(String[] args) throws Exception { System.out.println("*******************Welcome to Mailer*************************"); Mailer mail = new Mailer(); mail.Mailer(); } } ```
2011/11/30
[ "https://Stackoverflow.com/questions/8324359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1073084/" ]
1. Factor out a method which takes parameters and do the email sending. No system.out and system.in allowed in this method. 2. For a test, you can drive this method with your existing code parts which reads parameters from console. 3. Make a GUI form which contains all input fields and probably some button. Your code will start something like this: JFrame f = new JFrame(); f.add(new JLabel("to")); ... f.setVisible(true); You have to learn a lot about component layouts. This code can be in the 'main' method for simplicity. 4. Wire your frontend with the backend: create an actionListener method on the button which collects parameters from the input fields (getText()) and invokes the email sender method. That's all. :)
You can make packages. Different Packages for different purposes. Like you can create a package to get only your front end classes and other package containing your above class to send emails. Then you can call methods of this class from your front end classes. For making front end, you can use Swings to create GUI based front end or you can create CUI based front end too from Notepad. It is not mandatory to use any IDE but that just makes easy to code.
1,644,694
$$a^2+ab+b^2\ge 3(a+b-1)$$ $a,b$ are real numbers using $AM\ge GM$ I proved that $$a^2+b^2+ab\ge 3ab$$ $$(a^2+b^2+ab)/3\ge 3ab$$ how do I prove that $$3ab\ge 3(a+b-1)$$ if I'm able to prove the above inequality then i'll be done
2016/02/07
[ "https://math.stackexchange.com/questions/1644694", "https://math.stackexchange.com", "https://math.stackexchange.com/users/300970/" ]
**Hint**: Let $a=x+1$ and $b=y+1$ (in the original inequality).
Follow [@BarryCipra](https://math.stackexchange.com/a/1644721/307483)'s hint of letting $a=x+1$ and $b=y+1$: $$(x+1)^2+(x+1)(y+1)+(y+1)^2 \geq 3((x+1)+(y+1)-1)$$ Expand the left side and simplify the right side: $$x^2+2x+1+xy+x+y+1+y^2+2y+1 \geq 3(x+y+1)$$ Simplify the left side and distribute the $3$ on the right side: $$x^2+xy+y^2+3x+3y+3 \geq 3x+3y+3$$ Subtract both sides by $3x+3y+3$: $$x^2+xy+y^2 \geq 0$$ Now, to prove this. we need to make some changes. We know that $xy \geq \lvert xy \rvert$. We also know that $\lvert xy \rvert \geq -\lvert xy \rvert$ because $\lvert xy \rvert$ is non-negative and non-negative numbers are always greater than or equal to their negatives. Finally, we have $-\lvert xy \rvert \geq -2\lvert xy \rvert$ because a non-positive number added to itself is always less than or equal to the original (e.g. $-2+(-2) \leq -2$, $-1+(-1) \leq -1$, $0+0 \leq 0$). Therefore, by the Transitive Property of Equality, we have $xy \geq -2\lvert xy \rvert$ and by adding $x^2+y^2$ by both sides of the inequality, we have $x^2+xy+y^2 \geq x^2-2\lvert xy \rvert+y^2$. This means we only need to prove the latter is non-negative to prove the former is non-negative, so we've reduced the problem to: $$x^2-2\lvert xy \rvert+y^2 \geq 0$$ Now, we know that $x^2=\lvert x \rvert^2$, $y^2=\lvert y\rvert^2$, and $\lvert xy \rvert=\lvert x \rvert \lvert y \rvert$, so we can substitute to get everything in terms of $\lvert x \rvert$ and $\lvert y \rvert$: $$\lvert x \rvert^2-2\lvert x \rvert \lvert y \rvert+\lvert y \rvert^2 \geq 0$$ Clearly, this is the same as $(\lvert x \rvert - \lvert y \rvert)^2$: $$(\lvert x \rvert - \lvert y \rvert)^2 \geq 0$$ This is obviously true because the square of a real number is always non-negative. Thus, by proving this is non-negative, we have proven that $x^2+xy+y^2$ is non-negative by our previous argument, which proves the whole inequality.
1,644,694
$$a^2+ab+b^2\ge 3(a+b-1)$$ $a,b$ are real numbers using $AM\ge GM$ I proved that $$a^2+b^2+ab\ge 3ab$$ $$(a^2+b^2+ab)/3\ge 3ab$$ how do I prove that $$3ab\ge 3(a+b-1)$$ if I'm able to prove the above inequality then i'll be done
2016/02/07
[ "https://math.stackexchange.com/questions/1644694", "https://math.stackexchange.com", "https://math.stackexchange.com/users/300970/" ]
This type of inequality can be proved in the similar way like this: $$ a^2 + ab + b^2 - 3(a + b - 1) = a^2 + ab + b^2 - 3a - 3b + 3 $$ $$ = a^2 - 2a + 1 + b^2 - 2b + 1 + ab -a -b + 1 = (a - 1)^2 + (b-1)^2 +(a-1)(b-1) $$ $$\ge 2|a-1||b-1| - (a -1)(b-1) \ge 0$$ The last one comes from AM-GM inequality.
Follow [@BarryCipra](https://math.stackexchange.com/a/1644721/307483)'s hint of letting $a=x+1$ and $b=y+1$: $$(x+1)^2+(x+1)(y+1)+(y+1)^2 \geq 3((x+1)+(y+1)-1)$$ Expand the left side and simplify the right side: $$x^2+2x+1+xy+x+y+1+y^2+2y+1 \geq 3(x+y+1)$$ Simplify the left side and distribute the $3$ on the right side: $$x^2+xy+y^2+3x+3y+3 \geq 3x+3y+3$$ Subtract both sides by $3x+3y+3$: $$x^2+xy+y^2 \geq 0$$ Now, to prove this. we need to make some changes. We know that $xy \geq \lvert xy \rvert$. We also know that $\lvert xy \rvert \geq -\lvert xy \rvert$ because $\lvert xy \rvert$ is non-negative and non-negative numbers are always greater than or equal to their negatives. Finally, we have $-\lvert xy \rvert \geq -2\lvert xy \rvert$ because a non-positive number added to itself is always less than or equal to the original (e.g. $-2+(-2) \leq -2$, $-1+(-1) \leq -1$, $0+0 \leq 0$). Therefore, by the Transitive Property of Equality, we have $xy \geq -2\lvert xy \rvert$ and by adding $x^2+y^2$ by both sides of the inequality, we have $x^2+xy+y^2 \geq x^2-2\lvert xy \rvert+y^2$. This means we only need to prove the latter is non-negative to prove the former is non-negative, so we've reduced the problem to: $$x^2-2\lvert xy \rvert+y^2 \geq 0$$ Now, we know that $x^2=\lvert x \rvert^2$, $y^2=\lvert y\rvert^2$, and $\lvert xy \rvert=\lvert x \rvert \lvert y \rvert$, so we can substitute to get everything in terms of $\lvert x \rvert$ and $\lvert y \rvert$: $$\lvert x \rvert^2-2\lvert x \rvert \lvert y \rvert+\lvert y \rvert^2 \geq 0$$ Clearly, this is the same as $(\lvert x \rvert - \lvert y \rvert)^2$: $$(\lvert x \rvert - \lvert y \rvert)^2 \geq 0$$ This is obviously true because the square of a real number is always non-negative. Thus, by proving this is non-negative, we have proven that $x^2+xy+y^2$ is non-negative by our previous argument, which proves the whole inequality.
55,577,262
Using `@WebMvcTest` will auto-configure all web layer beans by looking for a `@SpringBootConfiguration` class (such as `@SpringBootApplication`). If the configuration class is in a different package and can't be found by scanning, can I provide it directly to `@WebMvcTest`?
2019/04/08
[ "https://Stackoverflow.com/questions/55577262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9773274/" ]
The following will point to the correct `@SpringBootApplication` class: ``` @RunWith(SpringJUnit4ClassRunner.class) @WebMvcTest(controllers = {MyController.class}) @ContextConfiguration(classes={MySpringBootApplicationClass.class}) public class MyControllerTest { //... } ```
If you are using ***@WebMvcTest*** for your test , it means you are focusing mainly on testing the spring mvc layer and not going any deeper into the application. > > So this annotation can be used only when a test ***focuses on Spring > MVC components*.** By default, tests annotated with @WebMvcTest will > also auto-configure Spring Security and MockMvc (include support for > HtmlUnit WebClient and Selenium WebDriver). For more fine-grained > control of MockMVC the @AutoConfigureMockMvc annotation can be > used.Typically ***@WebMvcTest*** is used in combination with > ***@MockBean*** or ***@Import*** to create any collaborators required by your *@Controller* beans. > > > ``` import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration @Import({ CustomerConfig.class, SchedulerConfig.class }) public class AppConfig { } ``` You can then import this configuration class using `@import` in the `@WebMvcTest` annotated test class and the beans should be picked up by spring. Reference : <https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTest.html>
10,537,897
How can I override spring messages like 'Bad Credentials'? I've configured my servlet context file with following beans ``` <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="WEB-INF/messages" /> <property name="defaultEncoding" value="UTF-8" /> </bean> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> <property name="defaultLocale" value="en" /> </bean> ``` I'm able to use `<spring:message>` tag to display messages from my custom file . In the same file I've redefined all messages that are mapped to 'Bad Credentials' in spring-security-core.jar (messages.properties file) but they are not used. I still see 'Bad Credentials' message. How can I override these spring messages?
2012/05/10
[ "https://Stackoverflow.com/questions/10537897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547750/" ]
It turns out that these beans should be defined in general application context and not in myservlet-servlet.xml file. Once I moved the definitions from servlet context it started to work as expected.
Use correct property name. Use basenames instead of basename
54,908,164
jQuery newbie. My goal is to loop through each article and append the img to the div with the class body. The problem is its taking every image and appending to the div with the class body. Thanks! My Script ``` jQuery('article .date').each(function() { jQuery(this).closest('article').find('img').after(this); }); ``` Markup ``` <article> <div class="date">Feb 22, 2019</div> <div class="body"> <img src="imagone.png"> Some random text </div> </article> <article> <div class="date">Feb 23, 2019</div> <div class="body"> <img src="imagtwo.png"> Some random text </div> </article> <article> <div class="date">Feb 24, 2019</div> <div class="body"> <img src="imagthree.png"> Some random text </div> </article> ``` Desired markup ``` <article> <div class="date">Feb 22, 2019</div><img src="imagone.png"> <div class="body"> Some random text </div> </article> <article> <div class="date">Feb 23, 2019</div><img src="imagtwo.png"> <div class="body"> Some random text </div> </article> <article> <div class="date">Feb 24, 2019</div><img src="imagthree.png"> <div class="body"> Some random text </div> </article> ```
2019/02/27
[ "https://Stackoverflow.com/questions/54908164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10529685/" ]
You could slice a given array and take only five elements for getting an average. ```js function standardDeviation(array) { const arrAvg = tempArray => tempArray.reduce((a, b) => a + b, 0) / tempArray.length; return array.map((_, i, a) => arrAvg(a.slice(i, i + 5))); } var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; console.log(standardDeviation(arr)); ```
You could try using the slice() function of array element. ``` // simulated loop index var curr_index_pos = 3; // entire array var array_full = [1,2,3,4,5,6,7,8,9,10]; // array with 5 next values from "curr_index_pos" var array_5 = array_full.slice(curr_index_pos,curr_index_pos+5); var sum = 0; for( var i = 0; i < array_5.length; i++ ) { sum += parseInt( array_5[i] ); } var avg = sum/array_5.length; console.log("array_5", array_5); // [4,5,6,7,8] console.log("sum", sum); // 30 console.log("avg", avg); // 6 ```
57,785,687
I have a Pandas Dataframe containing multiple colums of strings. I now like to check a certain column against a list of allowed substrings and then get a new subset with the result. ``` substr = ['A', 'C', 'D'] df = pd.read_excel('output.xlsx') df = df.dropna() # now filter all rows where the string in the 2nd column doesn't contain one of the substrings ``` The only approach I found was creating a List of the corresponding column an then do a list comprehension, but then I loose the other columns. Can I use list comprehension as part of e.g. `df.str.contains()`? ``` year type value price 2000 ty-A 500 10000 2002 ty-Q 200 84600 2003 ty-R 500 56000 2003 ty-B 500 18000 2006 ty-C 500 12500 2012 ty-A 500 65000 2018 ty-F 500 86000 2019 ty-D 500 51900 ``` expected output: ``` year type value price 2000 ty-A 500 10000 2006 ty-C 500 12500 2012 ty-A 500 65000 2019 ty-D 500 51900 ```
2019/09/04
[ "https://Stackoverflow.com/questions/57785687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9360663/" ]
You could use [`pandas.Series.isin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.isin.html) ```py >>> df.loc[df['type'].isin(substr)] year type value price 0 2000 A 500 10000 4 2006 C 500 12500 5 2012 A 500 65000 7 2019 D 500 51900 ```
you could use [pandas.DataFrame.any](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.any.html#pandas.DataFrame.any) or [pandas.DataFrame.all](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.all.html) if you want where all instances match ``` df.loc[df['type'].apply(lambda x: all( word in x for word in substr) ``` or if you want any from the substr ``` df.loc[df['type'].apply(lambda x: any( word in x for word in substr) ``` That should if you print or return df a filtered list.
273,530
Suppose $$y^{'}+p(x)y=q(x),\,\,\,y(x\_0)=y\_0$$ where $p$ and $q$ are continuous functions in some interval $I$ containing $x\_0$. Show that the particular solution is $$y(x)=e^{\int\_{x\_o}^{x}{p(t)}dt}[\int\_{x\_0}^{x}{e^{\int\_{x\_0}^{t}{p(\xi)}d\xi}q(t)dt+y\_0}]$$ I have no idea where the $\xi$ comes from. I can only get the general solution $$y(x)=\frac{1}{I(x)}{\int{}I(x)q(x)dx+C} ,$$ where $I(x)$ is an integrating factor
2013/01/09
[ "https://math.stackexchange.com/questions/273530", "https://math.stackexchange.com", "https://math.stackexchange.com/users/54398/" ]
Searching for the method called **Variation of Parameters**, we will find out, for the linear 1-order differential equation $y'+p(x)y=q(x)$ where the functions $p(x), q(x)$ have the conditions as you gave them above; there is a solution like $y\_1(x)=\text{e}^{\int-p(x)dx}$.(You know all of these) The method goes further and tells us that the one-parameter family of solutions of our equation is as the form you noted above as well. In fact we set $y(x)=v(x)y\_1(x)$ into the equation to find another part of solution which is free of any constant. This is the particular solution $$y\_p(x)=\text{e}^{\int-p(x)dx}\int\text{e}^{\int-p(x)dx}f(x)dx$$. In 2-order linear equation we can easily understand why this approach was made. Now I make an example to see why that formula arisen. Let we have $y'=f(x,y),\; y(x\_0)=y\_0$. You surely accept that if $f(x,y)$ be continuous in a region containing the point $(x\_0,y\_0)$ then by integrating from both sides of our latter OE, we have $$y(x)=c+\int\_{x\_0}^{x}f(t,y(t))dt$$ and certainly $$y(x\_0)=c+\int\_{x\_0}^{x\_0}f(t,y(t))dt=c$$ and so $$y(x)=y\_0 +\int\_{x\_0}^{x}f(t,y(t))dt$$. I hope you got the point. Moreover @experimentX gave you additional points.
if you multiply $e^{\int p(x)\text{d}x}$ to both sides of the equation,get: $$y'e^{\int p(x)\text{d}x}+p(x)ye^{\int p(x)\text{d}x}=q(x)e^{\int p(x)\text{d}x}$$ the above equation can be written as $$\text{d}\left(ye^{\int p(x)\text{d}x}\right)=\text{d}\left(\int q(x)e^{\int p(x)\text{d}x}\right)$$ then you can get the answer.
377,587
I'm trying to use the `tikz-feynman` package to produce a fairly simple diagram, I produced the following plot: ``` \documentclass[tikz]{standalone} \usepackage[compat=1.1.0]{tikz-feynman} \begin{document} \feynmandiagram [horizontal=a to b] { i1 [particle=\(q\)] -- [fermion] a -- [fermion] i2[particle=\(\bar{q}\)], a -- [gluon, edge label=\(g\)] b, f1 [particle=\(g\)] -- [gluon] b -- [dashed, red] f2 [red, particle=\(G\)]], }; \end{document} ``` and would like to add a gluon radiation off the line that connects the `i1` and `a` vertexes. My understanding is that I would have to redo the diagram placing the vertexes manually. Is that so?
2017/06/30
[ "https://tex.stackexchange.com/questions/377587", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/9585/" ]
Once the diagram has been placed with [Ti*k*Z-Feynman](http://jpellis.me/projects/tikz-feynman) ([CTAN](http://ctan.org/pkg/tikz-feynman)), you can access the vertices as you would with other coordinates in Ti*k*Z. In your case, you probably don't want to redraw the whole diagram as you want to make it salient as it is the same diagram except with initial state radiation extra. In the solution below, I add an extra vertex `(r)` which I then connect with a gluon line to 80% of the distance from `(i1)` to `(a)`. ``` \RequirePackage{luatex85} \documentclass[tikz, border=10pt]{standalone} \usepackage[compat=1.1.0]{tikz-feynman} \begin{document} \begin{tikzpicture} \begin{feynman} \diagram [horizontal=a to b] { i1 [particle=\(q\)] -- [fermion] a -- [fermion] i2[particle=\(\bar{q}\)], a -- [gluon, edge label=\(g\)] b, f1 [particle=\(g\)] -- [gluon] b -- [dashed, red] f2 [red, particle=\(G\)]], }; \vertex [above left=of f1] (r); \draw [gluon] ($(i1)!0.8!(a)$) -- (r); \end{feynman} \end{tikzpicture} \end{document} ``` [![output](https://i.stack.imgur.com/uasBB.png)](https://i.stack.imgur.com/uasBB.png)
This is one case where manual placement can come to the rescue, if you want to do anything beyond the simple case of the question (with an s-channel 2-to-2 diagram and a single emission in the initial state). This gives you complete freedom on the look and feel of the diagram. ``` \documentclass[tikz, border=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{shapes,arrows,positioning,automata,backgrounds,calc,er,patterns} \usepackage[compat=1.1.0]{tikz-feynman} \begin{document} \begin{tikzpicture} \begin{feynman} \vertex [large, blob] (blob) at (0,0) {}; \vertex (b) at (-1.1,0.55); \vertex (c) at (-0.4,1.); \vertex (g1) at (-2,1) {}; \vertex (g2) at (-2,-1) {}; \vertex (t2) at (2,1) {}; \vertex (t1) at (2,-1) {}; \vertex (b2) at (0.6,1.5) {}; \vertex (b1) at (0.65,0.9) {}; \diagram* { (g1) -- [gluon] (b) -- [gluon] (blob) -- [gluon] (g2), (c) -- [gluon] (b), (b1) -- [fermion] (c) -- [fermion] (b2), (t1) -- [fermion] (blob) -- [fermion] (t2), }; \end{feynman} \end{tikzpicture} \end{document} ``` [![feynman diagram](https://i.stack.imgur.com/Y6J3c.png)](https://i.stack.imgur.com/Y6J3c.png)
24,981,863
In my iOS 7.1 application that I'm trying to develop, I need to figure out percentages of a specific number which is entered in a UITextField. It would appear when executing the code I get the wrong percentage of that number entered. I've tried two different ways to get the require percentage answer I'm looking for, however it keeps giving the wrong answer. Below here is the two methods that I've tried. For example I want to get 72% of 250. If you were to do this on a calculator or better yet a excel spreadsheet I get the right answer 250 x 1 - 72% = 70. This is the correct answer I want Method1 (.m file) Not working Values that are set the the specific .text parameters: ``` Entered in the UITextField _linuxOracleOnDiskw_oRTC.text = 250 Value set to UITextField _formulaNumber.text = 1 Percentage Value set to _linuxOracle_Percent.text = 0.72 _linuxOracleOnDiskwithRTC.text = [NSString stringWithFormat:@"%.2f", ([_linuxOracleOnDiskw_oRTC.text doubleValue])*([_formulaNumber.text doubleValue])-([_linuxOracle_Percent.text doubleValue])]; ``` When executed I the answer or vale that gets entered in the UITextField \_linuxOracleOnDiskwithRTC.text is 249.28. This is wrong should be 70 Second method tried is as follows: ``` float linuxOracleOnDiskw_oRTC = [_linuxOracleOnDiskw_oRTC.text floatValue]; ``` \_linuxOracleOnDiskwithRTC.text = [NSString stringWithFormat:@"%.2f", (linuxOracleOnDiskw\_oRTC \* 1 - 72/100.0f )]; If someone can tell me what I maybe doing wrong and point me in the right direction with calculating percentages of a specific number entered in a UITextField I would be extremely GREATFUL.
2014/07/27
[ "https://Stackoverflow.com/questions/24981863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3881740/" ]
Don't omit your brackets when performing calculations with code. For "250 x 1 - 72%" to get 70, you need to do this: 250 x (1 - 0.72) = 250 x 0.28 = 70 Formulas in () will be calculated first, followed by multiplication and division (whichever first), then followed by addition and subtraction (whichever first). So, insert your brackets appropriately.
Your formula to calculate the percentage is incorrect. One correct way to calculate percentages is 250 / 100 x 72 This gives you 72% of 250. The result of that isn't 70, btw, but 180. If you want 70, then you don't want 72% but 28% (or 100% - 72%): 250 / 100 x (100 - 72)
56,045,959
There are a lot of posts about how to count `NaN` in a list or pandas series, as well as the time efficiency of the various options. One solution I have not seen is self equality: If `y == np.nan` then `(y != y) is True`. So a quick way to count the NaNs in a list would be: ```py import pandas as pd import numpy as np lst = pd.Series([np.nan, 5, 4, 3, 2, np.nan]) count = sum(1 for x in lst if x != x) ``` I hadn't seen that solution before, which makes me wonder: When will this fail to work the way I want it to work (eg maybe for dtypes that aren't in my columns - I have floats and strings? I've done some testing with my own data, and found this solution to be equivalent to: ```py count = lst.isnull().sum() # and count = len([x for x in lst if x != x]) ``` I've found that the speed is in this order from fastest to slowest: `sum`, `len`, `.sum()`
2019/05/08
[ "https://Stackoverflow.com/questions/56045959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5531578/" ]
You could use [`numpy.isnan()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.isnan.html), so your code would look like: ```py import pandas as pd import numpy as np lst = pd.Series([np.nan, 5, 4, 3, 2, np.nan]) count = len([x for x in lst if np.isnan(x)]) ``` But if you want to be fancy: ```py count = sum(np.isnan(lst)) ``` Or if you're concerned about memory: ```py # Less elegant, but does the job count = 0 for x in lst: if np.isnan(x): count += 1 ```
Based on the comments, I did a basic time complexity experiment between the two proposed methods. Note that this doesn't address any cases where your approach fails, as I didn't find any. Setup: ``` def make_col(): return [np.random.choice([1,2,3,4,5,6,7,8,9,10,np.NaN]) for i in range(100000)] df=pd.DataFrame({k:make_ops() for k in list('abcdefghijklmnopqrstuvwxyz')}) df.shape (100000, 26) ``` Experiment (note that I tried to be explicit at each step rather than optimizing for total efficiency, to show the difference between the two): ``` %%timeit n=[] for col in df.columns: count=len([x for x in df[col] if x != x]) n.append(count) 134 ms %%timeit n=[] for col in df.columns: count=count = df[col].isnull().sum() n.append(count) 29.7 ms ``` For approximately 80% improvement using the built-in methods Interestingly, based on the numpy/Cython/C optimization under the hood, if you run the `%%prun` profiler on both of the above operations, you get fewer individual function calls with your approach, but more overall runtime. Respectively: ``` 2013 function calls in 0.248 seconds ``` vs. ``` 8903 function calls in 0.046 seconds ``` And, regarding memory usage between the two, it looks like you're right regarding the two being logically equivalent regarding copying and storage. Both snippets above come in around `peak memory: 247.20 MiB` using the `%%memit` magic from [this source](https://ipython-books.github.io/44-profiling-the-memory-usage-of-your-code-with-memory_profiler/) (which as a caveat, I haven't seen or used previously and am unaware of any gotchas or issues regarding its use)
36,511,990
Assume I receive two arguments to a template, T1 and T2. If I know T1 is itself a templated class (e.g., a container), and T2 can be anything, is it possible for me to determine the base template type for T1 and rebuild it using T2 as its argument? For example, if I receive `std::vector<int>` and `std::string`, I would want to automatically build `std::vector<std::string>`. However if I were given `std::set<bool>` and `double`, it would produce `std::set<double>`. After reviewing type\_traits, relevant blogs, and other questions here, I don't see a general approach to solving this problem. The only way I can currently see to accomplish this task is to build template adapters for each type that could be passed in as T1. For example, if I had: ``` template<typename T_inner, typename T_new> std::list<T_new> AdaptTemplate(std::list<T_inner>, T_new); template<typename T_inner, typename T_new> std::set<T_new> AdaptTemplate(std::set<T_inner>, T_new); template<typename T_inner, typename T_new> std::vector<T_new> AdaptTemplate(std::vector<T_inner>, T_new); ``` I should be able to use decltype and rely on operator overloading to solve my problem. Something along the lines of: ``` template <typename T1, typename T2> void MyTemplatedFunction() { using my_type = decltype(AdaptTemplate(T1(),T2())); } ``` Am I missing something? Is there a better approach? **WHY do I want to do this?** I'm building a C++ library where I want to simplify what users need to do to build modular templates. For example, if a user wants to build an agent-based simulation, they might configure a World template with an organism type, a population manager, an environment manager, and a systematics manager. Each of the managers also need to know the organism type, so a declaration might look something like: ``` World< NeuralNetworkAgent, EAPop<NeuralNetworkAgent>, MazeEnvironment<NeuralNetworkAgent>, LineageTracker<NeuralNetworkAgent> > world; ``` I'd much rather users not have to repeat `NeuralNetworkAgent` each time. If I am able to change template arguments, then default arguments can be used and the above can be simplified to: ``` World< NeuralNetworkAgent, EAPop<>, MazeEnvironment<>, LineageTracker<> > world; ``` Plus it's easier to convert from one world type to another without worrying about type errors. Of course, I can deal with most errors using static\_assert and just deal with the longer declarations, but I'd like to know if a better solution is possible.
2016/04/09
[ "https://Stackoverflow.com/questions/36511990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2301053/" ]
define a util class, like following: ``` public class AcitivtyUtil { public static void showActivity(Activity from, Class<?> to, boolean finish) { Intent intent = new Intent(from, to); from.startActivity(intent); if (finish) { from.finish(); } } } ``` then you can call `ActivityUtil.showActivity(this, TargetActivity.class, true|false)` at any Activity. some error in your code: ``` public void ShowActivity(Activity act) // here you can't pass a Activity object as parameter, you should pass Class<?>, so it should be act.class { Intent intent = new Intent(this, act.class); startActivity(intent); } ``` If you don't want use util class, you can also define the `showActivity()` in your Activity class as member method, recommend define it in BaseActivity, so you need not duplicate it in all Activity. ``` public void showActivity(Class<?> to, boolean finish) { Intent intent = new Intent(this, to); startActivity(intent); if (finish) { finish(); } } ```
Okay I edited my answer Ertürk. Change the parameter of your Activity act parameter of your `showActivity` to Intent intent and pass the value of intent params to your method's intent. So to use it, it'll be like: ``` showActivity(new Intent(this, LoginActivity.class)); ```
36,511,990
Assume I receive two arguments to a template, T1 and T2. If I know T1 is itself a templated class (e.g., a container), and T2 can be anything, is it possible for me to determine the base template type for T1 and rebuild it using T2 as its argument? For example, if I receive `std::vector<int>` and `std::string`, I would want to automatically build `std::vector<std::string>`. However if I were given `std::set<bool>` and `double`, it would produce `std::set<double>`. After reviewing type\_traits, relevant blogs, and other questions here, I don't see a general approach to solving this problem. The only way I can currently see to accomplish this task is to build template adapters for each type that could be passed in as T1. For example, if I had: ``` template<typename T_inner, typename T_new> std::list<T_new> AdaptTemplate(std::list<T_inner>, T_new); template<typename T_inner, typename T_new> std::set<T_new> AdaptTemplate(std::set<T_inner>, T_new); template<typename T_inner, typename T_new> std::vector<T_new> AdaptTemplate(std::vector<T_inner>, T_new); ``` I should be able to use decltype and rely on operator overloading to solve my problem. Something along the lines of: ``` template <typename T1, typename T2> void MyTemplatedFunction() { using my_type = decltype(AdaptTemplate(T1(),T2())); } ``` Am I missing something? Is there a better approach? **WHY do I want to do this?** I'm building a C++ library where I want to simplify what users need to do to build modular templates. For example, if a user wants to build an agent-based simulation, they might configure a World template with an organism type, a population manager, an environment manager, and a systematics manager. Each of the managers also need to know the organism type, so a declaration might look something like: ``` World< NeuralNetworkAgent, EAPop<NeuralNetworkAgent>, MazeEnvironment<NeuralNetworkAgent>, LineageTracker<NeuralNetworkAgent> > world; ``` I'd much rather users not have to repeat `NeuralNetworkAgent` each time. If I am able to change template arguments, then default arguments can be used and the above can be simplified to: ``` World< NeuralNetworkAgent, EAPop<>, MazeEnvironment<>, LineageTracker<> > world; ``` Plus it's easier to convert from one world type to another without worrying about type errors. Of course, I can deal with most errors using static\_assert and just deal with the longer declarations, but I'd like to know if a better solution is possible.
2016/04/09
[ "https://Stackoverflow.com/questions/36511990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2301053/" ]
define a util class, like following: ``` public class AcitivtyUtil { public static void showActivity(Activity from, Class<?> to, boolean finish) { Intent intent = new Intent(from, to); from.startActivity(intent); if (finish) { from.finish(); } } } ``` then you can call `ActivityUtil.showActivity(this, TargetActivity.class, true|false)` at any Activity. some error in your code: ``` public void ShowActivity(Activity act) // here you can't pass a Activity object as parameter, you should pass Class<?>, so it should be act.class { Intent intent = new Intent(this, act.class); startActivity(intent); } ``` If you don't want use util class, you can also define the `showActivity()` in your Activity class as member method, recommend define it in BaseActivity, so you need not duplicate it in all Activity. ``` public void showActivity(Class<?> to, boolean finish) { Intent intent = new Intent(this, to); startActivity(intent); if (finish) { finish(); } } ```
you can use the following: ``` public void ShowActivity(Activity act) { Intent intent = new Intent(this, act.getClass()); startActivity(intent); } ```
36,511,990
Assume I receive two arguments to a template, T1 and T2. If I know T1 is itself a templated class (e.g., a container), and T2 can be anything, is it possible for me to determine the base template type for T1 and rebuild it using T2 as its argument? For example, if I receive `std::vector<int>` and `std::string`, I would want to automatically build `std::vector<std::string>`. However if I were given `std::set<bool>` and `double`, it would produce `std::set<double>`. After reviewing type\_traits, relevant blogs, and other questions here, I don't see a general approach to solving this problem. The only way I can currently see to accomplish this task is to build template adapters for each type that could be passed in as T1. For example, if I had: ``` template<typename T_inner, typename T_new> std::list<T_new> AdaptTemplate(std::list<T_inner>, T_new); template<typename T_inner, typename T_new> std::set<T_new> AdaptTemplate(std::set<T_inner>, T_new); template<typename T_inner, typename T_new> std::vector<T_new> AdaptTemplate(std::vector<T_inner>, T_new); ``` I should be able to use decltype and rely on operator overloading to solve my problem. Something along the lines of: ``` template <typename T1, typename T2> void MyTemplatedFunction() { using my_type = decltype(AdaptTemplate(T1(),T2())); } ``` Am I missing something? Is there a better approach? **WHY do I want to do this?** I'm building a C++ library where I want to simplify what users need to do to build modular templates. For example, if a user wants to build an agent-based simulation, they might configure a World template with an organism type, a population manager, an environment manager, and a systematics manager. Each of the managers also need to know the organism type, so a declaration might look something like: ``` World< NeuralNetworkAgent, EAPop<NeuralNetworkAgent>, MazeEnvironment<NeuralNetworkAgent>, LineageTracker<NeuralNetworkAgent> > world; ``` I'd much rather users not have to repeat `NeuralNetworkAgent` each time. If I am able to change template arguments, then default arguments can be used and the above can be simplified to: ``` World< NeuralNetworkAgent, EAPop<>, MazeEnvironment<>, LineageTracker<> > world; ``` Plus it's easier to convert from one world type to another without worrying about type errors. Of course, I can deal with most errors using static\_assert and just deal with the longer declarations, but I'd like to know if a better solution is possible.
2016/04/09
[ "https://Stackoverflow.com/questions/36511990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2301053/" ]
you can use the following: ``` public void ShowActivity(Activity act) { Intent intent = new Intent(this, act.getClass()); startActivity(intent); } ```
Okay I edited my answer Ertürk. Change the parameter of your Activity act parameter of your `showActivity` to Intent intent and pass the value of intent params to your method's intent. So to use it, it'll be like: ``` showActivity(new Intent(this, LoginActivity.class)); ```
41,353
I face a problem where I need to compute similarities over bilingual (English and French) texts. The "database" looks like this: ``` +-+-+-+ | |F|E| +-+-+-+ |1|X|X| +-+-+-+ |2| |X| +-+-+-+ |3|X| | +-+-+-+ |4|X| | +-+-+-+ |5| |X| +-+-+-+ |6|X|X| +-+-+-+ |7|X| | +-+-+-+ ``` which means that I have English and French texts (variable long single sentences) for each "item" with either in both version (in this case the versions are loose translations of each other) or only in one language. The task is to find the closest item ID for any incoming new sentence irrespective the actual language of either of the sentence in the "database" or of the incoming sentence (that is, the matching sentence in the "database" needn't necessarily be in the same language as the incoming sentence as long as the meaning is the closest). I hope this goal explanation is clear. Originally I planned to build a word2vec from scratch for both languages (the vocabulary is quite specific so I would have preferred my own word2vec) and find similarities only for the corresponding language for each new sentence but this would omit all candidates from the items where the corresponding language sentences are missing. So I wonder if generating a common word2vec encoding for the combined corpus is viable (the word2vec method itself being language agnostic) but I cannot figure out if such a solution would be superior. Additionally, the number of the sentences is not very large (about 10.000) maybe word2vec generation from scratch is not the best idea on one hand, but there are really specific terms in the corpora on the other hand.
2018/11/17
[ "https://datascience.stackexchange.com/questions/41353", "https://datascience.stackexchange.com", "https://datascience.stackexchange.com/users/21560/" ]
This paper from Amazon explains how you can use aligned bilingual word embeddings to generate a similarity score between two sentences of different languages. Used movie subtitles in four language pairs (English to German, French, Portuguese and Spanish) to show the efficiency of their system. ["Unsupervised Quality Estimation Without Reference Corpus for Subtitle Machine Translation Using Word Embeddings"](https://ieeexplore.ieee.org/document/8665529)
You could take pretrained embedder on multiple languages, then check distances between the encodings. There's unofficial `pypi` port of Facebook's [LASER](https://pypi.org/project/laserembeddings/). It's langauge-agnostic and pretrained on both `en` and `fr`. ``` from laserembeddings import Laser laser = Laser() sentence_en = 'My name is Hendrik' sentence_fr = 'Je suis Hendrik' en_embedding = laser.embed_sentences([sentence_en], lang='en')[0] fr_embedding = laser.embed_sentences([sentence_fr], lang='fr')[0] ``` Embeddings are 1024-element NumPy array. You can calculate some metric between embeddings i.e. euclidean. ``` import numpy as np distance = np.linalg.norm(en_embedding - fr_embedding) ``` The good thing is you have defined similarity in your DB, so you can learn the threshold for your distance metric and check execatly how well it fares.
58,783,984
am making a card where i have the image and description below but the image is too zoomed and doesnt look attractive i've tried to adjust the height and image but it doesnt work [![enter image description here](https://i.stack.imgur.com/ZXyPR.png)](https://i.stack.imgur.com/ZXyPR.png) HTML ``` <div id="event-card"> <div id="card-image"> <img src="{{ URL::to('/assets/photos/event3.jpg') }}"> </div> <div class="container" id="card-details"> {{$event->eventName}} </div> </div> ``` This is the CSS ``` #event-card{ box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); transition: 0.3s; display: inline-block; width:250px; height:250px; overflow: hidden; margin-right:10px; margin-bottom:10px; border-radius: 8px; margin-top:40px; } #card-image { background-image:url('/churchill/public/assets/photos/event3.jpg'); height:60%; width: 100%; background-size:cover; overflow:hidden; background-repeat: no-repeat; } #event-cards{ width:80%; margin-left:156px; } ```
2019/11/09
[ "https://Stackoverflow.com/questions/58783984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
All well.. images.. biggest problem ever :D Well you actually have few options. I will be straightforward ```css img { width: 100%; height: 100%; object-fit: cover; } ``` This will make image look natural and not stretched but it might cut it on sides for that ```css img { max-width: 100%; height: auto; } ``` This might be best solution for you. Image won't go over parent in width and it will go in height big enough to keep its aspect ratio and it will look natural. Play with it and see what looks best for you PS: You also have ```css object-fit: fill; object-fit: contain; object-fit: cover; object-fit: scale-down; object-fit: none; ```
What is the original width and height of the image? if the image height `500px` and the width `500px` and you set it width `500px` and height `200px` it will cause a problem like you facing, to avoid this issue you can set the image as a background you can create another div with the height and width you want and set this image as a background and you can control it using `background-size:cover` and `background-position`
12,703,271
I need to write a script in CentOS, which will run in background. This script need to check whether a file name "status.txt" has been created in /root/MyFile folder on not. If that file is created, an event should be captured by my script. What code snippet I should write in my script, so that it gets event that the txt file has been created in a folder? Any help is greatly appreciated.
2012/10/03
[ "https://Stackoverflow.com/questions/12703271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1716243/" ]
The simplest solution: ``` while true; do do [ -e "/root/MyFile/status.txt" ] && { echo file is created; break; } sleep 1 done ``` Instead of `echo file is created` you can write the commands you want to execute. You can to the same with **inotify**: ``` inotifywait --format '%f' -m /root/MyFile 2> /dev/null | while read file do [ "$file" = status.txt ] \ && [ -e "/root/Myfile/$file" ] \ && { echo file is created ; break; } done ``` This that solution has that advantage that you will get the action instantly, as the file will be created. And in the first case you will too wait for the second. The second advantage, that you need to poll the filesystem every second. But this solution has disadvantages also: * it works only on Linux; * you need relatively modern kernel; * you need to install inotify-tools; * if you create many files before `status.txt` will be created, you make many additional comparison operation. Resuming: I think, you need the first solution.
If your kernel is newer than 2.6.13 you could use [inotify](http://en.wikipedia.org/wiki/Inotify) mechanism to achieve your goal. Install package [inotify-tools](https://github.com/rvoicilas/inotify-tools/) and write the script that will watch for your file, using provided [examples](https://github.com/rvoicilas/inotify-tools/wiki#wiki-info)
33,938
I'm trying to set Single-Click (in explorer) in some Kiosk-like PCs, running Windows XP, but I can't find any way to set it through GPO. Is there any way to do this?
2009/06/30
[ "https://serverfault.com/questions/33938", "https://serverfault.com", "https://serverfault.com/users/132/" ]
You're not going to be able to change this with "Administrative Templates". This is one of those annoying values that's stored in a REG\_BINARY structure (specifically HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellState) and is wholly undocumented in structure. You could script a registry merge to this value, but if Explorer is already running when you change this value you won't see the effect until the next logon. Explorer is able to update itself when you change this setting in the menu via some undocumented API. Yay undocumented APIs... *sigh* You'll also be changing more than just the single-click behaviour if you merge over top of it-- there are other things in this opaque binary value. (I'd love Microsoft to take the attitude that 100% of settings in Windows, Office, etc must be customizable via Group Policy.)
The policy is called "Turn on Classic Shell" User Configuration | Administrative Templates | Windows components | Windows Explorer
3,004,566
This is my first time posting so do correct me if I am doing anything wrong. Please help me with this math problem from the British Maths Olympiad (1994 British Maths Olympiad1 Q1 Number Theory). > > Starting with any three digit number $n$ (such as $n = 625$) we obtain a new number $f(n)$ which is equal to the sum of the three digits of $n$, their three products in pairs, and the product of all three digits. > Find all three digit numbers such that $\frac{n}{f(n)}=1$. > > > The only solution I found is $199$, can someone verify it please?
2018/11/19
[ "https://math.stackexchange.com/questions/3004566", "https://math.stackexchange.com", "https://math.stackexchange.com/users/616837/" ]
Let $n=100a+10b+c,$ where $a> 0$ and $b,c\geq 0$. We are trying to solve $$100a+10b+c=a+b+c+ab+ac+bc+abc \\ \implies 99a+9b=abc+ab+ac+bc \\ \implies a(99-b-c-bc)=b(c-9) \\$$$c-9\leq 0$, but $b+c+bc\leq 99$. So the above equation holds iff $b=c=9$, which means $a$ can take any value.
Here's part $(b)$ because I'm assuming you don't need help with part $(a)$: --- We want to compute all possible integers $n$ such that $\frac{n}{f(n)} = 1$. Since we know that, by assumption, $n$ is a three-digit number, we can write $$n = 100a + 10b + c,$$ where $a, b, c$ are integers. If this is the case, in terms of our newly defined variables $a$, $b$, and $c$, we can express $f(n)$ as follows: $$f(n) = abc + ab + bc + ac + a + b + c.$$ Now, in order to have $\frac{n}{f(n)} = 1,$ we must have $n = f(n)$. This happens when $$99a + 9b = abc + ab + bc + ac$$ $$\Longleftrightarrow (9-c)b = a(bc + b + c - 99) $$ Also, we must have $b, c \leq 9,$ which implies $bc + b + c - 99 \leq 0$. However, since $a \neq 0$ (if $a = 0$, we would be able to form a two or one-digit number instead of a three-digit one!), we conclude $b = c = 9$. Therefore, our solution set is given by $$\boxed{\{199, 299, 399, 499, 599, 699, 799, 899, 999\}}$$
3,004,566
This is my first time posting so do correct me if I am doing anything wrong. Please help me with this math problem from the British Maths Olympiad (1994 British Maths Olympiad1 Q1 Number Theory). > > Starting with any three digit number $n$ (such as $n = 625$) we obtain a new number $f(n)$ which is equal to the sum of the three digits of $n$, their three products in pairs, and the product of all three digits. > Find all three digit numbers such that $\frac{n}{f(n)}=1$. > > > The only solution I found is $199$, can someone verify it please?
2018/11/19
[ "https://math.stackexchange.com/questions/3004566", "https://math.stackexchange.com", "https://math.stackexchange.com/users/616837/" ]
Let $n=100a+10b+c,$ where $a> 0$ and $b,c\geq 0$. We are trying to solve $$100a+10b+c=a+b+c+ab+ac+bc+abc \\ \implies 99a+9b=abc+ab+ac+bc \\ \implies a(99-b-c-bc)=b(c-9) \\$$$c-9\leq 0$, but $b+c+bc\leq 99$. So the above equation holds iff $b=c=9$, which means $a$ can take any value.
let n=100a+10b+c f(n)= a+b+c+ab+bc+ca+abc if n/f(n)=1 we get n=f(n) 100a+10b+c=a+b+c+ab+bc+ca+abc 99a+9b=ab+bc+ca+abc 99a+9b=a(b+c+ca)+bc Let a=1 99+9b=b+c+2bc 99+8b=c(1+2b)=(95+4)+8b= 95 + 4(1+2b) 95=c(1+2b)-4(1+2b)=(c-4)(1+2b) since c, b are integers from [1,9] 95=19\*5=(c-4)(1+2b) c-4 is single digit so it must be = 5 c-4=5 c=9 1+2b=19 b=9 so abc becomes 199 and similarly taking a values from 2 to 9... (this method is time consuming, I couldn't think of a shorter one)
3,004,566
This is my first time posting so do correct me if I am doing anything wrong. Please help me with this math problem from the British Maths Olympiad (1994 British Maths Olympiad1 Q1 Number Theory). > > Starting with any three digit number $n$ (such as $n = 625$) we obtain a new number $f(n)$ which is equal to the sum of the three digits of $n$, their three products in pairs, and the product of all three digits. > Find all three digit numbers such that $\frac{n}{f(n)}=1$. > > > The only solution I found is $199$, can someone verify it please?
2018/11/19
[ "https://math.stackexchange.com/questions/3004566", "https://math.stackexchange.com", "https://math.stackexchange.com/users/616837/" ]
Here's part $(b)$ because I'm assuming you don't need help with part $(a)$: --- We want to compute all possible integers $n$ such that $\frac{n}{f(n)} = 1$. Since we know that, by assumption, $n$ is a three-digit number, we can write $$n = 100a + 10b + c,$$ where $a, b, c$ are integers. If this is the case, in terms of our newly defined variables $a$, $b$, and $c$, we can express $f(n)$ as follows: $$f(n) = abc + ab + bc + ac + a + b + c.$$ Now, in order to have $\frac{n}{f(n)} = 1,$ we must have $n = f(n)$. This happens when $$99a + 9b = abc + ab + bc + ac$$ $$\Longleftrightarrow (9-c)b = a(bc + b + c - 99) $$ Also, we must have $b, c \leq 9,$ which implies $bc + b + c - 99 \leq 0$. However, since $a \neq 0$ (if $a = 0$, we would be able to form a two or one-digit number instead of a three-digit one!), we conclude $b = c = 9$. Therefore, our solution set is given by $$\boxed{\{199, 299, 399, 499, 599, 699, 799, 899, 999\}}$$
let n=100a+10b+c f(n)= a+b+c+ab+bc+ca+abc if n/f(n)=1 we get n=f(n) 100a+10b+c=a+b+c+ab+bc+ca+abc 99a+9b=ab+bc+ca+abc 99a+9b=a(b+c+ca)+bc Let a=1 99+9b=b+c+2bc 99+8b=c(1+2b)=(95+4)+8b= 95 + 4(1+2b) 95=c(1+2b)-4(1+2b)=(c-4)(1+2b) since c, b are integers from [1,9] 95=19\*5=(c-4)(1+2b) c-4 is single digit so it must be = 5 c-4=5 c=9 1+2b=19 b=9 so abc becomes 199 and similarly taking a values from 2 to 9... (this method is time consuming, I couldn't think of a shorter one)
2,434,413
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: ``` str.replace(new RegExp('$', 'g'), '_'); ``` But this doesn't work for me and nothing gets replaced.
2010/03/12
[ "https://Stackoverflow.com/questions/2434413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111292/" ]
The `$` in RegExp is a special character, so you need to escape it with backslash. ``` new_str = str.replace(new RegExp('\\$', 'g'), '_'); ``` however, in JS you can use the simpler syntax ``` new_str = str.replace(/\$/g, '_'); ```
........ ``` str.replace(new RegExp('\\$', 'g'), '_'); ``` Becaue `$` is special char in js, you need to escape it.
2,434,413
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: ``` str.replace(new RegExp('$', 'g'), '_'); ``` But this doesn't work for me and nothing gets replaced.
2010/03/12
[ "https://Stackoverflow.com/questions/2434413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111292/" ]
You don’t need to use `RegExp`. You can use the literal syntax: ``` str.replace(/\$/g, '_') ``` You just need to escape the `$` character as it’s a special character in regular expressions that marks the end of the string. --- **Edit**    Oh, you can also use `split` and `join` to solve this: ``` str.split("$").join("_") ```
........ ``` str.replace(new RegExp('\\$', 'g'), '_'); ``` Becaue `$` is special char in js, you need to escape it.
2,434,413
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: ``` str.replace(new RegExp('$', 'g'), '_'); ``` But this doesn't work for me and nothing gets replaced.
2010/03/12
[ "https://Stackoverflow.com/questions/2434413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111292/" ]
........ ``` str.replace(new RegExp('\\$', 'g'), '_'); ``` Becaue `$` is special char in js, you need to escape it.
You don't need regular expressions just to replace one symbol: ``` newStr = oldStr.replace('$', '_') ```
2,434,413
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: ``` str.replace(new RegExp('$', 'g'), '_'); ``` But this doesn't work for me and nothing gets replaced.
2010/03/12
[ "https://Stackoverflow.com/questions/2434413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111292/" ]
The `$` in RegExp is a special character, so you need to escape it with backslash. ``` new_str = str.replace(new RegExp('\\$', 'g'), '_'); ``` however, in JS you can use the simpler syntax ``` new_str = str.replace(/\$/g, '_'); ```
You don’t need to use `RegExp`. You can use the literal syntax: ``` str.replace(/\$/g, '_') ``` You just need to escape the `$` character as it’s a special character in regular expressions that marks the end of the string. --- **Edit**    Oh, you can also use `split` and `join` to solve this: ``` str.split("$").join("_") ```
2,434,413
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: ``` str.replace(new RegExp('$', 'g'), '_'); ``` But this doesn't work for me and nothing gets replaced.
2010/03/12
[ "https://Stackoverflow.com/questions/2434413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111292/" ]
The `$` in RegExp is a special character, so you need to escape it with backslash. ``` new_str = str.replace(new RegExp('\\$', 'g'), '_'); ``` however, in JS you can use the simpler syntax ``` new_str = str.replace(/\$/g, '_'); ```
You don't need regular expressions just to replace one symbol: ``` newStr = oldStr.replace('$', '_') ```
2,434,413
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore. I have tried: ``` str.replace(new RegExp('$', 'g'), '_'); ``` But this doesn't work for me and nothing gets replaced.
2010/03/12
[ "https://Stackoverflow.com/questions/2434413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111292/" ]
You don’t need to use `RegExp`. You can use the literal syntax: ``` str.replace(/\$/g, '_') ``` You just need to escape the `$` character as it’s a special character in regular expressions that marks the end of the string. --- **Edit**    Oh, you can also use `split` and `join` to solve this: ``` str.split("$").join("_") ```
You don't need regular expressions just to replace one symbol: ``` newStr = oldStr.replace('$', '_') ```
36,426,547
I am using Ubuntu 14.04 I wanted to install package "requests" to use in python 3.5, so I installed it using pip3. I could see it in /usr/lib/python3.4, but while trying to actually execute scripts with Python 3.5 I always got "ImportError: No module named 'requests'" OK, so I figured, perhaps that's because the package is not in python3.5 but in python3.4. Therefore, I tried to uninstall and install i again, but it just kept popping up where I didn't want it (not to mention, when I run apt-get remove pip3-requests, it actually removed pip3 for me as well lol). Therefore, I tried physically removing python3.4 from usr/lib and usr/local/lib in order to try and see if maybe pip3 was confused and installed packages in wrong directories. I'm afraid it was not a good idea... when I now run e.g. `sudo pip3 install reqests` I get the following error: `Could not find platform independent libraries <prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'` Is there any way to fix this now? And to actually use requests package? When I use ``` sudo apt-get install python3-pip ``` It works and starts unpacking etc. but then I get a long error that starts with: ``` Setting up python3.4 (3.4.3-1ubuntu1~14.04.3) Could not find platform independent libraries <prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted dpkg: error processing package python3.4 (--configure): subprocess installed post-installation script returned error exit status 134 dpkg: dependency problems prevent configuration of python3: ``` (...) and ends with ``` python3 depends on python3.4 (>= 3.4.0-0~); however: Package python3.4 is not configured yet. dpkg: error processing package python3-wheel (--configure): dependency problems - leaving unconfigured E: Sub-process /usr/bin/dpkg returned an error code (1) ```
2016/04/05
[ "https://Stackoverflow.com/questions/36426547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4680896/" ]
**First of all, it is a very bad idea to remove your *system* Python 3 in Ubuntu (which 3.4 is in recent subrevisions of Trusty LTS)**. That is because it is a **vital part of the system**. If you run the command `apt-cache rdepends python3`, you'd see that packages such as `ubuntu-minimal`, `ubuntu-release-upgrader-core`, `lsb-release`, `lsb-core`, `ubuntu-core-libs` and so on, all depend on Ubuntu's version of Python 3 being installed (and this is the **python3.4** in Ubuntu 14.04.4). If you force-remove python 3.4 by hand, you've ruined your system. It might very well be that you now have to reinstall the whole operating system, unless you manage to reinstall all the system `.deb` packages that put data in `/usr/lib/python3.4`. And especially so if you do it with force. It can make your system even unbootable, so do not reboot that computer before you've successfully reinstalled Python 3... actually I am not sure how to do it safely since it seems you've forcefully removed all system dependencies from the /usr/lib) --- You should try to reinstall python3.4 ``` sudo apt-get install --reinstall python3.4 ``` But now the bigger problem is that you've still missing all sorts of dependencies for your system programs. Do note that `pip` also should be available as a *module*. Thus to ensure that you install for Python 3.5, you can do ``` sudo python3.5 -mpip install requests ``` The `pip3` is a wrapper for a `pip` that installs to the *system* Python 3 version (3.4 in your case).
Ubuntu 14.04LTS uses the [*trusty* package list](http://packages.ubuntu.com/trusty/). That repository comes with [Python 3.4.0-0ubuntu2](http://packages.ubuntu.com/trusty/python3). So the `pip` contained in `python3-pip` belongs to *that* version: 3.4. As such, when using Python 3.5, packages installed using Python 3.4 and that version’s `pip` will not be available. I don’t know how you installed Python 3.5 on your system, but you should use that way to install `pip` for that version as well. If you compiled it from source yourself, you should see the [install instructions for pip](https://pip.pypa.io/en/stable/installing/) on how to get it installed for Python 3.5.
36,426,547
I am using Ubuntu 14.04 I wanted to install package "requests" to use in python 3.5, so I installed it using pip3. I could see it in /usr/lib/python3.4, but while trying to actually execute scripts with Python 3.5 I always got "ImportError: No module named 'requests'" OK, so I figured, perhaps that's because the package is not in python3.5 but in python3.4. Therefore, I tried to uninstall and install i again, but it just kept popping up where I didn't want it (not to mention, when I run apt-get remove pip3-requests, it actually removed pip3 for me as well lol). Therefore, I tried physically removing python3.4 from usr/lib and usr/local/lib in order to try and see if maybe pip3 was confused and installed packages in wrong directories. I'm afraid it was not a good idea... when I now run e.g. `sudo pip3 install reqests` I get the following error: `Could not find platform independent libraries <prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'` Is there any way to fix this now? And to actually use requests package? When I use ``` sudo apt-get install python3-pip ``` It works and starts unpacking etc. but then I get a long error that starts with: ``` Setting up python3.4 (3.4.3-1ubuntu1~14.04.3) Could not find platform independent libraries <prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted dpkg: error processing package python3.4 (--configure): subprocess installed post-installation script returned error exit status 134 dpkg: dependency problems prevent configuration of python3: ``` (...) and ends with ``` python3 depends on python3.4 (>= 3.4.0-0~); however: Package python3.4 is not configured yet. dpkg: error processing package python3-wheel (--configure): dependency problems - leaving unconfigured E: Sub-process /usr/bin/dpkg returned an error code (1) ```
2016/04/05
[ "https://Stackoverflow.com/questions/36426547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4680896/" ]
**First of all, it is a very bad idea to remove your *system* Python 3 in Ubuntu (which 3.4 is in recent subrevisions of Trusty LTS)**. That is because it is a **vital part of the system**. If you run the command `apt-cache rdepends python3`, you'd see that packages such as `ubuntu-minimal`, `ubuntu-release-upgrader-core`, `lsb-release`, `lsb-core`, `ubuntu-core-libs` and so on, all depend on Ubuntu's version of Python 3 being installed (and this is the **python3.4** in Ubuntu 14.04.4). If you force-remove python 3.4 by hand, you've ruined your system. It might very well be that you now have to reinstall the whole operating system, unless you manage to reinstall all the system `.deb` packages that put data in `/usr/lib/python3.4`. And especially so if you do it with force. It can make your system even unbootable, so do not reboot that computer before you've successfully reinstalled Python 3... actually I am not sure how to do it safely since it seems you've forcefully removed all system dependencies from the /usr/lib) --- You should try to reinstall python3.4 ``` sudo apt-get install --reinstall python3.4 ``` But now the bigger problem is that you've still missing all sorts of dependencies for your system programs. Do note that `pip` also should be available as a *module*. Thus to ensure that you install for Python 3.5, you can do ``` sudo python3.5 -mpip install requests ``` The `pip3` is a wrapper for a `pip` that installs to the *system* Python 3 version (3.4 in your case).
1. Open a text-only virtual console by using the keyboard shortcut `Ctrl` + `Alt` + `F3`. 2. At the `login:` prompt type your username and press `Enter`. 3. At the `Password:` prompt type your user password and press `Enter`. 4. Reinstall the default Python 3 version by running the following command: ``` sudo apt install python3-all ``` 5. Switch out of the virtual console and return to your desktop environment by pressing the keyboard shortcut `Ctrl`+`Alt`+`F7`. In Ubuntu 17.10 and later press the keyboard shortcut `Ctrl`+`Alt`+`F2` to exit from the virtual console. --- After you have installed the default Python 3 version, you need to get back your default Ubuntu desktop system. In order to avoid messing something up, do it in the following order: 1. First install the terminal from the console using the command: `sudo apt install gnome-terminal`. If you can't install gnome-terminal at all, skip this step and go to step 2. 2. Return to your desktop and open the terminal using the keyboard shortcut `Ctrl` + `Alt` + `T`. From the terminal install the Ubuntu Software Center using the command: ``` sudo apt install software-center ``` In Ubuntu 16.04 and later run this command instead to reinstall the default Software application: ``` sudo apt install gnome-software ``` If you still can't open the terminal, run the same command from the console instead. If you can't install the default software application at all, skip this step and go to step 3. 3. Open the terminal and try to open the Ubuntu Software Center from the terminal by running the appropriate command, either: `software-center` or `gnome-software`. From the Ubuntu Software Center install the Ubuntu desktop system or else open the terminal (or the console) and install the Ubuntu desktop system by running the command: `sudo apt install ubuntu-desktop`.
70,814,373
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] if x == y: print("Numbers found") else: print("Numbers not found") ``` *I want to print the numbers which are not present in list y.*
2022/01/22
[ "https://Stackoverflow.com/questions/70814373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741997/" ]
The fastest way is to transform both in sets and print the difference: ``` >>> print(set(x).difference(set(y))) {6} ``` This code print numbers present in `x` but not in `y`
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] for i in x: if i in y: print(f"{i} found") else: print(f"{i} not found") ```
70,814,373
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] if x == y: print("Numbers found") else: print("Numbers not found") ``` *I want to print the numbers which are not present in list y.*
2022/01/22
[ "https://Stackoverflow.com/questions/70814373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741997/" ]
The fastest way is to transform both in sets and print the difference: ``` >>> print(set(x).difference(set(y))) {6} ``` This code print numbers present in `x` but not in `y`
to get not matches: ``` def returnNotMatches(a, b): return [[x for x in a if x not in b], [x for x in b if x not in a]] ``` or ``` new_list = list(set(list1).difference(list2)) ``` to get the intersection: ``` list1 =[1,2,3,4,5,6] list2 = [1,2,3,4,5] list1_as_set = set(list1) intersection = list1_as_set.intersection(list2) ``` output: ``` {1, 2, 3, 4, 5} ``` you can also transfer it to a list: ``` intersection_as_list = list(intersection) ``` or: ``` new_list = list(set(list1).intersection(list2)) ```
70,814,373
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] if x == y: print("Numbers found") else: print("Numbers not found") ``` *I want to print the numbers which are not present in list y.*
2022/01/22
[ "https://Stackoverflow.com/questions/70814373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741997/" ]
The fastest way is to transform both in sets and print the difference: ``` >>> print(set(x).difference(set(y))) {6} ``` This code print numbers present in `x` but not in `y`
This is the best option in my opinion. ``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] for number in x: if number not in y: print(f"{number} not found") ```
70,814,373
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] if x == y: print("Numbers found") else: print("Numbers not found") ``` *I want to print the numbers which are not present in list y.*
2022/01/22
[ "https://Stackoverflow.com/questions/70814373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741997/" ]
You can do like this: ``` x = [1,2,3,4,5,6] y = [1,2,3,4,5] for i in x: if i not in y: print(i) ```
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] for i in x: if i in y: print(f"{i} found") else: print(f"{i} not found") ```
70,814,373
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] if x == y: print("Numbers found") else: print("Numbers not found") ``` *I want to print the numbers which are not present in list y.*
2022/01/22
[ "https://Stackoverflow.com/questions/70814373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741997/" ]
You can do like this: ``` x = [1,2,3,4,5,6] y = [1,2,3,4,5] for i in x: if i not in y: print(i) ```
to get not matches: ``` def returnNotMatches(a, b): return [[x for x in a if x not in b], [x for x in b if x not in a]] ``` or ``` new_list = list(set(list1).difference(list2)) ``` to get the intersection: ``` list1 =[1,2,3,4,5,6] list2 = [1,2,3,4,5] list1_as_set = set(list1) intersection = list1_as_set.intersection(list2) ``` output: ``` {1, 2, 3, 4, 5} ``` you can also transfer it to a list: ``` intersection_as_list = list(intersection) ``` or: ``` new_list = list(set(list1).intersection(list2)) ```
70,814,373
``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] if x == y: print("Numbers found") else: print("Numbers not found") ``` *I want to print the numbers which are not present in list y.*
2022/01/22
[ "https://Stackoverflow.com/questions/70814373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17741997/" ]
You can do like this: ``` x = [1,2,3,4,5,6] y = [1,2,3,4,5] for i in x: if i not in y: print(i) ```
This is the best option in my opinion. ``` x =[1,2,3,4,5,6] y = [1,2,3,4,5] for number in x: if number not in y: print(f"{number} not found") ```
36,809,868
I have two inputs one for min and the other for max value. How can I add validation so the min < max? ```html <div class="form-group"> <label class="control-label"> Montant minimum</label> <input id="min" class="form-control" type="number" ng-model="type.minMontant" required/> </div> <div class="form-group"> <label class="control-label"> Montant maximum</label> <input id="max" class="form-control" type="number" ng-model="type.maxMontant" required/> </div> ``` And then when I'll try to pick a value, it must be in [min,max] ?
2016/04/23
[ "https://Stackoverflow.com/questions/36809868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6120367/" ]
**Not Sure if this is wat you want** **if you want validation messages to show then you have to use angular-messages** ``` <div ng-app> <div class="form-group"> <label class="control-label"> Montant minimum</label> <input id="min" class="form-control" type="number" min="0" max="{{maxMontant}}" ng-model="minMontant" required/> </div> <div class="form-group"> <label class="control-label"> Montant maximum</label> <input id="max" class="form-control" type="number" max="10" ng-model="maxMontant" required/> </div> </div> ```
add `min` and `max` attiribute(html5) ``` <div class="form-group"> <label class="control-label"> Montant minimum</label> <input id="min" class="form-control" type="number" ng-model="type.minMontant" min="0" required/> </div> <div class="form-group"> <label class="control-label"> Montant maximum</label> <input id="max" class="form-control" type="number" ng-model="type.maxMontant" max="10" required/> </div> ```
36,809,868
I have two inputs one for min and the other for max value. How can I add validation so the min < max? ```html <div class="form-group"> <label class="control-label"> Montant minimum</label> <input id="min" class="form-control" type="number" ng-model="type.minMontant" required/> </div> <div class="form-group"> <label class="control-label"> Montant maximum</label> <input id="max" class="form-control" type="number" ng-model="type.maxMontant" required/> </div> ``` And then when I'll try to pick a value, it must be in [min,max] ?
2016/04/23
[ "https://Stackoverflow.com/questions/36809868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6120367/" ]
**Not Sure if this is wat you want** **if you want validation messages to show then you have to use angular-messages** ``` <div ng-app> <div class="form-group"> <label class="control-label"> Montant minimum</label> <input id="min" class="form-control" type="number" min="0" max="{{maxMontant}}" ng-model="minMontant" required/> </div> <div class="form-group"> <label class="control-label"> Montant maximum</label> <input id="max" class="form-control" type="number" max="10" ng-model="maxMontant" required/> </div> </div> ```
You can have custom validators to check integrity of range and then check the input value with available range. Following is a simulation of it: [JSFiddle](https://jsfiddle.net/RajeshDixit/guumuvn1/1/) ```js $scope.validate = function() { var valid = $scope.validateMin() && $scope.validateMax(); if (valid) { if ($scope.type.value >= $scope.type.min && $scope.type.value <= $scope.type.max) { alert("Correct Value") } else { alert("Out of range"); } } else { alert("Incorrent range values entered"); } } ```
450,107
I'm trying to compile a project from the command line, like this: ``` devenv.exe myproj.sln /build release ``` It looks like the code compiles well, but that's not all I need: I want to be able to capture the output (e.g. warnings, errors) from the compiler as they occur. Unfortunately as soon as I issue the above command I am returned to the command prompt. When I look at process-explorer or taskmgr.exe I can see that the devenv.exe process (and a few other sub-processes) working away. If I look in the output folder I can see all of my files gradually appearing. Is there a way of making VCC work a little bit more like GCC - when I issue a build command or make a project using a Makefile, I get a stream of messages and the console blocks until the process has completed. Update: Thanks, two excellent solutions. I can confirm that it works.
2009/01/16
[ "https://Stackoverflow.com/questions/450107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46411/" ]
devenv uses this interesting dispatcher that switches between command line mode and windowed mode. There's actually a devenv.com in addition to devenv.exe, and since \*.com takes precedence over \*.exe, it gets invoked first. devenv.com analyzes the command line and decides what to invoke. In other words, change your command line to: ``` devenv myproj.sln /build release ``` And you should be ok.
use devenv.com in place of devenv.exe and you will get what you want. You can use MSBuild.exe as well for more options.
62,761,664
I'm getting via url querystring variables like: myserver\_state=1&myserver\_running=2&myserver\_mem=3 Currently i'm adding to an existing json like: ``` { "key1": "1", "key2": "2", "key3": "3", "myserver_state": "1", "myserver_running": "2", "myserver_mem": "3" } ``` And i really want it like this: ``` { "key1": "1", "key2": "2", "key3": "3", "myserver": { "state": "1", "running": "2", "mem": "3" } } ``` I'm using this to load them: ``` $formdata = array( 'state'=> $_POST['state'], 'uassip'=> $_POST['uassip'], 'uassipport'=> $_POST['uassipport'], 'c_uacminrtpport'=> $_POST['c_uacminrtpport'], 'c_uacmaxrtpport'=> $_POST['c_uacmaxrtpport'], 'c_cps'=> $_POST['c_cps'], 'c_totalcalls'=> $_POST['c_totalcalls'], 'c_maxchannels'=> $_POST['c_maxchannels'], 'c_duration'=> $_POST['c_duration'], 'c_to'=> $_POST['c_to'], 'c_uacxml'=> $_POST['c_uacxml'] ); echo "fromdata: <br>"; echo var_dump($formdata) . "<br><hr>"; if(file_put_contents('testconfig.json', json_encode($formdata) )) echo 'OK'; else echo 'Unable to save data in "testconfig.json"'; ``` Many thanks! EDIT: following comments i tried: status.php?server1[current\_state]=10 this actually works to: ``` "c_uacxml": "telnyx-uac-invite-ok.xml", "server1": { "current_state": "10" } } ``` Which is great, BUT, if i then want to add an element like this: status.php?server1[current\_mem]=1 This actually REPLACES the whole `server1` ``` "c_uacxml": "telnyx-uac-invite-ok.xml", "server1": { "current_mem": "10" } } ``` and i lose the already existing current\_state
2020/07/06
[ "https://Stackoverflow.com/questions/62761664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2115947/" ]
Just use multidimensional array within your URL like: ``` test.php?key1=1&key2=2&myserver[state]=1&myserver[running]=2&myserver[mem]=3 ``` so easy script ``` <?php echo '<pre>'; echo json_encode($_GET, JSON_PRETTY_PRINT); ``` will give you ``` { "key1": "1", "key2": "2", "myserver": { "state": "1", "running": "2", "mem": "3" } } ``` of course, if required you can use also POST request with the same naming rules.
in order to create a nested JSON object, you need to create an array within an array. E.g. ``` $example = [ 'key1' => 'foo', 'key2' => 'bar', 'key3' => [ 'subkey1' => 'foo', 'subkey2' => 'bar', ], ]; ``` When running it through `json_encode()`, it will result in ``` { "key1": "foo", "key2": "bar", "key3": { "subkey1": "foo", "subkey2": "bar" } } ``` Also it's not necessary to load form data like this – ``` $formdata = [ 'state' => $_POST['state'], 'uassip' => $_POST['uassip'], 'uassipport' => $_POST['uassipport'], 'c_uacminrtpport' => $_POST['c_uacminrtpport'], 'c_uacmaxrtpport' => $_POST['c_uacmaxrtpport'], 'c_cps' => $_POST['c_cps'], 'c_totalcalls' => $_POST['c_totalcalls'], 'c_maxchannels' => $_POST['c_maxchannels'], 'c_duration' => $_POST['c_duration'], 'c_to' => $_POST['c_to'], 'c_uacxml' => $_POST['c_uacxml'], ]; ``` Since the `$_POST` already contains a structure that you are trying to recreate. You can simply assign the post data to a new varaible. On another note, I highly recommend you to check out PSR PHP standards, they will greatly help to improve code readability and your code structure :) <https://www.php-fig.org/psr/>
42,343,463
I am having below dummy table ``` select * from ( select 'A' as col1, 'B' as col2 from dual union select 'B' as col1, 'A' as col2 from dual union select 'A' as col1, 'C' as col2 from dual union select 'C' as col1, 'A' as col2 from dual union select 'A' as col1, 'D' as col2 from dual )a ``` which will give output as below ``` col1 col2 A B A C A D B A C A ``` I wants to find the distinct values from that table like below ``` col1 col2 A B A C A D ``` first row can be A B or B A same as second can be A C or C A Is it possible?? We got the solution for above problem which is below ``` select distinct least(col1, col2), greatest(col1, col2) from the_table; ``` but if there is more than 2 column, then i wouldn't work Let us assume the below scenario Input ``` col1 col2 col3 A B E A C E A D E B A F C A E ``` Output ``` col1 col2 col3 A B E A D E B A F C A E ``` then what would be the possible solution ?
2017/02/20
[ "https://Stackoverflow.com/questions/42343463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2431786/" ]
Here is one method: ``` select col1, col2 from t where col1 <= col2 union all select col1, col2 from t where col1 > col2 and not exists (select 1 from t t2 where t2.col1 = t.col2 and t2.col2 = t.col1); ```
``` select DISTINCT * from ( select 'A' as col1, 'B' as col2 from dual union select 'B' as col1, 'A' as col2 from dual union select 'A' as col1, 'C' as col2 from dual union select 'C' as col1, 'A' as col2 from dual union select 'A' as col1, 'D' as col2 from dual )a ```
42,343,463
I am having below dummy table ``` select * from ( select 'A' as col1, 'B' as col2 from dual union select 'B' as col1, 'A' as col2 from dual union select 'A' as col1, 'C' as col2 from dual union select 'C' as col1, 'A' as col2 from dual union select 'A' as col1, 'D' as col2 from dual )a ``` which will give output as below ``` col1 col2 A B A C A D B A C A ``` I wants to find the distinct values from that table like below ``` col1 col2 A B A C A D ``` first row can be A B or B A same as second can be A C or C A Is it possible?? We got the solution for above problem which is below ``` select distinct least(col1, col2), greatest(col1, col2) from the_table; ``` but if there is more than 2 column, then i wouldn't work Let us assume the below scenario Input ``` col1 col2 col3 A B E A C E A D E B A F C A E ``` Output ``` col1 col2 col3 A B E A D E B A F C A E ``` then what would be the possible solution ?
2017/02/20
[ "https://Stackoverflow.com/questions/42343463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2431786/" ]
Here is one method: ``` select col1, col2 from t where col1 <= col2 union all select col1, col2 from t where col1 > col2 and not exists (select 1 from t t2 where t2.col1 = t.col2 and t2.col2 = t.col1); ```
``` select col1, col2 from t where col1 <= col2 union select col2, col1 from t where col1 > col2 ```
42,343,463
I am having below dummy table ``` select * from ( select 'A' as col1, 'B' as col2 from dual union select 'B' as col1, 'A' as col2 from dual union select 'A' as col1, 'C' as col2 from dual union select 'C' as col1, 'A' as col2 from dual union select 'A' as col1, 'D' as col2 from dual )a ``` which will give output as below ``` col1 col2 A B A C A D B A C A ``` I wants to find the distinct values from that table like below ``` col1 col2 A B A C A D ``` first row can be A B or B A same as second can be A C or C A Is it possible?? We got the solution for above problem which is below ``` select distinct least(col1, col2), greatest(col1, col2) from the_table; ``` but if there is more than 2 column, then i wouldn't work Let us assume the below scenario Input ``` col1 col2 col3 A B E A C E A D E B A F C A E ``` Output ``` col1 col2 col3 A B E A D E B A F C A E ``` then what would be the possible solution ?
2017/02/20
[ "https://Stackoverflow.com/questions/42343463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2431786/" ]
The following will work for Oracle and Postgres: ``` select distinct least(col1, col2), greatest(col1, col2) from the_table; ``` Online example: <http://rextester.com/BZXC69735>
``` select DISTINCT * from ( select 'A' as col1, 'B' as col2 from dual union select 'B' as col1, 'A' as col2 from dual union select 'A' as col1, 'C' as col2 from dual union select 'C' as col1, 'A' as col2 from dual union select 'A' as col1, 'D' as col2 from dual )a ```
42,343,463
I am having below dummy table ``` select * from ( select 'A' as col1, 'B' as col2 from dual union select 'B' as col1, 'A' as col2 from dual union select 'A' as col1, 'C' as col2 from dual union select 'C' as col1, 'A' as col2 from dual union select 'A' as col1, 'D' as col2 from dual )a ``` which will give output as below ``` col1 col2 A B A C A D B A C A ``` I wants to find the distinct values from that table like below ``` col1 col2 A B A C A D ``` first row can be A B or B A same as second can be A C or C A Is it possible?? We got the solution for above problem which is below ``` select distinct least(col1, col2), greatest(col1, col2) from the_table; ``` but if there is more than 2 column, then i wouldn't work Let us assume the below scenario Input ``` col1 col2 col3 A B E A C E A D E B A F C A E ``` Output ``` col1 col2 col3 A B E A D E B A F C A E ``` then what would be the possible solution ?
2017/02/20
[ "https://Stackoverflow.com/questions/42343463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2431786/" ]
The following will work for Oracle and Postgres: ``` select distinct least(col1, col2), greatest(col1, col2) from the_table; ``` Online example: <http://rextester.com/BZXC69735>
``` select col1, col2 from t where col1 <= col2 union select col2, col1 from t where col1 > col2 ```
9,582,357
My knowledge of MVC and Razor is quite basic so I'm hoping its something rather simple. Basically, I have my `Controllers` as normal but my `Views` folder has a nested structure. For example, instead of: ``` Views -> Index.cshtml ``` It is like ``` Views -> BrandName -> Index.cshtml ``` I created a custom helper to work around this, but I'm not sure how it would work with query string urls? As an example here is a controller: ``` private DataService ds = new DataService(); // // GET: /Collections/ public ActionResult Index() { return View(); } // // GET: /Collections/Collection?id=1 public ActionResult Collection(int id) { var collectionModel = ds.GetCollection(id); return View(collectionModel); } ``` But how do I get `ActionResult Collection` to look at: ``` Views -> Brand2 -> Collection.cshtml ``` Here is the workaround method I was using: ``` public static string ResolvePath(string pageName) { string path = String.Empty; //AppSetting Key=Brand string brand = ConfigurationManager.AppSettings["Brand"]; if (String.IsNullOrWhiteSpace(brand)) path = "~/Views/Shared/Error.cshtml"; //Key [Brand] was not specified else path = String.Format("~/Views/{0}/{1}", brand, pageName); return path; } ```
2012/03/06
[ "https://Stackoverflow.com/questions/9582357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/849843/" ]
Use the following ``` public ActionResult Collection(int id) { var collectionModel = ds.GetCollection(id); return View("/Brand2/Collection", collectionModel); } ``` The above code will search for the following views. ``` ~/Views/Brand2/Collection.aspx ~/Views/Brand2/Collection.ascx ~/Views/Shared/Brand2/Collection.aspx ~/Views/Shared/Brand2/Collection.ascx ~/Views/Brand2/Collection.cshtml ~/Views/Brand2/Collection.vbhtml ~/Views/Shared/Brand2/Collection.cshtml ~/Views/Shared/Brand2/Collection.vbhtml ``` or to be more direct ``` public ActionResult Collection(int id) { var collectionModel = ds.GetCollection(id); return View("~/Brand2/Collection.cshtml", collectionModel); } ``` Now, I want to be the first to warn you that you should never, never, never use this answer. There is a good reason for following the conventions inherent in an MVC application. Placing your files in known locations makes it easier for everyone to understand your application.
You can do this on application start by adding paths that the view engine should check like so. ``` RazorViewEngine razorEngine = ViewEngines.Engines.OfType<RazorViewEngine>() .FirstOrDefault(); List<string> viewLocationFormats = new List<string>(); newPartialViewFormats.Add("~/Views/Shared/MyDirectory/{0}.cshtml"); //add any other directories you want to check as well razorEngine.ViewLocationFormats = razorEngine.ViewLocationFormats.Union(viewLocationFormats).ToArray(); ``` For partial views you can do similar but on the `razorEngine.PartialViewLocationFormats` property instead.
1,605,718
I need to calculate: $$ \iint \_D \frac{2y^2+x^2}{xy}~\mathrm dx~\mathrm dy $$ over the set $D$ which is: $$ y\leq x^2 \leq 2y , \quad 1\leq x^2 +y^2 \leq 2 , \quad x\geq 0 $$ can someone help me understand what possible change of variables can I do here? Thanks a lot in advance .
2016/01/09
[ "https://math.stackexchange.com/questions/1605718", "https://math.stackexchange.com", "https://math.stackexchange.com/users/173919/" ]
You have $$\begin{aligned}\vert f(x)-f(y) \vert &= \left\vert \sqrt{x^2+1}-\sqrt{y^2+1} \right\vert \\ &= \left\vert (\sqrt{x^2+1}-\sqrt{y^2+1}) \frac{\sqrt{x^2+1}+\sqrt{y^2+1}}{\sqrt{x^2+1}+\sqrt{y^2+1}} \right\vert \\ &= \left\vert \frac{x^2-y^2}{\sqrt{x^2+1}+\sqrt{y^2+1}} \right\vert \\ &\le \frac{\vert x-y \vert (\vert x \vert + \vert y \vert )}{ \sqrt{x^2+1}+\sqrt{y^2+1}} \\ &\le \vert x-y \vert \end{aligned}$$ hence choosing $\delta = \epsilon$ will work.
Note that $f'(x)= x/\sqrt {x^2+1}$ for all $x.$ We thus have $|f'(x)|<1$ everywhere. Suppose $x,y\in \mathbb R.$ Then the mean value theorem gives $$f(y)-f(x) = f'(c)(y-x) \implies |f(y)-f(x)| \le |y-x|.$$ This easily gives the uniform continuity of $f$ on $\mathbb R.$
54,902,426
I'm trying to use a plotly example in Python 3, but getting a syntax error in this line: ``` return map(lambda (x, y, an): (x, y), cornersWithAngles) ``` I already read that using parentheses to unpack the arguments in a lambda is not allowed in Python 3, but I don't know how exactly to adjust my code to solve that problem. Here is the complete code (error is on line 16): ``` import plotly.plotly as py import plotly.graph_objs as go from plotly.tools import FigureFactory as FF import scipy def PolygonSort(corners): n = len(corners) cx = float(sum(x for x, y in corners)) / n cy = float(sum(y for x, y in corners)) / n cornersWithAngles = [] for x, y in corners: an = (np.arctan2(y - cy, x - cx) + 2.0 * np.pi) % (2.0 * np.pi) cornersWithAngles.append((x, y, an)) cornersWithAngles.sort(key = lambda tup: tup[2]) return map(lambda (x, y, an): (x, y), cornersWithAngles) def PolygonArea(corners): n = len(corners) area = 0.0 for i in range(n): j = (i + 1) % n area += corners[i][0] * corners[j][1] area -= corners[j][0] * corners[i][1] area = abs(area) / 2.0 return area corners = [(0, 0), (3, 0), (2, 10), (3, 4), (1, 5.5)] corners_sorted = PolygonSort(corners) area = PolygonArea(corners_sorted) x = [corner[0] for corner in corners_sorted] y = [corner[1] for corner in corners_sorted] annotation = go.Annotation( x=5.5, y=8.0, text='The area of the polygon is approximately %s' % (area), showarrow=False ) trace1 = go.Scatter( x=x, y=y, mode='markers', fill='tozeroy', ) layout = go.Layout( annotations=[annotation], xaxis=dict( range=[-1, 9] ), yaxis=dict( range=[-1, 12] ) ) trace_data = [trace1] fig = go.Figure(data=trace_data, layout=layout) py.iplot(fig, filename='polygon-area') ```
2019/02/27
[ "https://Stackoverflow.com/questions/54902426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890524/" ]
This is an oversight in the SystemVerilog LRM. There's no syntax to specify a required set of parameters for an interface in a module header. You might check your synthesis tool to see if they provide any way of specifying parameter overrides for the top-level synthesis instance.
You specify the parameter when you instantiate the interface; you do not specify it in the port list of the module. Given ``` interface myinterface #(parameter DATA_SIZE = 0); ... ``` All you need is ``` module mymodule (myinterface.mymodport mybus); ... ``` because somewhere else you have ``` myinterface #(.DATA_SIZE(64)) i(); ``` --- ``` interface myinterface #(parameter DATA_SIZE = 0); logic [DATA_SIZE-1:0] AWID; logic [31:0] AWADDR; modport mymodport (input AWID, AWADDR); endinterface module mymodule (myinterface.mymodport mybus); initial $display("mymodule"); endmodule module top; myinterface #(.DATA_SIZE(64)) i(); mymodule m (.mybus(i)); endmodule ``` <https://www.edaplayground.com/x/528x>
195,688
I've written a code in a WP\_Query to converting a string (the\_content) to an array (choices). But it seems wrong! In fact, the choices array is empty after each loop. However str string is notnull. How can i handle this array to be nutnull? Any help would be appreciated. ``` $first_query = new WP_Query( $args ); while ($first_query->have_posts()) : $first_query->the_post(); the_title(); //echo the title the_content(); //echo the content $str = the_content(); $choices = explode("-",$str); var_dump($choices); endwhile; ```
2015/07/27
[ "https://wordpress.stackexchange.com/questions/195688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71448/" ]
You have a couple of issues here * `the_content()` echos the content to screen. You should be using `get_the_content()` which returns the content. Just remember, `get_the_content()` is unfiltered, so if you need filtered content, use `apply_filters( 'the_content', get_the_content() )` which will return filtered content. * Your `explode()` function is probably wrong as well. You are using a hyphen to explode your content into pieces of an array. If your content don't contain hyphens, your array will only have one key with the complete content as value. You would probably need to use white spaces (*`explode( ' ', get_the_content() );`*) or regular expressions or something similar to targt more than hypens or white spaces to explode the content. In one of my [previous posts for custom excerpts](https://wordpress.stackexchange.com/a/141136/31545) , I have used something similar to explode my content, here is something you can try and experiment with ``` preg_match_all('/(<[^>]+>|[^<>\s]+)\s*/u', get_the_content(), $tokens); var_dump( $tokens ); ```
Try with: `$str = get_the_content();`
108,171
How do I get the following to show up (on stackoverflow) with color syntax highlighting? class Foo { internal Foo() { for (int i = 0; i < 42; ++i); } }
2011/10/02
[ "https://meta.stackexchange.com/questions/108171", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/170189/" ]
See <https://stackoverflow.com/editing-help>. Basically, for code, indent four spaces -- you can do this by pasting code then highlighting and hitting `Ctrl` + `K` or the ``{}`` button above the editing box. As far as syntax highlighting, see [Changes to syntax highlighting](https://meta.stackexchange.com/questions/72082/changes-to-syntax-highlighting) and [Interface options for specifying language prettify](https://meta.stackexchange.com/questions/63800/interface-options-for-specifying-language-prettify/81970#81970). The correct language will often be inferred by the tags on the question, but you can manually specify it with an HTML comment: ``` <!-- language: c# --> public static bool IsAwesome { get { return true; } } ``` or ``` <!-- language: lang-js --> setTimeout(function () { alert("JavaScript"); }, 1000); ``` before the code block.
If you want to insert code inline like this `int i = 0;` use backticks: ``int i = 0;``. If you want an entire block of code you can highlight it and then click the code button which looks like `{}`. You can also hit `Ctrl+K` while it's highlight, or just manually indent it all 4 spaces: ``` class Foo { internal Foo() { for (int i = 0; i < 42; ++i); } } ```
12,521
Who knows two hundred eighty-five? ---------------------------------- ?חמישה ושמונים ומאתים - מי יודע ------------------------------- In the spirit of the song ["Echad - mi yodeya"](http://en.wikipedia.org/wiki/Echad_Mi_Yodea), please post interesting and significant Jewish facts about the number 285. The best lazy gematria I can come up with for this one is weak, but that's no reason to be cowed. Check out [mi-yodeya-series](/questions/tagged/mi-yodeya-series "show questions tagged 'mi-yodeya-series'") for the previous two hundred eighty-four entries in this ongoing series. Please include sources for your information wherever possible, as with all other answers on this site.
2011/12/22
[ "https://judaism.stackexchange.com/questions/12521", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/2/" ]
As Alex correctly noted here [Arba'a Ushmonim Umatayim - mi yodeya?](https://judaism.stackexchange.com/questions/12394/arbaa-ushmonim-umatayim-mi-yodeya/12404#12404) 285 is the most psukim read on a regular shabbat in sefard/chassidishe shuls: * Mattot 112 * Ma'asei 132 * Maftir 3 * Haftora 27 * Mincha 11 * TOTAL 285 Note the longer haftorah than the previous answer.
The first translation of the Hebrew Bible was written in Greek. This began in 285 BCE
12,521
Who knows two hundred eighty-five? ---------------------------------- ?חמישה ושמונים ומאתים - מי יודע ------------------------------- In the spirit of the song ["Echad - mi yodeya"](http://en.wikipedia.org/wiki/Echad_Mi_Yodea), please post interesting and significant Jewish facts about the number 285. The best lazy gematria I can come up with for this one is weak, but that's no reason to be cowed. Check out [mi-yodeya-series](/questions/tagged/mi-yodeya-series "show questions tagged 'mi-yodeya-series'") for the previous two hundred eighty-four entries in this ongoing series. Please include sources for your information wherever possible, as with all other answers on this site.
2011/12/22
[ "https://judaism.stackexchange.com/questions/12521", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/2/" ]
As Alex correctly noted here [Arba'a Ushmonim Umatayim - mi yodeya?](https://judaism.stackexchange.com/questions/12394/arbaa-ushmonim-umatayim-mi-yodeya/12404#12404) 285 is the most psukim read on a regular shabbat in sefard/chassidishe shuls: * Mattot 112 * Ma'asei 132 * Maftir 3 * Haftora 27 * Mincha 11 * TOTAL 285 Note the longer haftorah than the previous answer.
Gimtaria "El Rahum (Merciful God)."
40,849,509
Using the defaults of the train in caret package, I am trying to train a random forest model for the dataset xtr2 (dim(xtr2): 765 9408). The problem is that it unbelievably takes too long (more than one day for one training) to fit the function. As far as I know train in its default uses bootstrap sampling (25 times) and three random selection of mtry, so why it should take so long? Please notice that I need to train the rf, three times in each run (because I need to make a mean of the results of different random forest models with the same data), and it takes about three days, and I need to run the code for 10 different samples, so it would take me 30 days to have the results. My question is how I can make it faster? 1. Can changing the defaults of train make the operation time less? for example using CV for training? 2. Can parallel processing with caret package help? if yes, how it can be done? 3. Can tuneRF of random forest package make any changes to the time? This is the code: ``` rffit=train(xtr2,ytr2,method="rf",ntree=500) rf.mdl =randomForest(x=xtr2,y=as.factor(ytr2),ntree=500, keep.forest=TRUE,importance=TRUE,oob.prox =FALSE , mtry = rffit$bestTune$mtry) ``` Thank you,
2016/11/28
[ "https://Stackoverflow.com/questions/40849509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6845158/" ]
My thoughts on your questions: 1. Yes! But don't forget you also have control over the search grid `caret` uses for the tuning parameters; in this case, `mtry`. I'm not sure what the default search grid is for `mtry`, but try the following: ctrl <- trainControl("cv", number = 5, verboseIter = TRUE) set.seed(101) # for reproducibility rffit <- train(xtr2, ytr2, method = "rf", trControl = ctrl, tuneLength = 5) 2. Yes! See the `caret` website: <http://topepo.github.io/caret/parallel-processing.html> 3. Yes and No! `tuneRF` simply uses the OOB error to find an optimal value of `mtry` (the only tuning parameter in `randomForest`). Using cross-validation tends to work better and produce a more honest estimate of model performance. `tuneRF` can take a long time but should be quicker than k-fold cross-validation. Overall, the online manual for `caret` is quite good: <http://topepo.github.io/caret/index.html>. Good luck!
You use `train` for determining `mtry` only. I would skip the `train` step, and stay with default `mtry`: ``` rf.mdl =randomForest(x=xtr2,y=as.factor(ytr2),ntree=500, keep.forest=TRUE,importance=TRUE,oob.prox =FALSE) ``` I strongly doubt that 3 different runs is a good idea. If you do 10 fold cross-validation (I am not sure it should be done anyways, as validation is ingrained into the random forest), 10 parts is too much, if you are short in time. 5 parts would be enough. Finally, the time of randomForest is proportional to nTree. Set nTree=100, and your program will run 5 time faster.
40,849,509
Using the defaults of the train in caret package, I am trying to train a random forest model for the dataset xtr2 (dim(xtr2): 765 9408). The problem is that it unbelievably takes too long (more than one day for one training) to fit the function. As far as I know train in its default uses bootstrap sampling (25 times) and three random selection of mtry, so why it should take so long? Please notice that I need to train the rf, three times in each run (because I need to make a mean of the results of different random forest models with the same data), and it takes about three days, and I need to run the code for 10 different samples, so it would take me 30 days to have the results. My question is how I can make it faster? 1. Can changing the defaults of train make the operation time less? for example using CV for training? 2. Can parallel processing with caret package help? if yes, how it can be done? 3. Can tuneRF of random forest package make any changes to the time? This is the code: ``` rffit=train(xtr2,ytr2,method="rf",ntree=500) rf.mdl =randomForest(x=xtr2,y=as.factor(ytr2),ntree=500, keep.forest=TRUE,importance=TRUE,oob.prox =FALSE , mtry = rffit$bestTune$mtry) ``` Thank you,
2016/11/28
[ "https://Stackoverflow.com/questions/40849509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6845158/" ]
My thoughts on your questions: 1. Yes! But don't forget you also have control over the search grid `caret` uses for the tuning parameters; in this case, `mtry`. I'm not sure what the default search grid is for `mtry`, but try the following: ctrl <- trainControl("cv", number = 5, verboseIter = TRUE) set.seed(101) # for reproducibility rffit <- train(xtr2, ytr2, method = "rf", trControl = ctrl, tuneLength = 5) 2. Yes! See the `caret` website: <http://topepo.github.io/caret/parallel-processing.html> 3. Yes and No! `tuneRF` simply uses the OOB error to find an optimal value of `mtry` (the only tuning parameter in `randomForest`). Using cross-validation tends to work better and produce a more honest estimate of model performance. `tuneRF` can take a long time but should be quicker than k-fold cross-validation. Overall, the online manual for `caret` is quite good: <http://topepo.github.io/caret/index.html>. Good luck!
I would also just add, that it the main issue is speed, there are several other random forest implementations in `caret`, and many of them are much faster than the original `randomForest` which is notoriously slow. I've found `ranger` to be a nice alternative that suited my very simple needs. Here is a nice [summary of the random forest packges in R](https://www.linkedin.com/pulse/different-random-forest-packages-r-madhur-modi). Many of these are in `caret` already. Also for consideration, here's an interesting [study of the performance of `ranger` vs `rborist`](https://www.researchgate.net/publication/281144987_ranger_A_Fast_Implementation_of_Random_Forests_for_High_Dimensional_Data_in_C_and_R/figures), where you can see how performance is affected by the tradeoff between sample size and features.
40,849,509
Using the defaults of the train in caret package, I am trying to train a random forest model for the dataset xtr2 (dim(xtr2): 765 9408). The problem is that it unbelievably takes too long (more than one day for one training) to fit the function. As far as I know train in its default uses bootstrap sampling (25 times) and three random selection of mtry, so why it should take so long? Please notice that I need to train the rf, three times in each run (because I need to make a mean of the results of different random forest models with the same data), and it takes about three days, and I need to run the code for 10 different samples, so it would take me 30 days to have the results. My question is how I can make it faster? 1. Can changing the defaults of train make the operation time less? for example using CV for training? 2. Can parallel processing with caret package help? if yes, how it can be done? 3. Can tuneRF of random forest package make any changes to the time? This is the code: ``` rffit=train(xtr2,ytr2,method="rf",ntree=500) rf.mdl =randomForest(x=xtr2,y=as.factor(ytr2),ntree=500, keep.forest=TRUE,importance=TRUE,oob.prox =FALSE , mtry = rffit$bestTune$mtry) ``` Thank you,
2016/11/28
[ "https://Stackoverflow.com/questions/40849509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6845158/" ]
You use `train` for determining `mtry` only. I would skip the `train` step, and stay with default `mtry`: ``` rf.mdl =randomForest(x=xtr2,y=as.factor(ytr2),ntree=500, keep.forest=TRUE,importance=TRUE,oob.prox =FALSE) ``` I strongly doubt that 3 different runs is a good idea. If you do 10 fold cross-validation (I am not sure it should be done anyways, as validation is ingrained into the random forest), 10 parts is too much, if you are short in time. 5 parts would be enough. Finally, the time of randomForest is proportional to nTree. Set nTree=100, and your program will run 5 time faster.
I would also just add, that it the main issue is speed, there are several other random forest implementations in `caret`, and many of them are much faster than the original `randomForest` which is notoriously slow. I've found `ranger` to be a nice alternative that suited my very simple needs. Here is a nice [summary of the random forest packges in R](https://www.linkedin.com/pulse/different-random-forest-packages-r-madhur-modi). Many of these are in `caret` already. Also for consideration, here's an interesting [study of the performance of `ranger` vs `rborist`](https://www.researchgate.net/publication/281144987_ranger_A_Fast_Implementation_of_Random_Forests_for_High_Dimensional_Data_in_C_and_R/figures), where you can see how performance is affected by the tradeoff between sample size and features.
3,989,152
I want to calculate $$\sum\_{k=0}^\infty\binom{k+3}k(0.2)^k$$ to get the exact value of it. I have excel and other tools to help me so it is fine if it is computationally expensive. Is there a clear and repeatable way to solve this infinite series? Thank you. This is my first post and be sure to give me some suggestions as well.
2021/01/17
[ "https://math.stackexchange.com/questions/3989152", "https://math.stackexchange.com", "https://math.stackexchange.com/users/875026/" ]
It’s a general fact that $$\sum\_{k\ge 0}\binom{k+n}nx^k=\frac1{(1-x)^{n+1}}\;.$$ You can prove this by induction on $n$, starting with the geometric series $$\frac1{1-x}=\sum\_{k\ge 0}x^k$$ and differentiating repeatedly with respect to $x$. You want the case $n=3$: $$\sum\_{k\ge 0}\binom{k+3}kx^k=\sum\_{k\ge 0}\binom{k+3}3x^k=\frac1{(1-x)^4}\,.$$ Now just substitute $x=0.2$.
Using the [negative binomial coefficient](https://math.stackexchange.com/a/217647/13854) $\binom{-4}{k}$, we have $$ \begin{align} \sum\_{k=0}^\infty\binom{k+3}{k}(0.2)^k &=\sum\_{k=0}^\infty\binom{-4}k(-1)^k(0.2)^k\\ &=(1-0.2)^{-4}\\[6pt] &=\frac{625}{256} \end{align} $$
1,576,277
I hosted one `DotNetNUke Application` to my production server, and locally it works perfectly. But, when browsing it redirects to the error page. How do I set the `default.aspx` as my application default page? I am getting the error as below: ``` DotNetNuke Error -------------------------------------------------------------------------------- Windows Vista Return to Site ``` Can anyone can help me, please? Will be appreciated. **UPDATE:** Hi, I changed the Path in the PortalAlias table to the server url and `default.aspx` as the starting page, but it displays the `error.aspx` as default page. Please help me resolve this problem..
2009/10/16
[ "https://Stackoverflow.com/questions/1576277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191017/" ]
That's very easy - build a folder tree based on GUID values parts. For example, make 256 folders each named after the first byte and only store there files that have a GUID starting with this byte. If that's still too many files in one folder - do the same in each folder for the second byte of the GUID. Add more levels if needed. Search for a file will be very fast. By selecting the number of bytes you use for each level you can effectively choose the tree structure for your scenario.
I would try and keep the # of files in each directory to some manageable number. The easiest way to do this is name the subdirectory after the first 2-3 characters of the GUID.
1,576,277
I hosted one `DotNetNUke Application` to my production server, and locally it works perfectly. But, when browsing it redirects to the error page. How do I set the `default.aspx` as my application default page? I am getting the error as below: ``` DotNetNuke Error -------------------------------------------------------------------------------- Windows Vista Return to Site ``` Can anyone can help me, please? Will be appreciated. **UPDATE:** Hi, I changed the Path in the PortalAlias table to the server url and `default.aspx` as the starting page, but it displays the `error.aspx` as default page. Please help me resolve this problem..
2009/10/16
[ "https://Stackoverflow.com/questions/1576277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191017/" ]
I would try and keep the # of files in each directory to some manageable number. The easiest way to do this is name the subdirectory after the first 2-3 characters of the GUID.
Sorting the audio files into separate subdirectories may slower if `dir_index` is used on the ext3 volume. (dir\_index: "Use hashed b-trees to speed up lookups in large directories.") This command will set the dir\_index feature: `tune2fs -O dir_index /dev/sda1`
1,576,277
I hosted one `DotNetNUke Application` to my production server, and locally it works perfectly. But, when browsing it redirects to the error page. How do I set the `default.aspx` as my application default page? I am getting the error as below: ``` DotNetNuke Error -------------------------------------------------------------------------------- Windows Vista Return to Site ``` Can anyone can help me, please? Will be appreciated. **UPDATE:** Hi, I changed the Path in the PortalAlias table to the server url and `default.aspx` as the starting page, but it displays the `error.aspx` as default page. Please help me resolve this problem..
2009/10/16
[ "https://Stackoverflow.com/questions/1576277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191017/" ]
That's very easy - build a folder tree based on GUID values parts. For example, make 256 folders each named after the first byte and only store there files that have a GUID starting with this byte. If that's still too many files in one folder - do the same in each folder for the second byte of the GUID. Add more levels if needed. Search for a file will be very fast. By selecting the number of bytes you use for each level you can effectively choose the tree structure for your scenario.
Sorting the audio files into separate subdirectories may slower if `dir_index` is used on the ext3 volume. (dir\_index: "Use hashed b-trees to speed up lookups in large directories.") This command will set the dir\_index feature: `tune2fs -O dir_index /dev/sda1`
1,576,277
I hosted one `DotNetNUke Application` to my production server, and locally it works perfectly. But, when browsing it redirects to the error page. How do I set the `default.aspx` as my application default page? I am getting the error as below: ``` DotNetNuke Error -------------------------------------------------------------------------------- Windows Vista Return to Site ``` Can anyone can help me, please? Will be appreciated. **UPDATE:** Hi, I changed the Path in the PortalAlias table to the server url and `default.aspx` as the starting page, but it displays the `error.aspx` as default page. Please help me resolve this problem..
2009/10/16
[ "https://Stackoverflow.com/questions/1576277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191017/" ]
That's very easy - build a folder tree based on GUID values parts. For example, make 256 folders each named after the first byte and only store there files that have a GUID starting with this byte. If that's still too many files in one folder - do the same in each folder for the second byte of the GUID. Add more levels if needed. Search for a file will be very fast. By selecting the number of bytes you use for each level you can effectively choose the tree structure for your scenario.
Construct n level deep folder hierarchy to store your files. The names of the nested folders will the first n bytes of the corresponding file name. For example: For storing a file "63f4c070-0ab2-102d-adcb-0015f22e2e5c" in a four level deep folder hierarchy, construct 6/3/f/4 and place this file in this hierarchy. The depth of the hierarchy depends on the maximum number of files you can have in your system. For a few million files in my project 4 level deep hierarchy works well. I also did the same thing in my project having nearly 1 million files. My requirement was also to process the files by traversing this huge list. I constructed a 4 level deep folder hierarchy and the processing time reduced from nearly 10 minutes to a few seconds. An add on to this optimization can be that, if you want to process all the files present in these deep folder hierarchies, then instead of calling a function to fetch the list for the first 4 levels just precompute all the possible 4 level deep folder hierarchy names. Suppose the guid can have 16 possible characters then we will have 16 folders each at the first four levels, we can just precompute the 16\*16\*16\*16 folder hierarchies which takes just a few ms. This save a lot of time if these large number of files are stored at a shared location and calling a function to fetch the list in a directory takes nearly a second.
1,576,277
I hosted one `DotNetNUke Application` to my production server, and locally it works perfectly. But, when browsing it redirects to the error page. How do I set the `default.aspx` as my application default page? I am getting the error as below: ``` DotNetNuke Error -------------------------------------------------------------------------------- Windows Vista Return to Site ``` Can anyone can help me, please? Will be appreciated. **UPDATE:** Hi, I changed the Path in the PortalAlias table to the server url and `default.aspx` as the starting page, but it displays the `error.aspx` as default page. Please help me resolve this problem..
2009/10/16
[ "https://Stackoverflow.com/questions/1576277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191017/" ]
Construct n level deep folder hierarchy to store your files. The names of the nested folders will the first n bytes of the corresponding file name. For example: For storing a file "63f4c070-0ab2-102d-adcb-0015f22e2e5c" in a four level deep folder hierarchy, construct 6/3/f/4 and place this file in this hierarchy. The depth of the hierarchy depends on the maximum number of files you can have in your system. For a few million files in my project 4 level deep hierarchy works well. I also did the same thing in my project having nearly 1 million files. My requirement was also to process the files by traversing this huge list. I constructed a 4 level deep folder hierarchy and the processing time reduced from nearly 10 minutes to a few seconds. An add on to this optimization can be that, if you want to process all the files present in these deep folder hierarchies, then instead of calling a function to fetch the list for the first 4 levels just precompute all the possible 4 level deep folder hierarchy names. Suppose the guid can have 16 possible characters then we will have 16 folders each at the first four levels, we can just precompute the 16\*16\*16\*16 folder hierarchies which takes just a few ms. This save a lot of time if these large number of files are stored at a shared location and calling a function to fetch the list in a directory takes nearly a second.
Sorting the audio files into separate subdirectories may slower if `dir_index` is used on the ext3 volume. (dir\_index: "Use hashed b-trees to speed up lookups in large directories.") This command will set the dir\_index feature: `tune2fs -O dir_index /dev/sda1`
61,174,221
I need to parse date value to specific format without using format field in dateFromString operator. [Mongo Playground](https://mongoplayground.net/p/U9thsJCE88V) Current situation : in Mongodb 4.0 if I format dateString using below it code it give me mentioned output. ``` parsedDate: { $dateFromString: { dateString: "$dateS", format: format: "%Y-%m-%dT%H" } } Output: "parsedDate": ISODate("2020-01-16T08:00:00Z") ``` I cannot use format field in 3.6 since its not supported. How do I convert my date to `format: "%Y-%m-%dT%H"` in 3.6?
2020/04/12
[ "https://Stackoverflow.com/questions/61174221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10516241/" ]
If I get the requirement right, Try the following query which uses: [`$dateFromParts`](https://docs.mongodb.com/manual/reference/operator/aggregation/dateFromParts/) **Input:** ``` [ { "date": ISODate("2020-01-16T08:54:17.604Z") } ] ``` **Query:** ``` db.collection.aggregate([ { $project: { outputDate: { $dateFromParts: { "year": { $year: "$date" }, "month": { $month: "$date" }, "day": { $dayOfMonth: "$date" }, "hour": { $hour: "$date" } } } } } ]); ``` **O/P:** ``` [ { "_id": ObjectId("5a934e000102030405000000"), "outputDate": ISODate("2020-01-16T08:00:00Z") } ] ``` [Playground Test Link](https://mongoplayground.net/p/BiAeIbEBZCO)
This worked for me: I used combined solution from @ambienBeing and @techstack. Thanks [Mongo playground](https://mongoplayground.net/p/aUBwxfZO_Qm) ``` "parsedDate": { "$dateFromParts": { "year": { "$year": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } }, "month": { "$month": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } }, "day": { "$dayOfMonth": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } }, "hour": { "$hour": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } } } }, ```
61,174,221
I need to parse date value to specific format without using format field in dateFromString operator. [Mongo Playground](https://mongoplayground.net/p/U9thsJCE88V) Current situation : in Mongodb 4.0 if I format dateString using below it code it give me mentioned output. ``` parsedDate: { $dateFromString: { dateString: "$dateS", format: format: "%Y-%m-%dT%H" } } Output: "parsedDate": ISODate("2020-01-16T08:00:00Z") ``` I cannot use format field in 3.6 since its not supported. How do I convert my date to `format: "%Y-%m-%dT%H"` in 3.6?
2020/04/12
[ "https://Stackoverflow.com/questions/61174221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10516241/" ]
I think following query will solve your problem because MongoDB 3.6 supports *dateFromString* Input: ``` [ { "dateS": "2020-01-16T08" } ] ``` Query: ``` db.collection.aggregate([ { "$project": { "year": {"$substr": ["$dateS",0,4]}, "month": {"$substr": ["$dateS",5,2]}, "day": {"$substr": ["$dateS",8,2]}, "hour": {"$substr": ["$dateS",11,2]} } }, { $addFields: { "isoString": { "$concat": ["$year","-","$month","-","$day","T","$hour",":00:00Z"] } } }, { $addFields: { "newDate": { $dateFromString: {"dateString": "$isoString"} } } } ]) ``` Output: ``` [ { "_id": ObjectId("5a934e000102030405000000"), "day": "16", "hour": "08", "isoString": "2020-01-16T08:00:00Z", "month": "01", "newDate": ISODate("2020-01-16T08:00:00Z"), "year": "2020" } ] ```
This worked for me: I used combined solution from @ambienBeing and @techstack. Thanks [Mongo playground](https://mongoplayground.net/p/aUBwxfZO_Qm) ``` "parsedDate": { "$dateFromParts": { "year": { "$year": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } }, "month": { "$month": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } }, "day": { "$dayOfMonth": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } }, "hour": { "$hour": { $dateFromString: { dateString: { "$concat": [ "$_id.dateHour", ":00:00Z" ] } } } } } }, ```
37,167,788
I have a TableViewController in a TabBar. When I select one cell of my tableView, I want start a new controller with pushViewController(MyNewController). This is my code : **In my TableView :** ``` func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let myController = (storyboard.instantiateViewControllerWithIdentifier("MyViewController") as? MyViewController)! myController.parameter = self.tableau[indexPath.row] UINavigationController().pushViewController(myController, animated: true) } ``` **In my TabBar :** ``` func viewDidLoad() { super.viewDidLoad() var controllerArray: [UIViewController] = [] let controller: UIViewController = ClubPreviewListViewController() controller.title = "TEST" controllerArray.append(controller) self.view.addSubview(pageMenu!.view) } ``` *(I use CAPSPageMenu for customize my TabBar, but it's not the problem, I have the same problem without)* **In my controller :** ``` deinit { print ("TEST") } ``` When I select a cell, the log write "TEST" everytime I select but don't change the view. I think it's my navigationController the problem, but I don't know how to fix it. Before I implement the TabBar, I use my TableView alone, and the push did works. Sorry for my english ! Thanks for your help. **EDIT:** I change my pushViewController : ``` func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let myController = (storyboard.instantiateViewControllerWithIdentifier("MyViewController") as? MyViewController)! myController.parameter = self.tableau[indexPath.row] //UINavigationController().pushViewController(myController, animated: true) self.navigationController?.pushViewController(myController, animated: true) } ``` Same reaction. My NavigationController isn't directly link with my TabBar. I need to create an other one ? I don't really understand how NavigationController works ! [This is my configuration](http://i.stack.imgur.com/OtUJL.jpg) **EDIT2:** **If I use the navigationController of my TabBar and not of my TableView, the view change !** ``` self.saveTabBarNavigationController.pushViewController(myController, animated: true) ```
2016/05/11
[ "https://Stackoverflow.com/questions/37167788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6175849/" ]
First, the correct way to write your query is: ``` SELECT CustomerID, SUM(SubTotal) FROM Sales.SalesOrderHeader GROUP BY CustomerID; ``` Using `SELECT DISTINCT` with window functions is clever. But, it overcomplicates the query, can have poorer performance, and is confusing to anyone reading it. To get the information by year (for each customer), just add that to the `SELECT` and `GROUP BY`: ``` SELECT CustomerID, YEAR(OrderDate) as yyyy, SUM(SubTotal) FROM Sales.SalesOrderHeader GROUP BY CustomerID, YEAR(OrderDate) ORDER BY CustomerId, yyyy; ``` If you actually want to get separate rows with subtotals, then study up on `GROUPING SETS` and `ROLLUP`. These are options to the `GROUP BY`.
You should use `group by` instead of `PARTITION BY` whenever you need an aggregate (`sum/count/max`) against a specific column like (customerid) as following ``` select customerId, sum(subTotal) FROM sales.salesOrderHeader group by customerId ``` **Edit** : including missing requirement of date (response to comment) If you want calculation against more than one column, you still can do it same way. Just add the `date` in group by clause as `group by customerId, saleDate` ``` select customerId, sum(subTotal) ,saleDate //=> you can miss it (date) from selection if you want to FROM sales.salesOrderHeader group by customerId, saleDate ```
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
**No.** That's the meaning of the word "advance": these are monies that the publisher is willing to give you up-front with the belief that your work will sell enough copies to cover the advance. Keep in mind that the advance is not "free money": it's a portion of the royalties for your book that you receive ahead of time. You won't receive any further royalties for your book until it's sold enough copies that the royalties you would have earned cover the advance. If your book fails to "earn out" the advance (sell enough copies to cover the advance), you can expect to have a hard time getting another contract with that publisher, and possibly with other publishers as well.
**Maybe**. If, for some unforeseen reason, the book is cancelled between the time the contract is signed and the publication date, the publisher may request that any paid-out portion of the advance be repaid. For instance, it might happen if the first half of the book is amazing, but the second half is a complete turkey. Or if the second half never gets submitted at all. Or a million other reasons. But the contract should say what happens, or at least what the publisher is allowed to ask for and when.
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
**No.** That's the meaning of the word "advance": these are monies that the publisher is willing to give you up-front with the belief that your work will sell enough copies to cover the advance. Keep in mind that the advance is not "free money": it's a portion of the royalties for your book that you receive ahead of time. You won't receive any further royalties for your book until it's sold enough copies that the royalties you would have earned cover the advance. If your book fails to "earn out" the advance (sell enough copies to cover the advance), you can expect to have a hard time getting another contract with that publisher, and possibly with other publishers as well.
It ***really, really depends on your contract***. There may be some situations, such as you refuse to edit the book or make requested changes and the publisher cancels the contract. The best idea? Negotiate with your publisher so that the advance (against royalties) is yours. If you're contract isn't clear enough about this, press for it to be made more clear.
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
**No.** That's the meaning of the word "advance": these are monies that the publisher is willing to give you up-front with the belief that your work will sell enough copies to cover the advance. Keep in mind that the advance is not "free money": it's a portion of the royalties for your book that you receive ahead of time. You won't receive any further royalties for your book until it's sold enough copies that the royalties you would have earned cover the advance. If your book fails to "earn out" the advance (sell enough copies to cover the advance), you can expect to have a hard time getting another contract with that publisher, and possibly with other publishers as well.
Generally speaking, if a pubisher gives you an advance against royalties, and then publishes your book, and the book doesn't sell well, you don't have to refund the advance. This is the normal understanding of an "advance" in the world of trade publishing. But read your contract carefully before you sign it.
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
**No.** That's the meaning of the word "advance": these are monies that the publisher is willing to give you up-front with the belief that your work will sell enough copies to cover the advance. Keep in mind that the advance is not "free money": it's a portion of the royalties for your book that you receive ahead of time. You won't receive any further royalties for your book until it's sold enough copies that the royalties you would have earned cover the advance. If your book fails to "earn out" the advance (sell enough copies to cover the advance), you can expect to have a hard time getting another contract with that publisher, and possibly with other publishers as well.
As someone else stated, it depends on your contract. I had a situation where I received an advance for a book proposal, but personal issues and family matters caused me to miss my deadline, and the publisher requested the money back. I hadn't spent any of it and felt it was the right thing to do because I hadn't delivered as promised. (I was aware beforehand that if I wasn't able to finish the book within a certain time range I would have to refund the advance, which is why I still had it!) In general, though, once the publisher has accepted the book and you have delivered, the advance is yours to keep. If the book doesn't sell well enough, then the publisher takes a loss. That's one of the reasons why new writers get smaller advances: they are a bigger risk. By the same token, you don't receive another penny from the publisher until the book makes enough money to pay the advance back to the publisher. Only then do you start collecting royalties.
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
**Maybe**. If, for some unforeseen reason, the book is cancelled between the time the contract is signed and the publication date, the publisher may request that any paid-out portion of the advance be repaid. For instance, it might happen if the first half of the book is amazing, but the second half is a complete turkey. Or if the second half never gets submitted at all. Or a million other reasons. But the contract should say what happens, or at least what the publisher is allowed to ask for and when.
As someone else stated, it depends on your contract. I had a situation where I received an advance for a book proposal, but personal issues and family matters caused me to miss my deadline, and the publisher requested the money back. I hadn't spent any of it and felt it was the right thing to do because I hadn't delivered as promised. (I was aware beforehand that if I wasn't able to finish the book within a certain time range I would have to refund the advance, which is why I still had it!) In general, though, once the publisher has accepted the book and you have delivered, the advance is yours to keep. If the book doesn't sell well enough, then the publisher takes a loss. That's one of the reasons why new writers get smaller advances: they are a bigger risk. By the same token, you don't receive another penny from the publisher until the book makes enough money to pay the advance back to the publisher. Only then do you start collecting royalties.
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
It ***really, really depends on your contract***. There may be some situations, such as you refuse to edit the book or make requested changes and the publisher cancels the contract. The best idea? Negotiate with your publisher so that the advance (against royalties) is yours. If you're contract isn't clear enough about this, press for it to be made more clear.
As someone else stated, it depends on your contract. I had a situation where I received an advance for a book proposal, but personal issues and family matters caused me to miss my deadline, and the publisher requested the money back. I hadn't spent any of it and felt it was the right thing to do because I hadn't delivered as promised. (I was aware beforehand that if I wasn't able to finish the book within a certain time range I would have to refund the advance, which is why I still had it!) In general, though, once the publisher has accepted the book and you have delivered, the advance is yours to keep. If the book doesn't sell well enough, then the publisher takes a loss. That's one of the reasons why new writers get smaller advances: they are a bigger risk. By the same token, you don't receive another penny from the publisher until the book makes enough money to pay the advance back to the publisher. Only then do you start collecting royalties.
1,077
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them? Do they ever just buy your work and you get some money plus royalties? thanks.
2011/01/11
[ "https://writers.stackexchange.com/questions/1077", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/289/" ]
Generally speaking, if a pubisher gives you an advance against royalties, and then publishes your book, and the book doesn't sell well, you don't have to refund the advance. This is the normal understanding of an "advance" in the world of trade publishing. But read your contract carefully before you sign it.
As someone else stated, it depends on your contract. I had a situation where I received an advance for a book proposal, but personal issues and family matters caused me to miss my deadline, and the publisher requested the money back. I hadn't spent any of it and felt it was the right thing to do because I hadn't delivered as promised. (I was aware beforehand that if I wasn't able to finish the book within a certain time range I would have to refund the advance, which is why I still had it!) In general, though, once the publisher has accepted the book and you have delivered, the advance is yours to keep. If the book doesn't sell well enough, then the publisher takes a loss. That's one of the reasons why new writers get smaller advances: they are a bigger risk. By the same token, you don't receive another penny from the publisher until the book makes enough money to pay the advance back to the publisher. Only then do you start collecting royalties.
73,459,978
I'm trying to do a database migration using `GCP Database Migration Service` My source database is of `Postgres` type (hosted on `Heroku`), but the name of the database is not `postgres` but rather something like `d12bdsdjs` ... My question is ... is there a way for me to use the `GCP Database Migration Service` to somehow migrate this database ? There seems to be no field on the form where I can provide this value in `GCP console` ... maybe I can somehow set it if I create my `migration job` using the `GCP SDK` or something ? Please advise
2022/08/23
[ "https://Stackoverflow.com/questions/73459978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2599899/" ]
Use a `for` loop to generate a range of valid indices for each array: ``` for($i = 0; $i -lt $array1.Count; $i++){ Write-Host "Server named '$($array1[$i])' has SID '$($array2[$i])'" } ``` But a better solution would be to create a single array of *objects* that have both pieces of information stored in named properties: ``` $array = @' Name,ID Server1,SID1 Server2,SID2 '@ |ConvertFrom-Csv ``` Now you can use a `foreach` loop without having to worry about the index: ``` foreach($computer in $array){ Write-Host "Server named '$($computer.Name)' has SID '$($computer.ID)'" } ```
You could use a [hash table](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2) or [ordered dictionary](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2#creating-ordered-dictionaries) (if you need the keys to keep their order), might be a good approach for your need. * Hash Table ``` $hash = @{ server1 = "SID1" server2 = "SID2" } ``` * Ordered Dictionary ``` $dict = [ordered]@{ server1 = "SID1" server2 = "SID2" } ``` Then you can [iterate over the key / value pairs](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2#iterating-over-keys-and-values) either using `.GetEnumerator()`: ``` foreach($pair in $hash.GetEnumerator()) { Write-Host ("Server={0} and SID={1}" -f $pair.Key, $pair.Value) } ``` Or by it's `.Keys` property: ``` foreach($key in $hash.PSBase.Keys) { Write-Host ("Server={0} and SID={1}" -f $key, $hash[$key]) } ```
73,459,978
I'm trying to do a database migration using `GCP Database Migration Service` My source database is of `Postgres` type (hosted on `Heroku`), but the name of the database is not `postgres` but rather something like `d12bdsdjs` ... My question is ... is there a way for me to use the `GCP Database Migration Service` to somehow migrate this database ? There seems to be no field on the form where I can provide this value in `GCP console` ... maybe I can somehow set it if I create my `migration job` using the `GCP SDK` or something ? Please advise
2022/08/23
[ "https://Stackoverflow.com/questions/73459978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2599899/" ]
Use a `for` loop to generate a range of valid indices for each array: ``` for($i = 0; $i -lt $array1.Count; $i++){ Write-Host "Server named '$($array1[$i])' has SID '$($array2[$i])'" } ``` But a better solution would be to create a single array of *objects* that have both pieces of information stored in named properties: ``` $array = @' Name,ID Server1,SID1 Server2,SID2 '@ |ConvertFrom-Csv ``` Now you can use a `foreach` loop without having to worry about the index: ``` foreach($computer in $array){ Write-Host "Server named '$($computer.Name)' has SID '$($computer.ID)'" } ```
An alternative approach is to use [`[System.Linq.Enumerable]::Zip`](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.zip?view=net-6.0) which provides convenient API(like [python `zip`](https://docs.python.org/3.3/library/functions.html#zip) function). ie, You could do ``` $array1 = @("server1", "server2") $array2 = @("SID1", "SID2") $doSomethingWithPair = { param($a, $b) Write-Output "I have $a and $b" } [System.Linq.Enumerable]::Zip( $array1, $array2, [Func[Object, Object, Object]]$doSomethingWithPair ) ``` This will print ``` I have server1 and SID1 I have server2 and SID2 ```
73,459,978
I'm trying to do a database migration using `GCP Database Migration Service` My source database is of `Postgres` type (hosted on `Heroku`), but the name of the database is not `postgres` but rather something like `d12bdsdjs` ... My question is ... is there a way for me to use the `GCP Database Migration Service` to somehow migrate this database ? There seems to be no field on the form where I can provide this value in `GCP console` ... maybe I can somehow set it if I create my `migration job` using the `GCP SDK` or something ? Please advise
2022/08/23
[ "https://Stackoverflow.com/questions/73459978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2599899/" ]
Use a `for` loop to generate a range of valid indices for each array: ``` for($i = 0; $i -lt $array1.Count; $i++){ Write-Host "Server named '$($array1[$i])' has SID '$($array2[$i])'" } ``` But a better solution would be to create a single array of *objects* that have both pieces of information stored in named properties: ``` $array = @' Name,ID Server1,SID1 Server2,SID2 '@ |ConvertFrom-Csv ``` Now you can use a `foreach` loop without having to worry about the index: ``` foreach($computer in $array){ Write-Host "Server named '$($computer.Name)' has SID '$($computer.ID)'" } ```
``` $array1 = @("server1", "server2") $array2 = @("SID1", "SID2") for($i=0; $i -lt $array1.Count; $i++){ Write-Host $array1[$i] ":"$array2[$i] } ```
73,459,978
I'm trying to do a database migration using `GCP Database Migration Service` My source database is of `Postgres` type (hosted on `Heroku`), but the name of the database is not `postgres` but rather something like `d12bdsdjs` ... My question is ... is there a way for me to use the `GCP Database Migration Service` to somehow migrate this database ? There seems to be no field on the form where I can provide this value in `GCP console` ... maybe I can somehow set it if I create my `migration job` using the `GCP SDK` or something ? Please advise
2022/08/23
[ "https://Stackoverflow.com/questions/73459978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2599899/" ]
You could use a [hash table](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2) or [ordered dictionary](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2#creating-ordered-dictionaries) (if you need the keys to keep their order), might be a good approach for your need. * Hash Table ``` $hash = @{ server1 = "SID1" server2 = "SID2" } ``` * Ordered Dictionary ``` $dict = [ordered]@{ server1 = "SID1" server2 = "SID2" } ``` Then you can [iterate over the key / value pairs](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables?view=powershell-7.2#iterating-over-keys-and-values) either using `.GetEnumerator()`: ``` foreach($pair in $hash.GetEnumerator()) { Write-Host ("Server={0} and SID={1}" -f $pair.Key, $pair.Value) } ``` Or by it's `.Keys` property: ``` foreach($key in $hash.PSBase.Keys) { Write-Host ("Server={0} and SID={1}" -f $key, $hash[$key]) } ```
``` $array1 = @("server1", "server2") $array2 = @("SID1", "SID2") for($i=0; $i -lt $array1.Count; $i++){ Write-Host $array1[$i] ":"$array2[$i] } ```
73,459,978
I'm trying to do a database migration using `GCP Database Migration Service` My source database is of `Postgres` type (hosted on `Heroku`), but the name of the database is not `postgres` but rather something like `d12bdsdjs` ... My question is ... is there a way for me to use the `GCP Database Migration Service` to somehow migrate this database ? There seems to be no field on the form where I can provide this value in `GCP console` ... maybe I can somehow set it if I create my `migration job` using the `GCP SDK` or something ? Please advise
2022/08/23
[ "https://Stackoverflow.com/questions/73459978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2599899/" ]
An alternative approach is to use [`[System.Linq.Enumerable]::Zip`](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.zip?view=net-6.0) which provides convenient API(like [python `zip`](https://docs.python.org/3.3/library/functions.html#zip) function). ie, You could do ``` $array1 = @("server1", "server2") $array2 = @("SID1", "SID2") $doSomethingWithPair = { param($a, $b) Write-Output "I have $a and $b" } [System.Linq.Enumerable]::Zip( $array1, $array2, [Func[Object, Object, Object]]$doSomethingWithPair ) ``` This will print ``` I have server1 and SID1 I have server2 and SID2 ```
``` $array1 = @("server1", "server2") $array2 = @("SID1", "SID2") for($i=0; $i -lt $array1.Count; $i++){ Write-Host $array1[$i] ":"$array2[$i] } ```
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
I think the examples given in the question and in the answers are grammatically non-trivial and thus **prone to translation mistakes**, even by a human learning a language (two substantives, two verbs, etc). That Google makes mistakes might not be so surprising, and we could even argue that the tests were too stringent. Perhaps a much more revealing test is to try Google translate with **unequivocally simple examples**. So, to see if Google understands us, I will try "I do not understand". From the grammatical point of view, it's trivial: one person/pronoun, one verb. No complex lexical twists possible. So, what do we get? Brace yourselves: [![enter image description here](https://i.stack.imgur.com/vq8nw.png)](https://i.stack.imgur.com/vq8nw.png) So far so good! But to be honest, many people just use "don't" rather than "do not". So... [![enter image description here](https://i.stack.imgur.com/M6iTq.png)](https://i.stack.imgur.com/M6iTq.png) What??? Did Google just changed the person? How on earth could it mistake an "I" by a plural "you"? Just for the sake of it, I also try it in Spanish: [![enter image description here](https://i.stack.imgur.com/40438.png)](https://i.stack.imgur.com/40438.png) Same basic mistake. What about "I understand"? [![enter image description here](https://i.stack.imgur.com/pmn3E.png)](https://i.stack.imgur.com/pmn3E.png) Better. What about "I do understand"? [![enter image description here](https://i.stack.imgur.com/SchsW.png)](https://i.stack.imgur.com/SchsW.png) Totally odd. If we reverse the direction of translation, we get: [![enter image description here](https://i.stack.imgur.com/tzjFR.png)](https://i.stack.imgur.com/tzjFR.png) From where we get the amazing conclusion that: > > I do understand = I do not understand > > > I think that we can now safely conclude that **Google translate is terrible** even for the most simple tasks.
The point of Google Translate (and this is not just for Latin) is that it only serves a purpose if you are able to judge the quality of its output, and understand that it's not a faithful account of the source text in any case. This means, of course, that it must only be used to translate a text in a language you *don't* know into a language you *do*. But if you're content with just getting the gist of what is being said, then it's great for approximately understanding what a web page is talking about in general lines. If it's the choice between understanding part of it and understanding nothing at all, then there may be value in using it. Finally, whenever you *do* use it, you must always be wary of what you get presented with. Could this have possibly been misconstrued? Does the surrounding text generally agree with the sense of this sentence? Some rudimentary text criticism may give you some confidence of whether a given translation is sound or not.
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
To answer the question ("What is Latin Google Translate good for?") as stated: ***Absolutely nothing***. At least reliably.
I think the examples given in the question and in the answers are grammatically non-trivial and thus **prone to translation mistakes**, even by a human learning a language (two substantives, two verbs, etc). That Google makes mistakes might not be so surprising, and we could even argue that the tests were too stringent. Perhaps a much more revealing test is to try Google translate with **unequivocally simple examples**. So, to see if Google understands us, I will try "I do not understand". From the grammatical point of view, it's trivial: one person/pronoun, one verb. No complex lexical twists possible. So, what do we get? Brace yourselves: [![enter image description here](https://i.stack.imgur.com/vq8nw.png)](https://i.stack.imgur.com/vq8nw.png) So far so good! But to be honest, many people just use "don't" rather than "do not". So... [![enter image description here](https://i.stack.imgur.com/M6iTq.png)](https://i.stack.imgur.com/M6iTq.png) What??? Did Google just changed the person? How on earth could it mistake an "I" by a plural "you"? Just for the sake of it, I also try it in Spanish: [![enter image description here](https://i.stack.imgur.com/40438.png)](https://i.stack.imgur.com/40438.png) Same basic mistake. What about "I understand"? [![enter image description here](https://i.stack.imgur.com/pmn3E.png)](https://i.stack.imgur.com/pmn3E.png) Better. What about "I do understand"? [![enter image description here](https://i.stack.imgur.com/SchsW.png)](https://i.stack.imgur.com/SchsW.png) Totally odd. If we reverse the direction of translation, we get: [![enter image description here](https://i.stack.imgur.com/tzjFR.png)](https://i.stack.imgur.com/tzjFR.png) From where we get the amazing conclusion that: > > I do understand = I do not understand > > > I think that we can now safely conclude that **Google translate is terrible** even for the most simple tasks.
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
A classmate of mine who got his Ph.D. in natural-language processing and now works at Google told me the following. It might be out of date and I might be remembering it wrong. But I just did a little, er, googling, and this seems to be passably well corroborated by other sources. How it works ------------ Google Translate is completely statistical. It has no model of grammar, syntax, or meaning. It works by correlating sequences of up to five consecutive words found in texts from both languages. Here's the conceit. Ignore all the complexity, structure, and meaning of language and pretend that people speak just by randomly choosing one word after another. The only question now is how to calculate the probabilities. A simple way is to say that the probability of each word is determined by the previous word spoken. For example, if the last word you said was "two", there is a certain probability that your next word will be "or". If you just said "or", there is a certain probability that your next word will be "butane". You could calculate these word-to-next-word probabilities from their frequencies in real text. If you [generate new text](https://www.jwz.org/dadadodo/dadadodo.cgi) according to these probabilities, you'll get random but just slightly coherent gibberish: TWO OR BUTANE GAS AND OF THE SAME. That's called a [Markov model](https://en.wikipedia.org/wiki/Markov_model). If you use a window of more words, say five, the resulting gibberish will look more likely to have been written by a schizophrenic than by an aphasic. A variation called a [hidden Markov model](https://en.wikipedia.org/wiki/Hidden_Markov_model) introduces "states", where each state has its own set of probabilities for "emitting" words as well as a set of "transition" probabilities for what will be the next state. This can simulate a little more of the influence of context on each word choice. Google Translate's algorithm is proprietary, and I think it's a little more sophisticated than hidden Markov models, but the principle is the same. They let computers run on lots of text in each language, assigning [probabilities to word sequences](https://en.wikipedia.org/wiki/Language_model) according to the principle "Assuming this text was generated by a random gibberish-generator, what probabilities [maximize the chance](https://en.wikipedia.org/wiki/Maximum_likelihood_estimation) that this exact text would have been generated?" Manually translated texts provide data to line up word sequences in one language with word sequences in another. Translation, then, is finding the highest-probability sequence from one language's gibberish-generator that corresponds to whatever makes the other language's gibberish-generator produce the input text. What it's reliable for ====================== Consequently, you won't learn much about what Google Translate is reliable for by trying out different grammatical structures. If you're lucky, all you'll get from that is an [ELIZA effect](https://en.wikipedia.org/wiki/ELIZA_effect). What Google Translate is most reliable for is translating documents produced by the United Nations between the languages in use there. This is because UN documents have provided a disproportionately large share of the manually translated texts from which Google Translate draws its five-word sequences. Witness what happens when I type this in: > > À l'exception de ce qui peut être convenu dans les accords particuliers de tutelle conclus conformément aux Articles 77, 79 et 81 et plaçant chaque territoire sous le régime de tutelle, et jusqu'à ce que ces accords aient été conclus, aucune disposition du présent Chapitre ne sera interprétée comme modifiant directement ou indirectement en aucune manière les droits quelconques d'aucun État ou d'aucun peuple ou les dispositions d'actes internationaux en vigueur auxquels des Membres de l'Organisation peuvent être parties. > > > It gives me: > > Except as may be agreed upon in the special guardianship agreements concluded in accordance with Articles 77, 79 and 81 and placing each territory under the trusteeship system, and until such agreements have been concluded, This Chapter shall not be construed as directly or indirectly modifying in any way the rights of any State or any people or the provisions of international instruments in force to which Members of the Organization may be parties. > > > Perfect! ([Almost](http://www.un.org/en/sections/un-charter/chapter-xii/index.html).) This is why its Latin translations tend to be so poor: it has a very thin corpus of human-made translations of Latin on which to base its probability estimates—and, of course, it's using an approach that's based on probabilities of word sequences, disregarding grammar and meaning. So, until the United Nations starts doing its business in Latin, Google Translate is not going to do a very good job. And even then, don't expect much unless you're translating text pasted from UN documents. The five-word window ==================== Here's an illustration of the five-word window. I enter: > > Pants, as you expected, were worn. > > > Pants were worn. > > > Pants, as you expected, are worn. > > > The Latin translations (with my manual translations back to English): > > [Anhelat](https://en.wiktionary.org/wiki/anhelo#Latin) quemadmodum speravimus confecta. *(He is panting just as we hoped accomplished.)* > > > [Braccas](https://en.wiktionary.org/wiki/braca#Latin) sunt attriti. *(The trousers have been worn away [like "attrition"].)* > > > Anhelat, ut spe [teris](https://en.wiktionary.org/wiki/tero#Latin). *(He is panting, just as, by hope, you are wearing [something] out.)* > > > Notice that the first and third sentences border on ungrammatical nonsense. The second sentence makes sense but it's ungrammatical; it should be *Braccae sunt attritae.* There aren't any five-word sequences in Google Translate's English database that line up well with "pants as you expected were/are," so it's flailing. Notice that in the third sentence, by the time it got to "worn", it had forgotten which sense of "pants" it chose at the start of the sentence. Or rather, it didn't forget, because it never tracked it. It only tracked five-word sequences. So, whether the sentence makes sense sort of affects the translation, but it's worse than that. What matters is exact, word-for-word matching with texts in the database. Entering Latin into Google Translate (with words changed from the first sentence shown in bold): > > Abraham vero aliam duxit uxorem nomine Cetthuram. > > > **Quintilianus** vero aliam duxit uxorem nomine Cetthuram. > > > Abraham vero aliam duxit uxorem nomine **Iuliam**. > > > Abraham vero **canem** duxit uxorem nomine **Fido**. > > > English output: > > And Abraham took another wife, and her name was Keturah. > > > Quintilian, now the wife of another wife, and her name was Keturah. > > > And Abraham took another wife, and the name of his wife, a daughter named Julia. > > > And Abraham took a wife, and brought him to a dog by the name of Fido. > > > The Vulgate and the [ASV translation](https://www.biblegateway.com/passage/?search=Genesis%2025&version=ASV) (or similar) would appear to be among Google Translate's source texts. Notice what happens when the input is off by as little as one word. --- The above explains just enough so that a layperson can understand what Google Translate is good at, what it's bad at, and why—and so they won't be misled by the results of experimenting with different grammatical structures. If you're interested in more rigorous and thorough information about the full complexities of this approach, google for "[statistical machine translation](https://www.google.com/search?q=statistical+machine+translation)". Some further info is [here](https://en.wikipedia.org/wiki/Google_Translate#Method_of_translation), including Google's rollout, now in progress, of an entirely new translation algorithm (which hasn't reached Latin yet).
I think the examples given in the question and in the answers are grammatically non-trivial and thus **prone to translation mistakes**, even by a human learning a language (two substantives, two verbs, etc). That Google makes mistakes might not be so surprising, and we could even argue that the tests were too stringent. Perhaps a much more revealing test is to try Google translate with **unequivocally simple examples**. So, to see if Google understands us, I will try "I do not understand". From the grammatical point of view, it's trivial: one person/pronoun, one verb. No complex lexical twists possible. So, what do we get? Brace yourselves: [![enter image description here](https://i.stack.imgur.com/vq8nw.png)](https://i.stack.imgur.com/vq8nw.png) So far so good! But to be honest, many people just use "don't" rather than "do not". So... [![enter image description here](https://i.stack.imgur.com/M6iTq.png)](https://i.stack.imgur.com/M6iTq.png) What??? Did Google just changed the person? How on earth could it mistake an "I" by a plural "you"? Just for the sake of it, I also try it in Spanish: [![enter image description here](https://i.stack.imgur.com/40438.png)](https://i.stack.imgur.com/40438.png) Same basic mistake. What about "I understand"? [![enter image description here](https://i.stack.imgur.com/pmn3E.png)](https://i.stack.imgur.com/pmn3E.png) Better. What about "I do understand"? [![enter image description here](https://i.stack.imgur.com/SchsW.png)](https://i.stack.imgur.com/SchsW.png) Totally odd. If we reverse the direction of translation, we get: [![enter image description here](https://i.stack.imgur.com/tzjFR.png)](https://i.stack.imgur.com/tzjFR.png) From where we get the amazing conclusion that: > > I do understand = I do not understand > > > I think that we can now safely conclude that **Google translate is terrible** even for the most simple tasks.
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
To answer the question ("What is Latin Google Translate good for?") as stated: ***Absolutely nothing***. At least reliably.
The point of Google Translate (and this is not just for Latin) is that it only serves a purpose if you are able to judge the quality of its output, and understand that it's not a faithful account of the source text in any case. This means, of course, that it must only be used to translate a text in a language you *don't* know into a language you *do*. But if you're content with just getting the gist of what is being said, then it's great for approximately understanding what a web page is talking about in general lines. If it's the choice between understanding part of it and understanding nothing at all, then there may be value in using it. Finally, whenever you *do* use it, you must always be wary of what you get presented with. Could this have possibly been misconstrued? Does the surrounding text generally agree with the sense of this sentence? Some rudimentary text criticism may give you some confidence of whether a given translation is sound or not.
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
To answer the question ("What is Latin Google Translate good for?") as stated: ***Absolutely nothing***. At least reliably.
I found a very specific use for it this summer. For a couple weeks I was at one of the living-Latin summer programs run by [SALVI](http://www.latin.org), and the rule there—as at other such programs I've attended—is that you're not allowed to speak any language but Latin except in emergencies. Since my husband, who speaks no Latin, gets lonely when it's just him and the dog and was annoyed that we'd be out of touch for so long, I wanted to be able to communicate with him a little bit, and Google Translate turned out to be just the thing. We sent each other very short, simple sentences ("Quōmodo tē habēs? Tē dēsīderō," etc.); the Latin he sent wasn't always correct but I always understood what he was trying to say, and I have to assume the same was true of the English that resulted from my Latin. It made him feel much better about my absence. So the answer is: Google Translate is good for preserving marital bliss!
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
While Google Translate may be useless to an advanced Latin speaker, a beginner such as me finds it helpful for gaining **quick insights.** I use it in combination with **little tricks,** such as splitting the sentence into separate clauses and/or adding punctuation and converting the syntax to the [Subject–Verb–Object word order](https://en.wikipedia.org/wiki/Subject%E2%80%93verb%E2%80%93object) which makes Latin more “palpable” to Anglo-Saxon Google Translate. Regardless of initial accuracy (or lack of it), this workflow is ultimately more efficient *for me* than the tedious alternative, which is using dictionaries and trying to match the meaning of each word manually from a multitude of confusing possibilities. Which are confusing because ancient notions don’t map onto modern notions on a 1:1 basis. The average Latin word appears to have a dozen of equally plausible meanings that appear unrelated to each other to the modern European mind. Or at least that’s how I see Latin as a beginner. Example (borrowed from @BenKovitz above): > > 1. Quintilianus vero aliam duxit uxorem nomine Cetthuram. *(raw Latin)* > 2. Vero; Quintilianus duxit aliam uxorem; nomine Cetthuram. *(manually pre-processed)* > 3. Vero, Quintilianus duxit aliam uxorem, nomine Cetthuram. *(manually pre-processed)* > > > Result: > > 1. Quintilian, now the wife of another wife, and her name was Keturah. *(nonsense)* > 2. however; Quintilian [married another woman] for his wife; her name was Keturah. ***(wow!)*** > 3. However, Quintilian [married another] wife, whose name was Keturah. ***(wow!)*** > > > Square brackets indicate user-selected alternative.
I found a very specific use for it this summer. For a couple weeks I was at one of the living-Latin summer programs run by [SALVI](http://www.latin.org), and the rule there—as at other such programs I've attended—is that you're not allowed to speak any language but Latin except in emergencies. Since my husband, who speaks no Latin, gets lonely when it's just him and the dog and was annoyed that we'd be out of touch for so long, I wanted to be able to communicate with him a little bit, and Google Translate turned out to be just the thing. We sent each other very short, simple sentences ("Quōmodo tē habēs? Tē dēsīderō," etc.); the Latin he sent wasn't always correct but I always understood what he was trying to say, and I have to assume the same was true of the English that resulted from my Latin. It made him feel much better about my absence. So the answer is: Google Translate is good for preserving marital bliss!
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
A classmate of mine who got his Ph.D. in natural-language processing and now works at Google told me the following. It might be out of date and I might be remembering it wrong. But I just did a little, er, googling, and this seems to be passably well corroborated by other sources. How it works ------------ Google Translate is completely statistical. It has no model of grammar, syntax, or meaning. It works by correlating sequences of up to five consecutive words found in texts from both languages. Here's the conceit. Ignore all the complexity, structure, and meaning of language and pretend that people speak just by randomly choosing one word after another. The only question now is how to calculate the probabilities. A simple way is to say that the probability of each word is determined by the previous word spoken. For example, if the last word you said was "two", there is a certain probability that your next word will be "or". If you just said "or", there is a certain probability that your next word will be "butane". You could calculate these word-to-next-word probabilities from their frequencies in real text. If you [generate new text](https://www.jwz.org/dadadodo/dadadodo.cgi) according to these probabilities, you'll get random but just slightly coherent gibberish: TWO OR BUTANE GAS AND OF THE SAME. That's called a [Markov model](https://en.wikipedia.org/wiki/Markov_model). If you use a window of more words, say five, the resulting gibberish will look more likely to have been written by a schizophrenic than by an aphasic. A variation called a [hidden Markov model](https://en.wikipedia.org/wiki/Hidden_Markov_model) introduces "states", where each state has its own set of probabilities for "emitting" words as well as a set of "transition" probabilities for what will be the next state. This can simulate a little more of the influence of context on each word choice. Google Translate's algorithm is proprietary, and I think it's a little more sophisticated than hidden Markov models, but the principle is the same. They let computers run on lots of text in each language, assigning [probabilities to word sequences](https://en.wikipedia.org/wiki/Language_model) according to the principle "Assuming this text was generated by a random gibberish-generator, what probabilities [maximize the chance](https://en.wikipedia.org/wiki/Maximum_likelihood_estimation) that this exact text would have been generated?" Manually translated texts provide data to line up word sequences in one language with word sequences in another. Translation, then, is finding the highest-probability sequence from one language's gibberish-generator that corresponds to whatever makes the other language's gibberish-generator produce the input text. What it's reliable for ====================== Consequently, you won't learn much about what Google Translate is reliable for by trying out different grammatical structures. If you're lucky, all you'll get from that is an [ELIZA effect](https://en.wikipedia.org/wiki/ELIZA_effect). What Google Translate is most reliable for is translating documents produced by the United Nations between the languages in use there. This is because UN documents have provided a disproportionately large share of the manually translated texts from which Google Translate draws its five-word sequences. Witness what happens when I type this in: > > À l'exception de ce qui peut être convenu dans les accords particuliers de tutelle conclus conformément aux Articles 77, 79 et 81 et plaçant chaque territoire sous le régime de tutelle, et jusqu'à ce que ces accords aient été conclus, aucune disposition du présent Chapitre ne sera interprétée comme modifiant directement ou indirectement en aucune manière les droits quelconques d'aucun État ou d'aucun peuple ou les dispositions d'actes internationaux en vigueur auxquels des Membres de l'Organisation peuvent être parties. > > > It gives me: > > Except as may be agreed upon in the special guardianship agreements concluded in accordance with Articles 77, 79 and 81 and placing each territory under the trusteeship system, and until such agreements have been concluded, This Chapter shall not be construed as directly or indirectly modifying in any way the rights of any State or any people or the provisions of international instruments in force to which Members of the Organization may be parties. > > > Perfect! ([Almost](http://www.un.org/en/sections/un-charter/chapter-xii/index.html).) This is why its Latin translations tend to be so poor: it has a very thin corpus of human-made translations of Latin on which to base its probability estimates—and, of course, it's using an approach that's based on probabilities of word sequences, disregarding grammar and meaning. So, until the United Nations starts doing its business in Latin, Google Translate is not going to do a very good job. And even then, don't expect much unless you're translating text pasted from UN documents. The five-word window ==================== Here's an illustration of the five-word window. I enter: > > Pants, as you expected, were worn. > > > Pants were worn. > > > Pants, as you expected, are worn. > > > The Latin translations (with my manual translations back to English): > > [Anhelat](https://en.wiktionary.org/wiki/anhelo#Latin) quemadmodum speravimus confecta. *(He is panting just as we hoped accomplished.)* > > > [Braccas](https://en.wiktionary.org/wiki/braca#Latin) sunt attriti. *(The trousers have been worn away [like "attrition"].)* > > > Anhelat, ut spe [teris](https://en.wiktionary.org/wiki/tero#Latin). *(He is panting, just as, by hope, you are wearing [something] out.)* > > > Notice that the first and third sentences border on ungrammatical nonsense. The second sentence makes sense but it's ungrammatical; it should be *Braccae sunt attritae.* There aren't any five-word sequences in Google Translate's English database that line up well with "pants as you expected were/are," so it's flailing. Notice that in the third sentence, by the time it got to "worn", it had forgotten which sense of "pants" it chose at the start of the sentence. Or rather, it didn't forget, because it never tracked it. It only tracked five-word sequences. So, whether the sentence makes sense sort of affects the translation, but it's worse than that. What matters is exact, word-for-word matching with texts in the database. Entering Latin into Google Translate (with words changed from the first sentence shown in bold): > > Abraham vero aliam duxit uxorem nomine Cetthuram. > > > **Quintilianus** vero aliam duxit uxorem nomine Cetthuram. > > > Abraham vero aliam duxit uxorem nomine **Iuliam**. > > > Abraham vero **canem** duxit uxorem nomine **Fido**. > > > English output: > > And Abraham took another wife, and her name was Keturah. > > > Quintilian, now the wife of another wife, and her name was Keturah. > > > And Abraham took another wife, and the name of his wife, a daughter named Julia. > > > And Abraham took a wife, and brought him to a dog by the name of Fido. > > > The Vulgate and the [ASV translation](https://www.biblegateway.com/passage/?search=Genesis%2025&version=ASV) (or similar) would appear to be among Google Translate's source texts. Notice what happens when the input is off by as little as one word. --- The above explains just enough so that a layperson can understand what Google Translate is good at, what it's bad at, and why—and so they won't be misled by the results of experimenting with different grammatical structures. If you're interested in more rigorous and thorough information about the full complexities of this approach, google for "[statistical machine translation](https://www.google.com/search?q=statistical+machine+translation)". Some further info is [here](https://en.wikipedia.org/wiki/Google_Translate#Method_of_translation), including Google's rollout, now in progress, of an entirely new translation algorithm (which hasn't reached Latin yet).
I found a very specific use for it this summer. For a couple weeks I was at one of the living-Latin summer programs run by [SALVI](http://www.latin.org), and the rule there—as at other such programs I've attended—is that you're not allowed to speak any language but Latin except in emergencies. Since my husband, who speaks no Latin, gets lonely when it's just him and the dog and was annoyed that we'd be out of touch for so long, I wanted to be able to communicate with him a little bit, and Google Translate turned out to be just the thing. We sent each other very short, simple sentences ("Quōmodo tē habēs? Tē dēsīderō," etc.); the Latin he sent wasn't always correct but I always understood what he was trying to say, and I have to assume the same was true of the English that resulted from my Latin. It made him feel much better about my absence. So the answer is: Google Translate is good for preserving marital bliss!
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
A classmate of mine who got his Ph.D. in natural-language processing and now works at Google told me the following. It might be out of date and I might be remembering it wrong. But I just did a little, er, googling, and this seems to be passably well corroborated by other sources. How it works ------------ Google Translate is completely statistical. It has no model of grammar, syntax, or meaning. It works by correlating sequences of up to five consecutive words found in texts from both languages. Here's the conceit. Ignore all the complexity, structure, and meaning of language and pretend that people speak just by randomly choosing one word after another. The only question now is how to calculate the probabilities. A simple way is to say that the probability of each word is determined by the previous word spoken. For example, if the last word you said was "two", there is a certain probability that your next word will be "or". If you just said "or", there is a certain probability that your next word will be "butane". You could calculate these word-to-next-word probabilities from their frequencies in real text. If you [generate new text](https://www.jwz.org/dadadodo/dadadodo.cgi) according to these probabilities, you'll get random but just slightly coherent gibberish: TWO OR BUTANE GAS AND OF THE SAME. That's called a [Markov model](https://en.wikipedia.org/wiki/Markov_model). If you use a window of more words, say five, the resulting gibberish will look more likely to have been written by a schizophrenic than by an aphasic. A variation called a [hidden Markov model](https://en.wikipedia.org/wiki/Hidden_Markov_model) introduces "states", where each state has its own set of probabilities for "emitting" words as well as a set of "transition" probabilities for what will be the next state. This can simulate a little more of the influence of context on each word choice. Google Translate's algorithm is proprietary, and I think it's a little more sophisticated than hidden Markov models, but the principle is the same. They let computers run on lots of text in each language, assigning [probabilities to word sequences](https://en.wikipedia.org/wiki/Language_model) according to the principle "Assuming this text was generated by a random gibberish-generator, what probabilities [maximize the chance](https://en.wikipedia.org/wiki/Maximum_likelihood_estimation) that this exact text would have been generated?" Manually translated texts provide data to line up word sequences in one language with word sequences in another. Translation, then, is finding the highest-probability sequence from one language's gibberish-generator that corresponds to whatever makes the other language's gibberish-generator produce the input text. What it's reliable for ====================== Consequently, you won't learn much about what Google Translate is reliable for by trying out different grammatical structures. If you're lucky, all you'll get from that is an [ELIZA effect](https://en.wikipedia.org/wiki/ELIZA_effect). What Google Translate is most reliable for is translating documents produced by the United Nations between the languages in use there. This is because UN documents have provided a disproportionately large share of the manually translated texts from which Google Translate draws its five-word sequences. Witness what happens when I type this in: > > À l'exception de ce qui peut être convenu dans les accords particuliers de tutelle conclus conformément aux Articles 77, 79 et 81 et plaçant chaque territoire sous le régime de tutelle, et jusqu'à ce que ces accords aient été conclus, aucune disposition du présent Chapitre ne sera interprétée comme modifiant directement ou indirectement en aucune manière les droits quelconques d'aucun État ou d'aucun peuple ou les dispositions d'actes internationaux en vigueur auxquels des Membres de l'Organisation peuvent être parties. > > > It gives me: > > Except as may be agreed upon in the special guardianship agreements concluded in accordance with Articles 77, 79 and 81 and placing each territory under the trusteeship system, and until such agreements have been concluded, This Chapter shall not be construed as directly or indirectly modifying in any way the rights of any State or any people or the provisions of international instruments in force to which Members of the Organization may be parties. > > > Perfect! ([Almost](http://www.un.org/en/sections/un-charter/chapter-xii/index.html).) This is why its Latin translations tend to be so poor: it has a very thin corpus of human-made translations of Latin on which to base its probability estimates—and, of course, it's using an approach that's based on probabilities of word sequences, disregarding grammar and meaning. So, until the United Nations starts doing its business in Latin, Google Translate is not going to do a very good job. And even then, don't expect much unless you're translating text pasted from UN documents. The five-word window ==================== Here's an illustration of the five-word window. I enter: > > Pants, as you expected, were worn. > > > Pants were worn. > > > Pants, as you expected, are worn. > > > The Latin translations (with my manual translations back to English): > > [Anhelat](https://en.wiktionary.org/wiki/anhelo#Latin) quemadmodum speravimus confecta. *(He is panting just as we hoped accomplished.)* > > > [Braccas](https://en.wiktionary.org/wiki/braca#Latin) sunt attriti. *(The trousers have been worn away [like "attrition"].)* > > > Anhelat, ut spe [teris](https://en.wiktionary.org/wiki/tero#Latin). *(He is panting, just as, by hope, you are wearing [something] out.)* > > > Notice that the first and third sentences border on ungrammatical nonsense. The second sentence makes sense but it's ungrammatical; it should be *Braccae sunt attritae.* There aren't any five-word sequences in Google Translate's English database that line up well with "pants as you expected were/are," so it's flailing. Notice that in the third sentence, by the time it got to "worn", it had forgotten which sense of "pants" it chose at the start of the sentence. Or rather, it didn't forget, because it never tracked it. It only tracked five-word sequences. So, whether the sentence makes sense sort of affects the translation, but it's worse than that. What matters is exact, word-for-word matching with texts in the database. Entering Latin into Google Translate (with words changed from the first sentence shown in bold): > > Abraham vero aliam duxit uxorem nomine Cetthuram. > > > **Quintilianus** vero aliam duxit uxorem nomine Cetthuram. > > > Abraham vero aliam duxit uxorem nomine **Iuliam**. > > > Abraham vero **canem** duxit uxorem nomine **Fido**. > > > English output: > > And Abraham took another wife, and her name was Keturah. > > > Quintilian, now the wife of another wife, and her name was Keturah. > > > And Abraham took another wife, and the name of his wife, a daughter named Julia. > > > And Abraham took a wife, and brought him to a dog by the name of Fido. > > > The Vulgate and the [ASV translation](https://www.biblegateway.com/passage/?search=Genesis%2025&version=ASV) (or similar) would appear to be among Google Translate's source texts. Notice what happens when the input is off by as little as one word. --- The above explains just enough so that a layperson can understand what Google Translate is good at, what it's bad at, and why—and so they won't be misled by the results of experimenting with different grammatical structures. If you're interested in more rigorous and thorough information about the full complexities of this approach, google for "[statistical machine translation](https://www.google.com/search?q=statistical+machine+translation)". Some further info is [here](https://en.wikipedia.org/wiki/Google_Translate#Method_of_translation), including Google's rollout, now in progress, of an entirely new translation algorithm (which hasn't reached Latin yet).
While Google Translate may be useless to an advanced Latin speaker, a beginner such as me finds it helpful for gaining **quick insights.** I use it in combination with **little tricks,** such as splitting the sentence into separate clauses and/or adding punctuation and converting the syntax to the [Subject–Verb–Object word order](https://en.wikipedia.org/wiki/Subject%E2%80%93verb%E2%80%93object) which makes Latin more “palpable” to Anglo-Saxon Google Translate. Regardless of initial accuracy (or lack of it), this workflow is ultimately more efficient *for me* than the tedious alternative, which is using dictionaries and trying to match the meaning of each word manually from a multitude of confusing possibilities. Which are confusing because ancient notions don’t map onto modern notions on a 1:1 basis. The average Latin word appears to have a dozen of equally plausible meanings that appear unrelated to each other to the modern European mind. Or at least that’s how I see Latin as a beginner. Example (borrowed from @BenKovitz above): > > 1. Quintilianus vero aliam duxit uxorem nomine Cetthuram. *(raw Latin)* > 2. Vero; Quintilianus duxit aliam uxorem; nomine Cetthuram. *(manually pre-processed)* > 3. Vero, Quintilianus duxit aliam uxorem, nomine Cetthuram. *(manually pre-processed)* > > > Result: > > 1. Quintilian, now the wife of another wife, and her name was Keturah. *(nonsense)* > 2. however; Quintilian [married another woman] for his wife; her name was Keturah. ***(wow!)*** > 3. However, Quintilian [married another] wife, whose name was Keturah. ***(wow!)*** > > > Square brackets indicate user-selected alternative.
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
A classmate of mine who got his Ph.D. in natural-language processing and now works at Google told me the following. It might be out of date and I might be remembering it wrong. But I just did a little, er, googling, and this seems to be passably well corroborated by other sources. How it works ------------ Google Translate is completely statistical. It has no model of grammar, syntax, or meaning. It works by correlating sequences of up to five consecutive words found in texts from both languages. Here's the conceit. Ignore all the complexity, structure, and meaning of language and pretend that people speak just by randomly choosing one word after another. The only question now is how to calculate the probabilities. A simple way is to say that the probability of each word is determined by the previous word spoken. For example, if the last word you said was "two", there is a certain probability that your next word will be "or". If you just said "or", there is a certain probability that your next word will be "butane". You could calculate these word-to-next-word probabilities from their frequencies in real text. If you [generate new text](https://www.jwz.org/dadadodo/dadadodo.cgi) according to these probabilities, you'll get random but just slightly coherent gibberish: TWO OR BUTANE GAS AND OF THE SAME. That's called a [Markov model](https://en.wikipedia.org/wiki/Markov_model). If you use a window of more words, say five, the resulting gibberish will look more likely to have been written by a schizophrenic than by an aphasic. A variation called a [hidden Markov model](https://en.wikipedia.org/wiki/Hidden_Markov_model) introduces "states", where each state has its own set of probabilities for "emitting" words as well as a set of "transition" probabilities for what will be the next state. This can simulate a little more of the influence of context on each word choice. Google Translate's algorithm is proprietary, and I think it's a little more sophisticated than hidden Markov models, but the principle is the same. They let computers run on lots of text in each language, assigning [probabilities to word sequences](https://en.wikipedia.org/wiki/Language_model) according to the principle "Assuming this text was generated by a random gibberish-generator, what probabilities [maximize the chance](https://en.wikipedia.org/wiki/Maximum_likelihood_estimation) that this exact text would have been generated?" Manually translated texts provide data to line up word sequences in one language with word sequences in another. Translation, then, is finding the highest-probability sequence from one language's gibberish-generator that corresponds to whatever makes the other language's gibberish-generator produce the input text. What it's reliable for ====================== Consequently, you won't learn much about what Google Translate is reliable for by trying out different grammatical structures. If you're lucky, all you'll get from that is an [ELIZA effect](https://en.wikipedia.org/wiki/ELIZA_effect). What Google Translate is most reliable for is translating documents produced by the United Nations between the languages in use there. This is because UN documents have provided a disproportionately large share of the manually translated texts from which Google Translate draws its five-word sequences. Witness what happens when I type this in: > > À l'exception de ce qui peut être convenu dans les accords particuliers de tutelle conclus conformément aux Articles 77, 79 et 81 et plaçant chaque territoire sous le régime de tutelle, et jusqu'à ce que ces accords aient été conclus, aucune disposition du présent Chapitre ne sera interprétée comme modifiant directement ou indirectement en aucune manière les droits quelconques d'aucun État ou d'aucun peuple ou les dispositions d'actes internationaux en vigueur auxquels des Membres de l'Organisation peuvent être parties. > > > It gives me: > > Except as may be agreed upon in the special guardianship agreements concluded in accordance with Articles 77, 79 and 81 and placing each territory under the trusteeship system, and until such agreements have been concluded, This Chapter shall not be construed as directly or indirectly modifying in any way the rights of any State or any people or the provisions of international instruments in force to which Members of the Organization may be parties. > > > Perfect! ([Almost](http://www.un.org/en/sections/un-charter/chapter-xii/index.html).) This is why its Latin translations tend to be so poor: it has a very thin corpus of human-made translations of Latin on which to base its probability estimates—and, of course, it's using an approach that's based on probabilities of word sequences, disregarding grammar and meaning. So, until the United Nations starts doing its business in Latin, Google Translate is not going to do a very good job. And even then, don't expect much unless you're translating text pasted from UN documents. The five-word window ==================== Here's an illustration of the five-word window. I enter: > > Pants, as you expected, were worn. > > > Pants were worn. > > > Pants, as you expected, are worn. > > > The Latin translations (with my manual translations back to English): > > [Anhelat](https://en.wiktionary.org/wiki/anhelo#Latin) quemadmodum speravimus confecta. *(He is panting just as we hoped accomplished.)* > > > [Braccas](https://en.wiktionary.org/wiki/braca#Latin) sunt attriti. *(The trousers have been worn away [like "attrition"].)* > > > Anhelat, ut spe [teris](https://en.wiktionary.org/wiki/tero#Latin). *(He is panting, just as, by hope, you are wearing [something] out.)* > > > Notice that the first and third sentences border on ungrammatical nonsense. The second sentence makes sense but it's ungrammatical; it should be *Braccae sunt attritae.* There aren't any five-word sequences in Google Translate's English database that line up well with "pants as you expected were/are," so it's flailing. Notice that in the third sentence, by the time it got to "worn", it had forgotten which sense of "pants" it chose at the start of the sentence. Or rather, it didn't forget, because it never tracked it. It only tracked five-word sequences. So, whether the sentence makes sense sort of affects the translation, but it's worse than that. What matters is exact, word-for-word matching with texts in the database. Entering Latin into Google Translate (with words changed from the first sentence shown in bold): > > Abraham vero aliam duxit uxorem nomine Cetthuram. > > > **Quintilianus** vero aliam duxit uxorem nomine Cetthuram. > > > Abraham vero aliam duxit uxorem nomine **Iuliam**. > > > Abraham vero **canem** duxit uxorem nomine **Fido**. > > > English output: > > And Abraham took another wife, and her name was Keturah. > > > Quintilian, now the wife of another wife, and her name was Keturah. > > > And Abraham took another wife, and the name of his wife, a daughter named Julia. > > > And Abraham took a wife, and brought him to a dog by the name of Fido. > > > The Vulgate and the [ASV translation](https://www.biblegateway.com/passage/?search=Genesis%2025&version=ASV) (or similar) would appear to be among Google Translate's source texts. Notice what happens when the input is off by as little as one word. --- The above explains just enough so that a layperson can understand what Google Translate is good at, what it's bad at, and why—and so they won't be misled by the results of experimenting with different grammatical structures. If you're interested in more rigorous and thorough information about the full complexities of this approach, google for "[statistical machine translation](https://www.google.com/search?q=statistical+machine+translation)". Some further info is [here](https://en.wikipedia.org/wiki/Google_Translate#Method_of_translation), including Google's rollout, now in progress, of an entirely new translation algorithm (which hasn't reached Latin yet).
To answer the question ("What is Latin Google Translate good for?") as stated: ***Absolutely nothing***. At least reliably.
4,349
Google Translate is notoriously unreliable for Latin. However, the translations do make some amount of sense. **Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?** I tried it for simple phrases to and from English. Here are the result of my little test1: 1. Puer canem amat. → The boy dog loves. (The boy loves the dog.) 2. Canem puer amat. → The boy loves the dog. (Correct!) 3. Puerum canis amat. → The dog loves the child. (Correct!) 4. Canis puerum amat. → The dog loves the child. (Correct!) 5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.) 6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.) 7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.) 8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.) 9. The boy loves the dog. → Puer canem diligit. (Correct!) 10. The dog loves the boy. → Canis puerum amat. (Correct!) 11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.) 12. The dog of the boy loves. → Canis pueri amat. (Correct!) 13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.) These might not be the perfect example sentences, but they demonstrate some basic syntax. (Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.) It seems that translation from Latin to English is very difficult even with simple structures. English to Latin is much better, but it fails for the slightly more complicated sentence. Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones. The tool might work better for translating individual words2 or with some language other than English. And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience. Does someone have more experience with Google Translate? It would be good to know if there is something it is useful and reliable for, even if the scope is very limited. --- 1 Format: Original → Google translation (better translation if Google fails) 2 For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79). But my question is not whether there are better tools than Google Translate. The question whether Google Translate can be trusted for anything at all regarding Latin.
2017/05/11
[ "https://latin.stackexchange.com/questions/4349", "https://latin.stackexchange.com", "https://latin.stackexchange.com/users/79/" ]
I think the examples given in the question and in the answers are grammatically non-trivial and thus **prone to translation mistakes**, even by a human learning a language (two substantives, two verbs, etc). That Google makes mistakes might not be so surprising, and we could even argue that the tests were too stringent. Perhaps a much more revealing test is to try Google translate with **unequivocally simple examples**. So, to see if Google understands us, I will try "I do not understand". From the grammatical point of view, it's trivial: one person/pronoun, one verb. No complex lexical twists possible. So, what do we get? Brace yourselves: [![enter image description here](https://i.stack.imgur.com/vq8nw.png)](https://i.stack.imgur.com/vq8nw.png) So far so good! But to be honest, many people just use "don't" rather than "do not". So... [![enter image description here](https://i.stack.imgur.com/M6iTq.png)](https://i.stack.imgur.com/M6iTq.png) What??? Did Google just changed the person? How on earth could it mistake an "I" by a plural "you"? Just for the sake of it, I also try it in Spanish: [![enter image description here](https://i.stack.imgur.com/40438.png)](https://i.stack.imgur.com/40438.png) Same basic mistake. What about "I understand"? [![enter image description here](https://i.stack.imgur.com/pmn3E.png)](https://i.stack.imgur.com/pmn3E.png) Better. What about "I do understand"? [![enter image description here](https://i.stack.imgur.com/SchsW.png)](https://i.stack.imgur.com/SchsW.png) Totally odd. If we reverse the direction of translation, we get: [![enter image description here](https://i.stack.imgur.com/tzjFR.png)](https://i.stack.imgur.com/tzjFR.png) From where we get the amazing conclusion that: > > I do understand = I do not understand > > > I think that we can now safely conclude that **Google translate is terrible** even for the most simple tasks.
I found a very specific use for it this summer. For a couple weeks I was at one of the living-Latin summer programs run by [SALVI](http://www.latin.org), and the rule there—as at other such programs I've attended—is that you're not allowed to speak any language but Latin except in emergencies. Since my husband, who speaks no Latin, gets lonely when it's just him and the dog and was annoyed that we'd be out of touch for so long, I wanted to be able to communicate with him a little bit, and Google Translate turned out to be just the thing. We sent each other very short, simple sentences ("Quōmodo tē habēs? Tē dēsīderō," etc.); the Latin he sent wasn't always correct but I always understood what he was trying to say, and I have to assume the same was true of the English that resulted from my Latin. It made him feel much better about my absence. So the answer is: Google Translate is good for preserving marital bliss!
24,275
I have a mac and raspberry pi connected via ethernet cable which are communicated fine. Internet sharing is turned on but my raspberry pi can't connect to the internet. My mac is connected to the internet via Wifi with the following settings: ![enter image description here](https://i.stack.imgur.com/sfLfg.png) Internet is working on my mac and have connected an ethernet cable between my mac and my raspberry pi. I turned on internet sharing on my mac and gave the ethernet the following settings: ![enter image description here](https://i.stack.imgur.com/mt3Lp.png) I gave my raspberry pi a static IP address in the same subnet (192.168.1.20) by editing the network/interaces file and set the gateway the same as my Macs ip address, which looks like this: ``` auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.20 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.90 allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp ``` I can ping from my RPi to my mac (ping 192.168.1.90) and can ssh into my RPi from my mac (set up previously; ssh [email protected]). **The problem**: I can't seem to connect to the internet. Running `sudo apt-get update` shows errors in the lines of "temporary failure resolving archive.raspberrypi.org'. Any help or advice is appreciated. **Update 1:** The output of "route" is (after waiting many seconds): ``` Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.1.254 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 ```
2014/11/04
[ "https://raspberrypi.stackexchange.com/questions/24275", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/22249/" ]
Your route is incorrect: default 192.168.1.254 If your gateway (in this case the Mac) is at .1.90, your gateway has to be at .1.90 If you have just set the fixed IP in network/interfaces, then you may need to restart your networking stack (/etc/init.d/network restart). Also check your current network configuration with "ifconfig eth0", you may see the problem right there. To fix your route do this: "route add default gw 192.168.1.90"
You have to enable this in 'Sharing' under 'Settings' Follow this <http://millibit.blogspot.com/2014/12/ceph-pi-making-pi-with-mac.html#internet_sharing>
1,612,989
The number of maps $f$ from the set $\{1,2,3\}$ into the set $\{1,2,3,4,5\}$ such that $f(i)\le f(j)$, whenever $i<j$.
2016/01/15
[ "https://math.stackexchange.com/questions/1612989", "https://math.stackexchange.com", "https://math.stackexchange.com/users/305289/" ]
You have to choose the $3$ function values $f(1),f(2),f(3)$ from $5$ possibilities, with repetition allowed. The order of the $3$ chosen numbers is not important, because once you have chosen them, the condition $f(i)\le f(j)$ tells you which is $f(1)$, which is $f(2)$ and which is $f(3)$. The number of choices of $3$ elements from $5$, with order not important and repetition allowed, is $$C(5+3-1,3)=C(7,3)=35\ .$$ For the ideas behind this see [here](https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29).
Hint - Suppose you map $1$ to $1$, now if $2$ maps to $1$ then $3$ can map to $1,2,3,4$ or $5$, Similarly if $2$ maps to $2$ then $3$ will have $4$ choices to map to, so the total no of functions when $1$ maps to $1$ is $(5+4+3+2+1)$ Similarly count the others when $1$ maps to $2,3,4$ or $5$
83,380
I have found lots of information online about European pilots owning and flying N-reg aircraft using trusts set up in the US. I live in Europe, but I'm a US citizen, so must I also set up a trust because I don't live in the US? I cannot seem to find a definitive answer on this with references to supporting regulation.
2021/01/08
[ "https://aviation.stackexchange.com/questions/83380", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/52979/" ]
As a US citizen you can own an N-reg aircraft directly, regardless of where you live. The regulations on aircraft registration are in [14 CFR Part 47](https://www.ecfr.gov/cgi-bin/text-idx?node=pt14.1.47#se14.1.47_17). They say *who* can register an N-reg aircraft, but they don't say anything about *where* that person must be. 47.3(a)(1) simply says: > > **§47.3 Registration required.** > > > (a) An aircraft may be registered under 49 U.S.C. 44103 only when the > aircraft is not registered under the laws of a foreign country and is— > > > (1) Owned by a citizen of the United States; > > > The regulations are summarized in a more readable way on [this FAA site](https://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/register_aircraft/). A trust allows a non-US citizen (or non-resident alien) to own an N-reg aircraft provided they have no more than 25% of the voting rights in the trust, per 47.7(c)(2)(iii).
According to NBAA, trusts are used by non-US citizens to register aircraft with the FAA. Because you are a US citizen, it looks like you don't need a trust to maintain the FAA registration. Here's the article with references to the FARs: <https://nbaa.org/flight-department-administration/aircraft-registration-transactions/owner-trusts/> . Here's an aviation trust company: <https://aviationtrust.com/> . I have no financial interest in that company. They appeared higher up in my search.
83,380
I have found lots of information online about European pilots owning and flying N-reg aircraft using trusts set up in the US. I live in Europe, but I'm a US citizen, so must I also set up a trust because I don't live in the US? I cannot seem to find a definitive answer on this with references to supporting regulation.
2021/01/08
[ "https://aviation.stackexchange.com/questions/83380", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/52979/" ]
As a US citizen you can own an N-reg aircraft directly, regardless of where you live. The regulations on aircraft registration are in [14 CFR Part 47](https://www.ecfr.gov/cgi-bin/text-idx?node=pt14.1.47#se14.1.47_17). They say *who* can register an N-reg aircraft, but they don't say anything about *where* that person must be. 47.3(a)(1) simply says: > > **§47.3 Registration required.** > > > (a) An aircraft may be registered under 49 U.S.C. 44103 only when the > aircraft is not registered under the laws of a foreign country and is— > > > (1) Owned by a citizen of the United States; > > > The regulations are summarized in a more readable way on [this FAA site](https://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/register_aircraft/). A trust allows a non-US citizen (or non-resident alien) to own an N-reg aircraft provided they have no more than 25% of the voting rights in the trust, per 47.7(c)(2)(iii).
No, as a US citizen you do not need to jump through any hoops to register an N-reg aircraft in your name, anywhere in the world. It doesn't matter where you live. I used to own an N-reg aircraft when I lived in Germany. It was registered to my German address. When I moved back to the US and brought it with me I submitted a change of address, and that was the end of that.
41,673,206
There are around 3 hundred components rendered inside the wrapper component and its taking to much of time to render. But I need thousand of components to get rendered inside the wrapper container. How can I achieve this without any performance issues while rendering the components [Image shows the rendering time taken by 300 components which is too much](https://i.stack.imgur.com/WhoMQ.png)
2017/01/16
[ "https://Stackoverflow.com/questions/41673206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2282123/" ]
You could sort the strings for the same order and join it. ```js function getUnique(a, b) { return [a.toString(), b.toString()].sort().join(''); } console.log(getUnique("apple", "ball")); console.log(getUnique("ball", "apple")); ``` For numbers, i suggest to use a separator and numerical order. ```js function getUnique(a, b) { return [a, b].sort(function (a, b) { return a - b; }).join('|'); } console.log(getUnique(1, 111)); // 1|111 console.log(getUnique(111, 1)); // 1|111 console.log(getUnique(11, 11)); // 11|11 ```
You can use `concat` method. See this example: ``` var str1 = "Hello "; var str2 = "world!"; var res = str1.concat(str2); ``` Source: <http://www.w3schools.com/jsref/jsref_concat_string.asp>
10,432,297
I'm working with a simple ASMX web service that gives the users the ability to add comments. For each comment that gets added I add a timestamp to the row. The issue I'm running into is that If I add two comments 1 second apart they will both have the same timestamp. Instead of using `DateTime.Now` in my code I use a static class so I can easily write unit tests. Here is my `Time` class: ``` public class Time : IDisposable { public static DateTime Now; static Time() { ResetToDefault(); } public static IDisposable Freeze(DateTime dateTimeToFreeze) { Now = dateTimeToFreeze; return new Time(); } void IDisposable.Dispose() { ResetToDefault(); } private static void ResetToDefault() { Now = DateTime.Now; } } ``` I'm guessing this class is the culprit because if I replace all instances of `Time.Now` with `DateTime.Now` everything works as expected. What is causing my `Time` class to freeze and not always refresh when requesting the current time?
2012/05/03
[ "https://Stackoverflow.com/questions/10432297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1135049/" ]
If you right click on the file, you should be able to see the permissions and attributes of the file.
Right click one the file--> Details . You can see the computer name where it was created and the date.
10,432,297
I'm working with a simple ASMX web service that gives the users the ability to add comments. For each comment that gets added I add a timestamp to the row. The issue I'm running into is that If I add two comments 1 second apart they will both have the same timestamp. Instead of using `DateTime.Now` in my code I use a static class so I can easily write unit tests. Here is my `Time` class: ``` public class Time : IDisposable { public static DateTime Now; static Time() { ResetToDefault(); } public static IDisposable Freeze(DateTime dateTimeToFreeze) { Now = dateTimeToFreeze; return new Time(); } void IDisposable.Dispose() { ResetToDefault(); } private static void ResetToDefault() { Now = DateTime.Now; } } ``` I'm guessing this class is the culprit because if I replace all instances of `Time.Now` with `DateTime.Now` everything works as expected. What is causing my `Time` class to freeze and not always refresh when requesting the current time?
2012/05/03
[ "https://Stackoverflow.com/questions/10432297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1135049/" ]
Check at the end of the line. Under GNU/Linux lines end with \n (ascii: 0x0A) while under Miscrosoft W$ndos it is \r\n (ascii: 0x0D 0x0A). Wikipedia: <https://en.wikipedia.org/wiki/Newline>
Right click one the file--> Details . You can see the computer name where it was created and the date.
10,432,297
I'm working with a simple ASMX web service that gives the users the ability to add comments. For each comment that gets added I add a timestamp to the row. The issue I'm running into is that If I add two comments 1 second apart they will both have the same timestamp. Instead of using `DateTime.Now` in my code I use a static class so I can easily write unit tests. Here is my `Time` class: ``` public class Time : IDisposable { public static DateTime Now; static Time() { ResetToDefault(); } public static IDisposable Freeze(DateTime dateTimeToFreeze) { Now = dateTimeToFreeze; return new Time(); } void IDisposable.Dispose() { ResetToDefault(); } private static void ResetToDefault() { Now = DateTime.Now; } } ``` I'm guessing this class is the culprit because if I replace all instances of `Time.Now` with `DateTime.Now` everything works as expected. What is causing my `Time` class to freeze and not always refresh when requesting the current time?
2012/05/03
[ "https://Stackoverflow.com/questions/10432297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1135049/" ]
found this: <http://bit.ly/J258Mr> for identifying a word document but some of the info is relevant > > To see on which computer the document had been created, open the Word > document in a hex editor and look for "PID\_GUID". This is followed by > a globally unique identifier that, depending upon the version of Word > used, may contain the MAC address of the system on which the file was > created. > > > Checking the user properties (as already mentioned) is a good way to > see who the creator of the original file was...so, if the document was > not created from scratch and was instead originally created on another > system, then the user information will be for the original file. > > > Another way to locate the "culprit" in this case is to parse the > contents of the NTUSER.DAT files for each user on each computer. While > this sounds like a lot of work, it really isn't...b/c you're only > looking for a couple of pieces of information. Specifically, you're > interested in the MRU keys for the version of Word being used, as well > as perhaps the RecentDocs keys." > > >
Right click one the file--> Details . You can see the computer name where it was created and the date.
10,432,297
I'm working with a simple ASMX web service that gives the users the ability to add comments. For each comment that gets added I add a timestamp to the row. The issue I'm running into is that If I add two comments 1 second apart they will both have the same timestamp. Instead of using `DateTime.Now` in my code I use a static class so I can easily write unit tests. Here is my `Time` class: ``` public class Time : IDisposable { public static DateTime Now; static Time() { ResetToDefault(); } public static IDisposable Freeze(DateTime dateTimeToFreeze) { Now = dateTimeToFreeze; return new Time(); } void IDisposable.Dispose() { ResetToDefault(); } private static void ResetToDefault() { Now = DateTime.Now; } } ``` I'm guessing this class is the culprit because if I replace all instances of `Time.Now` with `DateTime.Now` everything works as expected. What is causing my `Time` class to freeze and not always refresh when requesting the current time?
2012/05/03
[ "https://Stackoverflow.com/questions/10432297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1135049/" ]
The one thing I can think on the top of my mind is inspecting the newline characters on your file - I'm assuming your files do have multiple lines. If the file was generated using Windows then a newline would be characterized by the combination of carriage return and line feed characters (CR+LF) whereas a simple line feed (LF) would be a hint that the file was generated in a Linux machine.
Right click one the file--> Details . You can see the computer name where it was created and the date.
6,095
The stock media player on my phone has an annoying behaviour. Whenever I unplug the headphones, if the media player is paused or not running, it immediately starts running and playing my playlist. This is very annoying because everyone in the room is forced to listen to my songs until I manage to tap (twice) the Music Widget. Has this been happening to anyone else? And what did you do to fix it? *Note: I'm not sure if it's Android's stock player or if it's Motorola's stock player, it's just called "Music". Note 2: From the comments, it seems this is Android's stock music app.* **Motorola-Milestone, firmware 2.1-update1.**
2011/02/17
[ "https://android.stackexchange.com/questions/6095", "https://android.stackexchange.com", "https://android.stackexchange.com/users/1926/" ]
This is a known bug in Android (even in certain Eclair systems). There's a widget called [Headset Blocker](https://market.android.com/details?id=com.idunnolol.headsetblocker) that when added to any of your homescreens and activated prevents the music player from playing whenever you unplug your headest. Freeware and it works. See if it helps.
Since you mentioned Motorola in the question, this might be your problem: The Droid and Milestone were having this problem on Android 2.0.1 or less. It was corrected on Android 2.1. So update your phone to the latest version and it should be corrected.
6,095
The stock media player on my phone has an annoying behaviour. Whenever I unplug the headphones, if the media player is paused or not running, it immediately starts running and playing my playlist. This is very annoying because everyone in the room is forced to listen to my songs until I manage to tap (twice) the Music Widget. Has this been happening to anyone else? And what did you do to fix it? *Note: I'm not sure if it's Android's stock player or if it's Motorola's stock player, it's just called "Music". Note 2: From the comments, it seems this is Android's stock music app.* **Motorola-Milestone, firmware 2.1-update1.**
2011/02/17
[ "https://android.stackexchange.com/questions/6095", "https://android.stackexchange.com", "https://android.stackexchange.com/users/1926/" ]
This is a known bug in Android (even in certain Eclair systems). There's a widget called [Headset Blocker](https://market.android.com/details?id=com.idunnolol.headsetblocker) that when added to any of your homescreens and activated prevents the music player from playing whenever you unplug your headest. Freeware and it works. See if it helps.
I used to have this problem on my Motorola Droid 1. I used Tasker to "stop music" on certain headset events. [See my answer here.](https://android.stackexchange.com/questions/4940/random-music-playback-winamp-cubed/4962#4962)
53,868,770
I simply want to use a modified example of Nested flex on the [PrimeNG Flex](https://www.primefaces.org/primeng/#/flexgrid) by using the code below: ``` <h3>Nested</h3> <div class="p-grid nested-grid"> <div class="p-col-8"> <div class="p-grid"> <div class="p-col-6"> <div class="box">6</div> </div> <div class="p-col-6"> <div class="box">6</div> </div> <div class="p-col-12"> <div class="box">12</div> </div> </div> </div> <div class="p-col-4"> <div class="box box-stretched">4</div> </div> </div> ``` However, the col divs act as the total size is not 12, instead 11 and if the total p-col number is 12 or more, the elements wrap to the next row that I do not want. On the other hand, I have a look at all of the main divs and body paddings and margins but there is no problem with that. I think the padding of the p-cols does not causing this problem and their paddings are also 0-5 px range. Any idea how to fix this problem?
2018/12/20
[ "https://Stackoverflow.com/questions/53868770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/836018/" ]
the example in the site shows kind of like this i don't think you need 'p-grid nested-grid' ``` <div class="p-grid"> <div class="p-col-8"> <div class="p-grid"> <div class="p-col-6"> 6 </div> <div class="p-col-6"> 6 </div> <div class="p-col-12"> 12 </div> </div> </div> <div class="p-col-4"> 4 </div> ```
Remove the `nested-grid` class in the first `div` element, it's not needed as shown in the example. ``` <div class="p-grid"> <div class="p-col-8"> <div class="p-grid"> <div class="p-col-6"> 6 </div> <div class="p-col-6"> 6 </div> <div class="p-col-12"> 12 </div> </div> </div> <div class="p-col-4"> 4 </div> </div> ```