Question

In: Computer Science

Hello, I have a problem with understanding this line. forEach(value.split("<br>"), line, line.trim()).slice(-3).join("\n") This line is for...

Hello, I have a problem with understanding this line.

forEach(value.split("<br>"), line, line.trim()).slice(-3).join("\n")

This line is for the open refine program. Could you tell me what this line is trying to do? I have no idea what this is for...

For your information, this line appeared when professor was talking about 'Fetching and Parsing HTML'..

Thank you for answering my question and have a good day!

p.s. My professor told us to insert that line in the expression box and try to figure out what this expression means... As I'm not majoring in CS, it's too difficult for me to understand..;(

Solutions

Expert Solution

. A forEach() statement asks for an array, a variable name, and an expression applied to the variable. Following the form forEach(array, variable, expression), construct the loop using these parameters:

ARRAY----its value.split("<br />"),(not "<br>which you ask in question ) creates an array from the lines of the sonnet in each cell

VARIABLE-----line, each item in the array is then represented as the variable (it could be anything, v is often used)

AN EXPRESSION TO BE APPLIED ON VARIABLE--

line.trim(), each item is then evaluated separately with the specified expression. In this case, trim() removes the white space from each sonnet line in the array.

As, the results of the forEach() are returned as a new array, additional array functions can be applied, which are slice and join. Add slice(1) to remove the sonnet number, and join("\n") to concatenate the lines in to a string value .

  • using all these above concepts you can create  a single line can be extracted and trimmed to create clean columns representing the sonnet number and first line
  • when you created a column ,after that by following the same technique, you can add another new column from parse named “last” to represent the final couplet lines using:

forEach(value.split("<br/>"), line, line.trim()).slice(-3).join("\n")


Related Solutions

Hello, I have a problem with understanding this code. value.parseHtml().select("p")[0].innerHtml() This code is for the open...
Hello, I have a problem with understanding this code. value.parseHtml().select("p")[0].innerHtml() This code is for the open refine program. Could you tell me what this code is trying to do? I have no idea what this is for... For your information, this code appeared when professor was talking about 'Fetching and Parsing HTML'.. Thank you for answering my question and have a good day! p.s. I don't know whether value.parseHtml().select("p")[0].innerHtml() is a code. Anyways, my professor told us to insert that...
Hello everyone! I have been stuck on this problem in my python 3 coding class. Is...
Hello everyone! I have been stuck on this problem in my python 3 coding class. Is there anybody who can see what I am doing wrong? The wings are .50 cents each, If I input sour and want 20 wings it should output a 0.15 discount. I just can't get it to work but I feel like I am really close. Thank you Code: #Variables answer = str() wings = int() rate = float() discount = float() subtotal = float()...
Hello! I have a question about the following problem, not sure how to approach it... This...
Hello! I have a question about the following problem, not sure how to approach it... This is from Mathematical Statistics and Data Analysis, Chapter 11, Problem 11.41 The Hodges-Lehmann shift estimate is defined to be d =median(Xi −Yj), where X1 , X2 , . . . , Xn are independent observations from a distribution F and Y1,Y2,...,Ym are independent observations from a distribution G and are independent of the Xi. Show that if F and G are normal distributions, then...
Hello , I cannot find the answer for this questions : Problem 3. (Signaling game: market...
Hello , I cannot find the answer for this questions : Problem 3. (Signaling game: market for used cars) Consider the market for used cars and assume that the cars can be of one of two possible quality levels: low (the ’lemons’) and high (the ’plums’). The seller knows the true quality of the car (the seller’s type is given by the quality level) but the buyers only know the probability distribution of the cars in the market. Assume that...
Hello! I have some problem wit this task. Comprehensive Problem 7-1 David and Darlene Jasper have...
Hello! I have some problem wit this task. Comprehensive Problem 7-1 David and Darlene Jasper have one child, Sam, who is 6 years old (birthdate July 1, 2013). The Jaspers reside at 4639 Honeysuckle Lane, Los Angeles, CA 90248. David's Social Security number is 577-11-3311, Darlene's is 477-98-4731, and Sam's is 589-22-1142. David's birthdate is May 29, 1986 and Darlene's birthday is January 31, 1988. David and Darlene's earnings and withholdings for 2019 are: David: Earnings from Apple Company (office...
Hello, I have to complete a horizontal and vertical analysis. The horizontal problem shows a comparative...
Hello, I have to complete a horizontal and vertical analysis. The horizontal problem shows a comparative balance sheet and the vertical problem shows a common size income statement. I have never learned this before so I wanted to get some help. I have to solve the horizontal problem as comparative then common size, and then vice versa for the vertical problem. What steps do I take?
Hello, I am just having a hard time understanding this question. The question is below. I...
Hello, I am just having a hard time understanding this question. The question is below. I am not supposed to write a program but instead in regular english sentence form just name the methods, fields, and variables I would use for this loan class. Im not really sure what a loan class means as well, thank you for your help. USING JAVA Given a Loan class, name the necessary fields and methods that we would need in this class. Be...
Hello, I have been struggling with the problem for a while now. Can someone please assist?...
Hello, I have been struggling with the problem for a while now. Can someone please assist? I cannot find the data online much less calculate the standard deviation. 1. Go to finance.yahoo.com and find them monthly rates of return over a 2 year period for five companies of your choice. Now assume you form each month an equally weighted portfolio of five firms (a portfolio with equal investments in each firm). What is the rate of return each month on...
Hello, I'm really struggling with this problem. So far I have calculated 48,000 for preferred and...
Hello, I'm really struggling with this problem. So far I have calculated 48,000 for preferred and 38,000 for common, which I know to be incorrect per my professor.  I also calculated 64,703 as the preferred and 41,697 as the common but I know these to be incorrect as well. I'm just not sure how to calculate this. Please see the below. The outstanding capital stock of Skysong Corporation consists of 2,000 shares of $100 par value, 8% preferred, and 5,100 shares...
Problem 1: USING STATPRO slice the data 3 ways As the midwest regional manager of a...
Problem 1: USING STATPRO slice the data 3 ways As the midwest regional manager of a chain of Heavenly Grill Restaurant, it is your responsibility to come up with the beer selections for the 50 restaurants under your management. It has been the policy of Heavenly Grill Restaurant to let each regional manager selects the beer offerings that are most appropriate for the region. However, the main office requires all regional managers to submit an annual report describing the beer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT