Skip to content
Advertisement

How can I say that if I want to return an operation on a list, but it stays the same when it comes out null?

I have a list-of-list of word groups in Turkish. I want to apply stemming and I found turkishnlp package. Although it has some shortcomings, it often returns the right word. However, when I apply this to the list, I don’t want the structure of my list to change and I want the words that he doesn’t know to stay the same.

For example, I have this list: mylist = [[‘yolda’,’gelirken’,’kopek’, ‘gördüm’],[‘cok’, ‘tatlıydı’]]

And I wrote this function:

JavaScript

This function returns this list:

JavaScript

[[‘yol’, ‘gelir’, ”, ‘gör’], [”, ‘tatlı’]]

However, I want to get this as the output: [[‘yol’, ‘gelir’, ‘kopek’, ‘gör’], [‘cok’, ‘tatlı’]]

How can I update my function? Thank you for your helps!

Advertisement

Answer

IIUC, you could modify your function to:

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement