Search Results

Search found 9273 results on 371 pages for 'complex strings'.

Page 3/371 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Proper indentation for Python multiline strings

    - by ensnare
    What is the proper indentation for Python multiline strings within a function? def method: string = """line one line two line three""" or def method: string = """line one line two line three""" or something else? It looks kind of weird to have the string hanging outside the function in the first example. Thanks.

    Read the article

  • C++ sort array of strings

    - by user69514
    I am trying to sort an array of strings, but it's not sorting anything.... what am I doing wrong? string namesS[MAX_NAMES]; int compare (const void * a, const void * b){ return ( *(char*)a - *(char*)b ); } void sortNames(){ qsort(namesS, MAX_NAMES, sizeof(string), compare); }

    Read the article

  • Clustering Strings on the basis of Common Substrings

    - by pk188
    I have around 10000+ strings and have to identify and group all the strings which looks similar(I base the similarity on the number of common words between any two give strings). The more number of common words, more similar the strings would be. For instance: How to make another layer from an existing layer Unable to edit data on the network drive Existing layers in the desktop Assistance with network drive In this case, the strings 1 and 3 are similar with common words Existing, Layer and 2 and 4 are similar with common words Network Drive(eliminating stop word) The steps I'm following are: Iterate through the data set Do a row by row comparison Find the common words between the strings Form a cluster where number of common words is greater than or equal to 2(eliminating stop words) If number of common words<2, put the string in a new cluster. Assign the rows either to the existing clusters or form a new one depending upon the common words Continue until all the strings are processed I am implementing the project in C#, and have got till step 3. However, I'm not sure how to proceed with the clustering. I have researched a lot about string clustering but could not find any solution that fits my problem. Your inputs would be highly appreciated.

    Read the article

  • Complex query making site extremely slow

    - by Basit
    select SQL_CALC_FOUND_ROWS DISTINCT media.*, username from album as album, album_permission as permission, user as user, media as media , word_tag as word_tag, tag as tag where ((media.album_id = album.album_id and album.private = 'yes' and album.album_id = permission.album_id and (permission.email = '' or permission.user_id = '') ) or (media.album_id = album.album_id and album.private = 'no' ) or media.album_id = '0' ) and media.status = '1' and media.user_id = user.user_id and word_tag.media_id = media.media_id and word_tag.tag_id = tag.tag_id and tag.name in ('justin','bieber','malfunction','katherine','heigl','wardrobe','cinetube') and media.media_type = 'video' and media.media_id not in ('YHL6a5z8MV4') group by media.media_id order by RAND() #there is limit too, by 20 rows.. i dont know where to begin explaining about this query, but please forgive me and ask me if you have any question. following is the explanation. SQL_CALC_FOUND_ROWS is calculating how many rows are there and will be using for pagination, so it counts total records, even tho only 20 is showing. DISTINCT will stop the repeated row to display. username is from user table. album, album_permission. its checking if album is private and if it is, then check if user has permission, by user_id. i think rest is easy to understand, but if you need to know more about it, then please ask. im really frustrated by this query and site is very slow or not opening sometimes cause of this query. please help

    Read the article

  • Complex data types in WCF?

    - by Hojou
    I've run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, 'connection forcibly closed by host'. Is there any way to make this work? I currently have a structure resembling this: pseudo code: Person: IEnumerable<Order> Order: IEnumberable<OrderLine> All three objects have the DataContract attribute and all public properties i want exposed (including the IEnumerable's) have the DataMember attribute. I have multiple OperationContract's on my service and all the methods returning a single object OR an IEnumerable of an object works perfectly. It's only when i try to nest IEnumerable that it turns bad. Also in my client service reference i picked the generic list as my collection type. I just want to emphasize, only one of my operations/methods fail with this error - the rest of them work perfectly. EDIT (more detailed error description): [SocketException (0x2746): An existing connection was forcibly closed by the remote host] [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.] [WebException: The underlying connection was closed: An unexpected error occurred on a receive.] [CommunicationException: An error occurred while receiving the HTTP response to http://myservice.mydomain.dk/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.] I tried looking for logs but i can't find any... also i'm using a WSHttpBinding and an http endpoint.

    Read the article

  • SQL complex Question

    - by santanu
    Hello All, I need to find a function. the scenario is : I have 2 table. 1. news table 2. news_comment table need to find the most commented 20 news. the news_comment table has the relationship with the news table Thank you

    Read the article

  • Parsing Complex Text File with C#

    - by David
    Hello, I need to parse a text file that has a lot of levels and characters. I've been trying different ways to parse it but I haven't been able to get anything to work. I've included a sample of the text file I'm dealing with. Any suggestions on how I can parse this file? I have denoted the parts of the file I need with TEXTINEED. (bean name: 'TEXTINEED context: (list '/text '/content/home/left-nav/text '/content/home/landing-page) type: '/text/types/text module: '/modules/TEXTINEED source: '|moretext| ((contents (list (list (bean type: '/directory/TEXTINEED ((directives (bean ((chartSize (list 600 400)) (showCorners (list #f)) (showColHeader (list #f)) (showRowHeader (list #f))))))) (bean type: '/directory/TEXTINEED ((directives (bean ((displayName (list "MTD")) (showCorners (list #f)) (showColHeader (list #f)) (showRowLabels (list #f)) (hideDetailedLink (list #t)) (showRowHeader (list #f)) (chartSize (list 600 400))))))) (bean type: '/directory/TEXTINEED ((directives (bean ((displayName (list "QTD")) (showCorners (list #f)) (showColHeader (list #f)) (showRowLabels (list #f)) (hideDetailedLink (list #t)) (showRowHeader (list #f)) (chartSize (list 600 400)))))))) Thanks!

    Read the article

  • SQL Complex Select - Trouble forming query

    - by JoshSpacher
    I have three tables, Customers, Sales and Products. Sales links a CustomerID with a ProductID and has a SalesPrice. select Products.Category, AVG(SalePrice) from Sales inner join Products on Products.ProductID = Sales.ProductID group by Products.Category This lets me see the average price for all sales by category. However, I only want to include customers that have more than 3 sales records or more in the DB. I am not sure the best way, or any way, to go about this. Ideas?

    Read the article

  • Create a complex SQL query?

    - by mazzzzz
    Hey guys, I have a program that allows me to run queries against a large database. I have two tables that are important right now, Deposits and withdraws. Each contains a history of every user. I need to take each table, add up every deposit and withdraws (per user), then subtract the withdraws from the deposits. I then need to return every user whos result is negative (aka they withdrew more then they deposited). Is this possible in one query? Example: Deposit Table: |ID|UserName|Amount| |1 | Use1 |100.00| |2 | Use1 |50.00 | |3 | Use2 |25.00 | |4 | Use1 | 5.00 | WithDraw Table: |ID|UserName|Amount| |2 | Use2 | 5.00 | |1 | Use1 |100.00| |4 | Use1 | 5.00 | |3 | Use2 |25.00 | So then the result would output: |OverWithdrawers| | Use2 | Is this possible (I sure don't know how to do it)? Thanks for any help, Max

    Read the article

  • C#: Efficiently search a large string for occurences of other strings

    - by Jon
    Hi, I'm using C# to continuously search for multiple string "keywords" within large strings, which are = 4kb. This code is constantly looping, and sleeps aren't cutting down CPU usage enough while maintaining a reasonable speed. The bog-down is the keyword matching method. I've found a few possibilities, and all of them give similar efficiency. 1) http://tomasp.net/articles/ahocorasick.aspx -I do not have enough keywords for this to be the most efficient algorithm. 2) Regex. Using an instance level, compiled regex. -Provides more functionality than I require, and not quite enough efficiency. 3) String.IndexOf. -I would need to do a "smart" version of this for it provide enough efficiency. Looping through each keyword and calling IndexOf doesn't cut it. Does anyone know of any algorithms or methods that I can use to attain my goal?

    Read the article

  • Searching within an array of strings...

    - by SoLoGHoST
    Ok, I'm feeling retarded here, I have a string like so: $string = 'function module_testing{'; or it could be like this: $string = 'function module_testing'; And than I have an array of strings like so: $string_array = array('module_testing', 'another_function', 'and_another_function'); Now, is there some sort of preg_match that I can do to test if any of the $string_array values are found within the $string string at any given position? So in this situation, there would be a match. Or is there a better way to do this? I can't use in_array since it's not an exact match, and I'd rather not do a foreach loop on it if I can help it, since it's already in a while loop. Thanks :)

    Read the article

  • C++: use array of strings wrapped in namespace?

    - by John D.
    I got the following code, wishing to wrap a group of strings nicely in a namespace: namespace msgs { const int arr_sz = 3; const char *msg[arr_sz] = {"blank", "blank", "blank" }; msg[0] = "Welcome, lets start by getting a little info from you!\n"; msg[1] = "Alright, bla bla bla.."; msg[2] = "etc."; } The code inside works nicely inside a function, but I don't know how to return an array from it. The namespace idea LOOKS fine, but it returns on the last three lines: error: expected constructor, destructor, or type conversion before ‘=’ token Why can't I define the array inside a namespace, do I need to do something first? It's nice because I can call it like printf(msgs::msg[1]) etc. I want to do this I just can't wrap my head around what's wrong :(

    Read the article

  • Switch-Case for strings in Javascript not working as expected

    - by Coltin
    So I have this problem with strings and switch-case, and I'll try to keep it as simple as possible. Here event.keyCode has the value "65", and is the result of a keydown event of 'a' (using JQuery). if (event.keyCode == "65") { alert("hmmmm"); } That works, but: switch (event.keyCode) { case '65': alert("Yay!"); break; } That doesn't. However this will work: switch ('65') { case '65': alert("Yay!"); break; } And if I do this: var t = '65'; switch (t) { case '65': alert("Yay!"); break; } It works. And then I tried this: var t = event.keyCode; switch (t) { case '65': alert("Yay!"); break; } But it fails! So why does it match in the if-block at the beginning, but not for the switch-case?

    Read the article

  • Linked List Sorting with Strings In C

    - by user308583
    I have a struct, with a Name and a single Node called nextName It's a Singly Linked list, and my task is to create the list, based on alphabetical order of the strings. So iff i enter Joe Zolt and Arthur i should get my list structured as Joe Than Joe Zolt Than Arthur Joe Zolt I'm having trouble implementing the correct Algorithm, which would put the pointers in the right order. This is What I have as of Now. Temp would be the name the user just entered and is trying to put into the list, namebox is just a copy of my root, being the whole list if(temp != NULL) { struct node* namebox = root; while (namebox!=NULL && (strcmp((namebox)->name,temp->name) <= 0)) { namebox = namebox->nextName; printf("here"); } temp->nextName = namebox; namebox = temp; root = namebox; This Works right now, if i enter names like CCC BBB than AAA I Get Back AAA BBB CCC when i print But if i put AAA BBB CCC , When i print i only get CCC, it cuts the previous off.

    Read the article

  • Numpy: Creating a complex array from 2 real ones?

    - by Duncan Tait
    I swear this should be so easy... Why is it not? :( In fact, I want to combine 2 parts of the same array to make a complex array: Data[:,:,:,0] , Data[:,:,:,1] These don't work: x = np.complex(Data[:,:,:,0], Data[:,:,:,1]) x = complex(Data[:,:,:,0], Data[:,:,:,1]) Am I missing something? Does numpy not like performing array functions on complex numbers? Here's the error: TypeError: only length-1 arrays can be converted to Python scalars Cheers

    Read the article

  • Passing List of Strings or Array of strings into Unity Injection Constructor (Config-Based)

    - by miguel
    I cannot seem to get unity working when attempting to pass in an array of strings into a constructor parameter list, while using XML configuration. When I try the following: <typeConfig ...> <constructor ...> <param ... parameterType="System.String[]"> <array> <value.../> <value.../> </array> </param> </constructor> </typeConfig> for a c'tor which looks like this: void Foo(string[] inputParams_){ ... } It always fails in Unity's FindConstructor(...) method stating that it cannot find a c'tor mathcing the parameter type of String.String Does anyone know how to pass an array of stings successfully into this type of c'tor? If not, how can I do so with a list of strings, if the c'tor were to accept an IList? Thanks!

    Read the article

  • Strings in array are no longer strings after jQuery.each()

    - by Álvaro G. Vicario
    I'm pretty confused with the behaviour of arrays of strings when I loop them through the jQuery.each() method. Apparently, the strings become jQuery objects inside the callback function. However, I cannot use the this.get() method to obtain the original string; doing so triggers a this.get is not a function error message. I suppose the reason is that it's not a DOM node. I can do $(this).get() but it makes my string become an array (from "foo" to ["f", "o", "o"]). How can I cast it back to string? I need to get a variable of String type because I pass it to other functions that compare the values among them. I enclose a self-contained test case (requires Firebug's console): <!DOCTYPE html> <html> <head><title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"><!-- $(function(){ var foo = []; var $foo = $(foo); foo.push("987"); $foo.push("987"); foo.push("654"); $foo.push("654"); $.each(foo, function(i){ console.log("foo[%d]: object=%o; value=%s; string=%o", i, this, this, $(this).get()); // this.get() does not exist }); $foo.each(function(i){ console.log("$foo[%d]: object=%o; value=%s; string=%o", i, this, this, $(this).get()); // this.get() does not exist }); }); //--></script> </head> <body> </body> </html>

    Read the article

  • Reading strings and integers from .txt file and printing output as strings only

    - by screename71
    Hello, I'm new to C++, and I'm trying to write a short C++ program that reads lines of text from a file, with each line containing one integer key and one alphanumeric string value (no embedded whitespace). The number of lines is not known in advance, (i.e., keep reading lines until end of file is reached). The program needs to use the 'std::map' data structure to store integers and strings read from input (and to associate integers with strings). The program then needs to output string values (but not integer values) to standard output, 1 per line, sorted by integer key values (smallest to largest). So, for example, suppose I have a text file called "data.txt" which contains the following three lines: 10 dog -50 horse 0 cat -12 zebra 14 walrus The output should then be: horse zebra cat dog walrus I've pasted below the progress I've made so far on my C++ program: #include <fstream> #include <iostream> #include <map> using namespace std; using std::map; int main () { string name; signed int value; ifstream myfile ("data.txt"); while (! myfile.eof() ) { getline(myfile,name,'\n'); myfile >> value >> name; cout << name << endl; } return 0; myfile.close(); } Unfortunately, this produces the following incorrect output: horse cat zebra walrus If anyone has any tips, hints, suggestions, etc. on changes and revisions I need to make to the program to get it to work as needed, can you please let me know? Thanks!

    Read the article

  • Good way to extract strings to resource

    - by Bart Friederichs
    I am using Visual Studio 2010 and we just decided to get started on localization of our code. We want to use the per-form resource file in combination with a separate resource file for static strings, called strings.resx. I was wondering if there is a good way to extra static strings (we already have quite some code we need to translate) to the strings.resx file? I have tried this plugin: Resource Refactoring 2010, but it doesn't work completely. It creates the correct new resource, but the strings aren't refactored in the code. Also, the tool seems to be abandoned by its developer. Is there a good plugin that can do this?

    Read the article

  • casting raw strings python

    - by dave
    in python, given a variable which holds a string is there a quick way to cast that into another raw string variable? the following code should illustrate what im after... def checkEqual(x, y): print True if x==y else False line1 = "hurr..\n..durr" line2 = r"hurr..\n..durr" line3 = "%r"%line1 print "%s \n\n%s \n\n%s \n" % (line1, line2, line3) checkEqual(line2, line3) #outputs False checkEqual(line2, line3[1:-1]) #outputs True The closest I have found so far is the %r formatting flag which seems to return a raw string albeit within single quote marks. Is there any easier way to do this like a line3 = raw(line1) kind of thing?

    Read the article

  • How to append strings using sprintf ?

    - by rejinacm
    Hey everybody, Thank you all before I start. I am facing a serious issue with sprintf. suppose my code snippet is : sprintf(Buffer,"Hello World"); sprintf(Buffer,"Good Morning"); sprintf(Buffer,"Good Afternoon"); . . . Some hundred sprints.... If i do like this, its getting overwritten. How can I avoid overwritting using sprintf. If i give a printf at the end i want to see all the lines. How to xchieve this.

    Read the article

  • Value isnt being saved in the strings

    - by Raptrex
    I'm trying to make a class where I put a key and value into the put method which puts the key in the k string array and value into the v string array, however it is not being saved in the array when I do get or display. For example: put(dan,30) get(dan) returns null display returns null null 10 times. Anyone know whats wrong? public class Memory { final int INITIAL_CAPACITY = 10; String[] k = new String[INITIAL_CAPACITY]; String[] v = new String[INITIAL_CAPACITY]; int count = 0; public Memory() { count = 0; } public int size() { return count; } public void put(String key, String value) { int a = 0; boolean found = false; for (int i = 0; i < k.length; i++) { //System.out.println("key is " + key.equals(k[i])); if (key.equalsIgnoreCase(k[i])) { v[i] = value; found = true; } if (found) break; a++; } //System.out.println(a == k.length); if (a == k.length); { k[count] = key; v[count] = value; //System.out.println(k[count] + " " + v[count]); count++; //System.out.println(count); } } public String get(String key) { String output = "a"; for(int i = 0; i < k.length; i++) { if(!key.equalsIgnoreCase(k[i])) { output = null; } else { output = v[i]; return output; } } return output; } public void clear() { for (int i = 0; i < k.length; i++) { k[i] = null; v[i] = null; } count = 0; } public void display() { for (int i = 0; i < k.length; i++) { System.out.println(k[i] + " " + v[i]); } } }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >