Post

2 followers Follow
0
Avatar

Bilingual with two columns

Hi all

I have 2 text field:

-----------------

Text Field a: paragraph Language A

Ax xxx /

Att t/

Az zz /

Appp pp ppp/

 

Text Field b: paragraph Language B

Bl/

Byy yyy/

B qqqq/

B uuu uu/

----------------------

Calculation Field bilingual a&b:

Table view:

No. | Language a | Language b

1    | Ax xxx | Bl

2| Att t | Byy yyy

3| Az zz | B qqqq

4 |  Appp pp ppp | B uuu uu

….

if possible, please tell me how can create this table-calculation (bilingual a&b) or other solution?

Many thanks

Ninh

Please sign in to leave a comment.

56 comments

0
Avatar

Hi Rainer,

danke fuer Ihr Support.

Calculation note : 

" Script syntax error: Unexpected token ILLEGAL."

May be the formula has typo but i can't find it: 

var sen = @all of table field in sentences;
var ord = @all of order number in sentences;
var rows = [];
for( var i = 0; i < sen.length; i++){
senArr = sen[i].split("\n"),
for(var j = 2; j < senArr.length; j++){
senOrd = senArr[j] + " | " + ord[i];
rows.push(senOrd);
}};
var rows = rows.sort( function (a,b) {
a = a.split(" | ")[1];
b = b.split(" | ")[1];
return a-b
}).join("\n).
"No. | First Letter | Word |  Sentence Order \n" +
"--- | --- | --- | --- \n" +
rows

Please help me to correct it.

=============================

Other hand,

In some article there are some number, ex: 2.017 years, 67.48$, 4.7 kg

With formula: b = str.replace(/(<([^>]+)>)|\*|\n|\r/ig,"").replace(/!/g,"!.").replace(/\?/g,"?.").replace(/([.?])\s*(?=[A-Z0-9'"])/g, "$1|").split("|");

Each break line is created if after number and dot (.) is blank character, as:

2

017 years

4

7 kg

How don’t break line of text if after number and dot (.) are not blank character?

Schones Wochenende fuer mein Hero :)

Ninh 0 votes
Comment actions Permalink
0
Avatar

Hi Ninh,

indeed there are 2 typos:

1. Replace in this line the comma by a semicolon
Correct line:

senArr = sen[i].split("\n");

2. In this line remove the dot behind the last bracket
Correct line:

}).join("\n)

 

 

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Thank Rainer,

i fixed these 2 typo, but calculation still " Script syntax error: Unexpected token ILLEGAL."

maybe there is other typo?

This formula

========

var sen = @All of Vocabulary list;
var ord = @All of Ordernumber;
var rows = [];
for( var i = 0; i < sen.length; i++){
senArr = sen[i].split("\n");
for(var j = 2; j < senArr.length; j++){
senOrd = senArr[j] + " | " + ord[i];
rows.push(senOrd);
}};
var rows = rows.sort( function (a,b) {
a = a.split(" | ")[1];
b = b.split(" | ")[1];
return a-b
}).join("\n)
"No. | First Letter | Word | Sentence Order \n" +
"--- | --- | --- | --- \n" +
rows

========

thanks

Ninh 0 votes
Comment actions Permalink
0
Avatar

Can't see a typo. Please share a screenshot of the calculation field where I can see the error notification.

For your other question: In some article there are some number, ex: 2.017 years, 67.48$, 4.7 kg

I've changed the whole formula, the for-loop shouldn't be necessary anymore. Please try this.

@text.replace(/(<([^>]+)>)|\*|_/g,"").replace(/(\?|\!)/g,"$1.").replace(/\n|\r/g," ").replace(/([\.?])\s*(?=\s.?([^a-z ]))/g,"/\n").replace(/\.([^.]*)$/, "$1/")

If that doesn't work please create a text which covers all possible scenarios. 

Rainer

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Great Rainer.

the new calculation without "for statement" works well

You are legend

Ninh 0 votes
Comment actions Permalink
0
Avatar

Dear Rainer, das Ergebnis ist:

In table, row sort by sentence order.

Can sort by No. and First Letter of Word, ex:

No.         First Letter       Word            Sentence Order

1            A                         and                     10

2            D                        during                  1

....

Danke im Voraus

Ninh 0 votes
Comment actions Permalink
0
Avatar

Hi Rainer,

new Formula is brillante but the last sentence don't work: not change from dot to  // character

Formula: 

@1A_Original English.replace(/(<([^>]+)>)|\*|_/g,"").replace(/!/g,"!.").replace(/\?/g,"?.").replace(/[\u201C]/g,'"').replace(/([\.?])\s*(?=\s.?([^a-z0-9'" ]))/g,"//\n").replace(/\.([^.]*)$1/, "$1/")

please see attachment image

of the country test. => of the country test //

Ninh 0 votes
Comment actions Permalink
0
Avatar

Cause you don't use the code I've provided in my last but one posting. Take and it will work.

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

For the table:

var sen = @all of table field in sentences;
var ord = @all of order number in sentences;
var rows = [];
for( var i = 0; i < sen.length; i++){
senArr = sen[i].split("\n");
for(var j = 2; j < senArr.length; j++){
rows.push(senArr[j] + " | " + ord[i];);
}};
var rowsSort = rows.sort( function (a,b) {
a = a.split("|")[1].trim();
b = b.split("|")[1].trim();
return a-b
});
var rows = [];
for(var i = 0; i < rowsSort.length; i++){
rows.push(rowsSort[i].replace(/\[.*?\]/,"[" + i + "]"));
};
"No. | First Letter | Word | Sentence Order \n" +
"--- | --- | --- | --- \n" +
rows.join("\n")
Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Danke Rainer,

Sie sind richtig.

That is my fail, Sorry.

1. Can i  replace number (USA: dot) to number (Deutschland: comma). Ex: 100.5 kg USA => 100,5 kg DL,  in article?

2. Numbered list: 1. or 2. or 10. to 1, 2, or 10, 

Can use together with the formula: 

@text.replace(/(<([^>]+)>)|\*|_/g,"").replace(/(\?|\!)/g,"$1.").replace(/\n|\r/g," ").replace(/([\.?])\s*(?=\s.?([^a-z ]))/g,"/\n").replace(/\.([^.]*)$/, "$1/")

Thanks

Ninh 0 votes
Comment actions Permalink
0
Avatar

and the table of above the formula:

1. Order of columns: deviation on the left and column (No.): No data (please see ímage)

2. some first rows has no data

3. First letter is not in A-Z order

Danke im Voraus

Ninh 0 votes
Comment actions Permalink
0
Avatar

Can i  replace number (USA: dot) to number (Deutschland: comma). Ex: 100.5 kg USA => 100,5 kg DL,  in article?

Add .replace(/USA/g,"DL") at the end. 

For the table:I need to see the code of the table in Sentences and a screenshot how this table looks like in an item. And also the code from words from the fields where the Sentences tables get their data.

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Danke Rainer,

i tested with 2 number : dot and comma. But no effort, please see image

wish: dot => comma

Coding

many thanks

Ninh 0 votes
Comment actions Permalink
0
Avatar

And the formula for this calculation field (vocabulary list)

Danke

 

Ninh 0 votes
Comment actions Permalink
0
Avatar

ok, I see, that was a misunderstanding :) I've thought you want to to remove the string "USA" by the string "DL", but you mean the number formatting. Forget my last .replace() and delete it. 

This one should do what you want:

.replace(/(\d),(\d{3})/g,"$1X_X$2").replace(/(\d)\.(\d)/g,"$1,$2").replace(/X_X/g,".")

But this replaces also the dots by commas in a text like: "As mentioned in chapter 1.1 and chapter 2.2. this ... ".

 

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

And the formula for this calculation field (vocabulary list)

I've meant the other vocabulary list (the one you get in var sen)

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Danke great Rainer,

good result from new calculation:

@text.replace(/(<([^>]+)>)|\*|_/g,"").replace(/(\?|\!)/g,"$1.").replace(/\n|\r/g," ").replace(/([\.?])\s*(?=\s.?([^a-z ]))/g,"/\n").replace(/\.([^.]*)$/, "$1/").replace(/(\d),(\d{3})/g,"$1X_X$2").replace(/(\d)\.(\d)/g,"$1,$2").replace(/X_X/g,".")

please see before and after in image

1. Number: 1.405 (before) => 1,405 (after): correct. But 5,987 (before) => 5.987 (after): incorrect => with comma (before) don't need change to dot. That mean; only one way to change number formating: from comma to dot

2. in chapter: More 1 digit are correct, ex: 1.2 or 3,1 or 4.0   but only one digit ex: 2. are incorrect

Ninh 0 votes
Comment actions Permalink
0
Avatar

Hi Ninh,

the new calculation does exactly what you wanted and what you've asked for: Transfer US number format to German number format.

1000 separator US = comma, German = dot
Decimal separator US = dot, German = comma.

1.405 (US) == 1 decimal 405
5,987 (US) == five thousand nine hundred eighty-seven

1,405 (German) = 1 decimal 405
5.987 (German) == five thousand nine hundred eighty-seven

1.405 (before) => 1,405 (after): correct AND 5,987 (before) => 5.987 (after): CORRECT

The issue with list number 2. isn't caused by the new code, but by the older part which removes dot by / line break. In this case in the original text between 2 and dot is a backslash, this backslash escapes the dot (you can google for "escape markdown").
You can try .replace(/\\/g,"") but this doesn't work for all cases, depends on how the backslash was entered in the original text.

Rainer

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

Hi great Rainer,

You are diamond :)

Number formating of DL is total different with USA  :)

-------------------------------------------------------------

About calculation Vocabulary list in App article:

i use calculation with your help:

// Vocabulary list = table field in Sentence

// Số thứ tự câu ở Source = number in sentence

var sen = @All of Vocabulary list;
var ord = @All of Số thứ tự câu ở Source;
var link= "https://podio.com/.../example/items/";
var ID = @All of Example ID Link with nulls;
var rows = [];
for ( var i = 0; i < sen.length; i++){
senArr = sen[i].split("\n");
for(var j = 2; j < senArr.length; j++){
if (senArr[j]+""!="") {
rows.push(senArr[j] +"["+ ord[i]+ '](' + link + ID[i] + ')|');
}
}};
var rowsSort = rows.sort( function (a,b) {
a = a.split("|")[1].trim();
b = b.split("|")[1].trim();
return a-b;
});
var rows1 = [];

for(var i = 0; i < rowsSort.length; i++){
rows1.push(rowsSort[i].replace(/\#.*?\./g,(i+1)));
};


"|No. | First Letter | Word | Sentence Order |\n" +
"|--- | --- | --- | ---| \n" +
rows1.join("\n")

=============

 

And result: 

all data display good. But only one issue: First Letter do not sort A-Z

Please check and correct it if any.

Danke shone.

Schonest Wochenende

Hope is last for this long topic with your help 

Ninh 0 votes
Comment actions Permalink
0
Avatar

In var rowsSort change the return line to:

return ((a < b) ? -1 : ((a > b) ? 1 : 0))

Rainer

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

thank you Rainer

i was changed:

var rowsSort = rows.sort( function (a,b) {
a = a.split("|")[1].trim();
b = b.split("|")[1].trim();
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
});

and first letter still don't display A-Z

Please help

thanks

Ninh 0 votes
Comment actions Permalink
0
Avatar

Dear Rainer,

ich habe noch eine Frage.

Changing: from ". to ". 

and i use formula: replace("."",'".\n')

Calculation note: script syntax error unexpected string

============

Example:

thank you

 

Ninh 0 votes
Comment actions Permalink
0
Avatar

and i use formula: replace("."",'".\n')

Don't understand what you want to achieve. Opening and closing quotation marks must be the same, eiter ' ', or " ". If you want to replace " it's  '"' (single double single).

 and first letter still don't display A-Z

for me it works. There must be something in your linked letter formula which isn't correct. You can check that by entering

rows[0]

as last line, It should look like:

n1 | [A](https://podio.com.....) | word  | n2

n1 = some No., n2 = some sentence order No.

Rainer Grabowski 0 votes
Comment actions Permalink