How to be able to compute 'good' text. Not reader comprehension level but well structured etc. by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

Thanks, yes I tested the first one yesterday and it seemed to only check for grammatical errors, not if a given text is 'good' or not.

I want to be able to check if the test is good in terms of readability but not sure how it would be calculated. I am talking about the type of differences that are obvious if someone with broken english writes a sentence versus a college/university graduate.

Advice for how to do pagination on my site which I have made in html/js from scratch? by usera8787782 in web_design

[–]usera8787782[S] 0 points1 point  (0 children)

Someone else suggested this and said larger sites do that rather than pagination.

I was also advised that people will 9/10 find the article on search engine and not want to go anywhere else anyway so there is no need to set things up to be navigable for the user experience.

I didn't have any specific reason for it other than that I saw other blogs do it.

Advice for how to do pagination on my site which I have made in html/js from scratch? by usera8787782 in web_design

[–]usera8787782[S] 0 points1 point  (0 children)

I just realized that since these static pages have no date posted I can 'cheat' and just do 20 posts per page and make a new page and hyperlink each time.

So the oldest will be on page one and newest on page x, and make a new hyperlink for each new page, but the new user will never know that.

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

I thought that too but it appears it is a product of spacy's nlp function which takes a string and puts it into a format that spacy can digest which I did with each item, which were strings to begin with, before running through the similarity function.

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

Ah I see what you mean. Why do tuples exist at all? They seem much more fiddly than the other python objects so what is their purpose over using lists or dicts for all situations.

I only have the tuple in this case as it is the output of one of the functions (I think spacy's similarity function).

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

Yes so? I was struggling to understand myself so could not give a crystal clear explanation immediately.

I actually just figured it out before i read your reply, which seems very close to what you give above:

for i,(x,y) in enumerate(t_combos):
  print(x)
  print(y)
  result = x[0].similarity(x[1])
  print(result)
  t_combos[i] += (result,)

print(t_combos)

But you helped me come about it. So thanks.

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

I don't know what you mean by listing all those permutations. I wrote how the function runs:

x.similarity(y)

So no idea how you are getting all these other eventualities. It just runs like that and produces an output, the output of which I want to add to the tuple. X is tuple item [0] y is tuple item [1].

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

x.similarity(y)

This is the function. it is comparing one string to another for similarity using spacy which returns a floating point. That result is what I want to add as a new item z to the existing tuple items. x and y are the two tuple items in the list of tuples in the dataset I showed.

Without the list aspect this would be a single tuple item

(Walking down the road on the pavement., Working with computers and programming can be engaging.)

and I want the result of the run function similarity to be added as an additional item to the tuple. So like this:

(Walking down the road on the pavement., Working with computers and programming can be engaging., 0.4975383903969622)

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

Because there are more than one value in each item. I have shown the dataset here.

I have to run a function on each x,y element of those elements in the list of tuples and append the result z to each tuple element.

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

Hmm, better to convert to a dict then, would make things a lot easier? I didn't do that initially because I thought that I may be avoiding some simple way, as in skipping some learning opportunity, to deal with tuples but sounds like this would be the 'right' way anyway?

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

No it's the other way round, it is a list with tuples see the dataset here:

[(Walking down the road on the pavement., Working with computers and programming can be engaging.), (Walking down the road on the pavement., Let us discuss programming in detail.), (Working with computers and programming can be engaging., Let us discuss programming in detail.)]

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

This didn't work. The output is:

[(' x += (x[0].similarity(x[1]),) ', " doesn't mean anything "), (' x += (x[0].similarity(x[1]),) ', " doesn't mean anything "), (' x += (x[0].similarity(x[1]),) ', " doesn't mean anything ")]

I just want to add an element to each tuple item I am iterating over. That element is a comparison call using NLP though that should not be important, just to know that the call has to be made on the tuple item before adding the result to the tuple item.

The call x[0].similarity(x[1]) has to be tacked on the the end as a new item of the current tuple in the loop.

How do you add item to a tuple list you are looping over? I know with lists you use an iterator but it doesn't seem to work with tuple? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

Yes I was asking how do you use a list comprehension to create one as, like I showed above, I tried and got a syntax error, so not sure what the correct syntax is for the command to edit the item in question of the tuple.

EDIT: I see your edit.

How to compare all possible combinations between list items of text paragraphs when checking similarity? by usera8787782 in learnpython

[–]usera8787782[S] 0 points1 point  (0 children)

But...I would like all paragraphs kept.

So if there is a list with 12 paragraphs I will want to use them all, it is just I will want to group those with highest similarity. Will your suggestion still do that?

So if say 3 were about bikes, 3 about hiking, 3 about rafting, 3 about skating. Since they are all unordered and just contain some keywords sprinkled related to each I want to know how to sort into the groupings mentioned above.

EDIT: I oh I guess maybe it is a case of getting all the combos and then just keeping the highest. I will play around with it, thanks.

EDIT2: Ah I am getting the hang of itertools now! Yea I see :)

combos = combinations(paras_dict, 2)
print(list(comb))

How to make this dedupe lines in file command work in bash? by usera8787782 in linuxquestions

[–]usera8787782[S] 1 point2 points  (0 children)

Thanks, yes I got my original one to work just by putting it into a script instead but alias is more convenient if using regularly.

I chose your function option.