logo
down
shadow

Number each word with a randomly-colored number


Number each word with a randomly-colored number

By : Alex
Date : November 22 2020, 03:01 PM
This might help you How can I place a number to the left of each word in my document, with each of the numbers being randomly-colored? , try this
you will have to figure out the random number stuff
code :
Option Explicit

Sub IndividualMacros()
    Dim i As Long, w As Range
    i = 1

    Dim aaa As Range
    For Each w In ActiveDocument.Words
        If w.Text Like "*[A-Z,a-z]*" Then
            w.Collapse wdCollapseStart     ' move pointer to before word
            w.InsertBefore i & " "         ' w range contains number and space
        '   w.select                       ' you can use this to see the range
            w.Font.Color = wdColorBlue     ' two ways to color text
            w.Font.ColorIndex = 4
            i = i + 1
        End If
    Next
End Sub


Share : facebook icon twitter icon
How to set a randomly a generated number for a simple guess the number game in HTML 5 and javascript

How to set a randomly a generated number for a simple guess the number game in HTML 5 and javascript


By : George Fulgeanu
Date : March 29 2020, 07:55 AM
it should still fix some issue Your problem is that the variable 'my_no' is undefined because the function 'rnd' does not return anything. Assuming that you need to generate a number between 'From' and 'To' (inclusive), you should change your 'rnd' function like this:
code :
function rnd(from, to) 
{
    /* Returns a random number between from and to (inclusive) */

    return Math.floor((Math.random() * (to - from + 1))) + from;
}
function range() 
{
    var to = parseInt(document.game.to.value);
    var from = parseInt(document.game.from.value);

    count = 0;

    my_no = rnd(from, to);
    document.game.help.value = "Guess a number, enter it, and press Guess.";
}
How can I randomly choose a word over x number of characters from a .txt file and save it to a variable?

How can I randomly choose a word over x number of characters from a .txt file and save it to a variable?


By : Ashwini
Date : March 29 2020, 07:55 AM
I hope this helps . You need the quotation marks since these delimit the string values. After you load the wordlists, you can do simply:
code :
Python 3.6
Type "help", "copyright", "credits" or "license" for more information.

import random
wordlist = []
with open("C:\\Users\\Myname\\Documents\\words.txt") as file:
    for line in file:
        wordlist.append(line)
wordlist = list(map(lambda x : x[:-1], wordlist))
print(random.choice(wordlist))
get a word in a file and add the line number where that word occurs and add that number in list and add to dictionary

get a word in a file and add the line number where that word occurs and add that number in list and add to dictionary


By : AnnyC
Date : March 29 2020, 07:55 AM
hope this fix your issue I am trying to write a function index that takes one parameter, a file name (having a full story), and returns a dictionary where the keys are the words in the file and the values are lists containing the line numbers unique and in ascending order) that these words appear in. , The following should do the trick
code :
def index(filename):
    word_lines = {}
    with open(filename) as file:
        for line_num, line in enumerate(file.readlines(), 1):
            for word in line.split():
                if word in word_lines.keys(): 
                    if line_num not in word_lines[word]:
                        word_lines[word].append(line_num)
                else:
                    word_lines[word] = [ line_num ]
    return word_lines

print(index('test.txt'))
{'Now,': [1], 'by': [1], 'Saint': [1], "Peter's": [1], 'Church': [1], 'and': [1, 5], 'Peter': [1], 'too,': [1], 'He': [2], 'shall': [2], 'not': [2, 6], 'make': [2], 'me': [2], 'there': [2], 'a': [2], 'joyful': [2], 'bride.': [2], 'I': [3, 5, 6], 'wonder': [3], 'at': [3], 'this': [3], 'haste;': [3], 'that': [3, 4], 'must': [3], 'wed': [3], 'Ere': [4], 'he,': [4], 'should': [4], 'be': [4], 'husband,': [4], 'comes': [4], 'to': [4], 'woo.': [4], 'pray': [5], 'you,': [5], 'tell': [5], 'my': [5], 'lord': [5], 'father,': [5], 'madam,': [5], 'will': [6], 'marry': [6], 'yet;': [6], 'and,': [6], 'when': [6], 'do,': [6], 'swear,': [6], 'It': [7], 'sh': [7]}
Read what number the colored number image is to console

Read what number the colored number image is to console


By : user3597028
Date : March 29 2020, 07:55 AM
With these it helps Instead of using Template Matching, a better approach is to use Pytesseract OCR to read the number with image_to_string(). But before performing OCR, you need to preprocess the image. For optimal OCR performance, the preprocessed image should have the desired text/number/characters to OCR in black with the background in white. A simple preprocessing step is to convert the image to grayscale, Otsu's threshold to obtain a binary image, then invert the image. Here's a visualization of the preprocessing step:
Input image -> Grayscale -> Otsu's threshold -> Inverted image ready for OCR
code :
import cv2
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"

# Load image, grayscale, Otsu's threshold, then invert
image = cv2.imread('1.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
invert = 255 - thresh

# Perfrom OCR with Pytesseract
data = pytesseract.image_to_string(invert, lang='eng', config='--psm 6')
print(data)

cv2.imshow('thresh', thresh)
cv2.imshow('invert', invert)
cv2.waitKey()
Select a number randomly and then select a higher number randomly python code?

Select a number randomly and then select a higher number randomly python code?


By : LinLearn
Date : March 29 2020, 07:55 AM
will be helpful for those in need I am trying to build a psychological experiment for my PhD thesis. I am pretty new to python. What I am looking for is that I need to select a number from a list of numbers and then again select a number which should in one case higher than the previous one and in another case lower than the previous one.
Related Posts Related Posts :
  • I can't figure out when it is now exiting my for loop and I get runtime error 28
  • Current date plus time VBA
  • how to place userform basing on a position of a shape
  • Access VBA Criteria of AND and &
  • check if time falls between a range not working
  • How to Print Module Descriptions from VBA?
  • How do i remove commas from an excel file using vba?
  • VBA loop in change event error
  • How to open a DB as read only in vba?
  • switch macro VBA running slow
  • Multi-Field Searching that show results as you type
  • Microsoft Access - Link pictures to database automatically based on folder directory + firstname lastname
  • Sum function in For loop with column changing
  • DCount() In VBA Always Returning A Null Value
  • Writing a date range in access query
  • select value of a dropdown menu (second colume)
  • VBA code calling a stored proc - display message box if no records returned
  • Access Multi-field Search with Results as you type
  • Start Autocad and run VBA automatically with .bat files
  • Access - VBA - Get row number by criteria
  • Unable to get the Sort property of the Range class
  • MS ACCESS: How to lookup environ username in a table in MS Access so that the full name is returned in a textbox?
  • How to remove fractions of seconds from a Date variable?
  • get filename from access attachment
  • Iterating through text and images within a Word Paragraph
  • Add Title to message box with several lines
  • Access VBA to open webpage with SSO requirement
  • Word VBA macro which moves all anchors to top of floating image
  • VBScipt throws exception 80010105
  • Check windows date format using access vba
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org