Im writing a php script to compare the similarity of 2 strings. This works pretty good at the moment, but what I would like to do is match words when one is a synonym of the first.
Any thoughts?
So far i have this, which prints out every word in my list, but i am trying to print only one word at random. Any suggestions?
def main():
# open a file
wordsf = open('words.txt', 'r')
word=random.choice('wordsf')
words_count=0
for line in wordsf:
word= line.rstrip('\n')
print(word)
words_count+=1
# close the file
wordsf.close()
I'd like to script, preferably in rake, the following actions into a single command:
Get the version of my local git repository.
Git pull the latest code.
Git diff from the version I extracted in step #1 to what is now in my local repository.
In other words, I want to get the latest code form the central repository and immediately generate a diff of what's changed since the last time I pulled.
Hi all,
on Android, there's a Canvas class that represents a drawing surface. It has a clipping rect. Question - are the rect's right and bottom borders inclusive or exclusive? In other words - if the rect is (0, 0)-(10, 10), will the Canvas allow drawing in pixels at coordinates 10?
df <- data.frame(var1=c('a', 'b', 'c'), var2=c('d', 'e', 'f'), freq=1:3)
What is the simplest way to expand the first two columns of the data.frame above, so that
each row appears the number of times specified in the column 'freq'?
In other words, go from this:
>df
var1 var2 freq
1 a d 1
2 b e 2
3 c f 3
To this:
>df.expanded
var1 var2
1 a d
2 b e
3 b e
4 c f
5 c f
6 c f
I am close but I am not sure what to do with the restuling match object. If I do
p = re.search('[/@.* /]', str)
I'll get any words that start with @ and end up with a space. This is what I want. However this returns a Match object that I dont' know what to do with. What's the most computationally efficient way of finding and returning a string which is prefixed with a @?
For example,
"Hi there @guy"
After doing the proper calculations, I would be returned
guy
Is it possible to configure gedit to treat the underscore character as a word character?
Currently, it appears that the editor treats "two_words" as two separate words when selecting, instead of a single word as in many other mainstream text editors.
Hi,
Question related to PHP memory-handling from someone not yet very experienced in PHP:
If I set a PHP session variable of a particular name, and then set a session variable of the exact same name elsewhere (during the same session), is the original variable over-written, or does junk accumulate in the session?
In other words, should I be destroying a previous session variable before creating a new one of the same name?
Thank you.
I'm new to SOA (and to Stack Overflow too...)
Some services and web applications we are developing must all log audit information. We are considering an audit service for this. Is there any SOA governing principal that should make me think twice about having one of the services call the audit service to log information? A service-to-service call in other words?
In other words - what would be a good name for a variable that references the currently logged user?
I've come up with a few:
logged_user
visitor
me
I'm not convinced either of them is good enough though.
I am trying to figure out the exact meaning of the words Covariance and Contravariance from several articles online and questions on StackOverflow, and from what I can understand, it's only another word for polymorphism.
Am I correct with the above statement? Or have I got it wrong ?
I have a style rule I want to apply to a tag when it has TWO styles. Is there any way to perform this without javascript? In other words..
<li class='left ui-class-selector'>
I want to select only if the li has both 'left' and 'ui-class-selector' classes applied.
hello everyone!
I'm trying to find the best way to display images inside of UILabels (in fact, I wouldn't mind switching to something other than UILabel if it supports images with no hassle)
The scenario is:
I have a table view with hundreds of cells and UILabel being the main component of each cell
The text I assign to each cell contains sequences of characters that need to be parsed out and represented as an image
In simpler words, imagine a TableView of an instant messenger that parses replaces all ":)", ":(", ":D" etc with corresponding smiley images
Any input would be greatly appreciated!
We are using recaptcha ASP.NET control:
http://recaptcha.net/plugins/aspnet/
However, we find that in some situations, recaptcha accepts answers which are clearly wrong.
For example, recaptcha provided these words:
of purser
The tester typed in the following:
o purser
..but Page.IsValid returned true! Is this a known issue with recaptcha?
I've already found how to capitalize all words of the sentence, but not the first word only.
NSString *txt =@"hi my friends!"
[txt capitalizedString];
I don't want to change to lower case and capitalize the first char. I'd like to capitalize the first word only without change the others.
I'm trying to get the MIME type of an <input type="file" /> element using Perl, but without actually examining the contents of the file itself, In other words, just using the HTTP headers.
I have only been able to get the "multipart/form-type" Content-Type value, but my understanding is that each element will get its own MIME Type?
How can I see the sub-MIME types using Perl?
Hey folks,
does serialization in Java always have to shrink the memory that is used to hold an object structure? Or is it likely that serialization will have higher costs?
In other words: Is serialization a tool to shrink the memory footprint of object structures in Java?
Hey everyone,
I'm wondering how I can hook up an input type=file to send a picture back to a backend servlet that will eventually be stored in a MySQL database as a BLOB? In other words, how can I upload a picture using the input and send that back to the servlet to insert into the database as a BLOB type?
Thanks
Hi, I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it?
IF you supply a list of strings to an edit control and set the autocomplete mode and source then you automatically get auto complete functionality. My question is can I get the same functioanlity in .NET somewhere without a control. In other words I want something like
string[] ProgressivePartialMatch( string[] Strings, string MatchText )
and so I want the strings back that would have showed up in the auto complete so to speak
I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words:
For example:
string = 'Apples, Bananas, Grapes, Oranges'
subtraction = 'Bananas'
result = 'Apples, Grapes, Oranges'
Also, a way to do this but while maintaining IDs:
string = '1:Apples, 4:Bananas, 6:Grapes, 23:Oranges'
subtraction = '4:Bananas'
result = '1:Apples, 6:Grapes, 23:Oranges'
Sample code is greatly appreciated. Thank you so much.
hello I want to make a magnifying glass on a picture so that the part of picture is extended ? in other words i want to find a easy method to create the illusion of a magnifying glass,I know ShapeDrawable and BitmapShader(Bitmap, Shader.TileMode.REPEAT,
Shader.TileMode.REPEAT) is useful,but I donot konw how tu du it.
AS http://i3.6.cn/cvbnm/72/60/36/73dfcc8862020e9ed366a55e72e88883.jpg
could you give me some code or sample? thank you
Using LINQ I'm looking to break down the following path string[], however I'd like to break it up to the point of the Binn folder. Is there a WHERE UNTIL operator in LINQ?
c:\ Program Files\ Microsoft SQL
Server\ MSSQL10.SQLEXPRESS\ MSSQL\
Binn\ sqlservr.exe
What I'd like todo
var words = from word in thepath
where UNTIL thepath == "Binn"
select word;
I have a text file which contains words separated by space. I want to take each word from the file and store it. So i have opened the file but am unsure how to assign the word to a char.
FILE *fp;
fp = fopen("file.txt", "r");
//then i want
char one = the first word in the file
char two = the second word in the file