Convert number to corresponding words [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to develop a piece of code that converts a number to the corresponding words, e.g. 1 -> "One", 2 -> "Two"
Is there any function in Python to do this task?

The answer to this question is "no". There is no function in Python to do this task.
If you "have to develop code to do it" (your words), then using a builtin wouldn't really be a valid solution, perhaps?
If you have to develop code to do it, you need better specifications. Do you have to be able to just do 0..9, or any cardinal number, or any number at all? (floating point? decimal? negative?). Why do you have to develop this code? Is it homework, or some special purpose?
If you just have to do 0..9, then as mentioned in comments, you should use a dictionary. Take care of case of the input.
If you have to do anything more than that, looking at the implementation of num2word would certainly be educational.

Related

How to Detect Near-Duplicates from a List of Text? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a list of 90K Text Lines. I want to find near-duplicates from them and mark them as duplicates. How can I do this using Python?
You need to define what you mean by "near duplicate". If I were to guess, one possible definition of two lines of text being "near duplicates" would be that they have a low Levenshtein distance. One popular Python implementation seems to be this one, but I cannot vouch for it myself.
If that is an acceptable definition, then you can simply compute all pairwise Levenshtein distances between your text lines and mark those below a given threshold.

How to display movies on a grid with code [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to play a bunch of movies on a grid let's say of dimension (n, n), where each movie m_ij is an element of the grid. I would like to decide which movie is positioned where on the grid at each second, i.e. movies can switch positions over time. How would one start to do this? I'd preferably use Python, but am open to use another language if appropriate. Thanks a lot for any help, it's for an art project.
I know you prefer Python but first think I can think of to achieve something like that easily would be through using this JavaScript library called p5js or processing which is same library written in Java. It is very good for doing art with code kinda thing.
Here is a video to give you the idea.
Anyways hope this helps. Cheers.

How can I find a good distracter for a key using python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
What I am trying to do is to create a Multiple Choice Question (MCQ) generation to our fill in the gap style question generator. I need to generate distracters (Wrong answers) from the Key (correct answer). The MCQ is generated from educational texts that users input. We're trying to tackle this through combining Contextual similarity, similarity of the sentences in which the keys and the distractors occur in and Difference in term frequencies Any help? I was thinking of using big data datasets to generate related distractors such as the ones provided by google vision, I have no clue how to achieve this in python.
This question is way too broad to be answered, though I would do my best to give you some pointers.
If you have a closed set of potential distractors, I would use word/phrase embedding to find the closest distractor to the right answer.
Gensim's word2vec is a good starting point in python
If you want your distractors to follow a template, for example replace a certain word from the right answer with its opposite, I would use nltk's wordnet implementation to find antonyns / synonyms.

Python, efficiently and easily substitute parts on very long string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a big file with some format. I want to substitute some items in the string by others, the string is long (like a big XML but with no format).
I know where they are, i could locate them by using a regular expression for each, but i wonder which is the best method, easier and better if its the most efficient way.
format/% already searches the string for parameter placeholders internally. Since they're implemented in C, you're not gonna beat their performance with Python code even if your search and replace workload is somewhat simpler. See Faster alternatives to numpy.argmax/argmin which is slow for a glance on C to Python relative performance.

Difference beetween C arrays and Python lists [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I ask this because i'm a beginner in CS and i have this doubt. So it would be nice if peeps try to explain instead of just make humor or downvote. I tought this site was for learning from others.
Is just a different name or there something different underlying it?
Can anyone briefly explain the difference beetween C arrays and Python lists?
A Python list is essentially an array of object references that keeps track of how many elements it contains.
(Conceptually, a Python reference is somewhat similar to a C pointer.)
Read more here: Internals of Python list, access and resizing runtimes

Categories

Resources