Search Results

Search found 5105 results on 205 pages for 'words'.

Page 9/205 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Function for counting characters/words not working

    - by user1742729
    <!DOCTYPE HTML> <html> <head> <title> Javascript - stuff </title> <script type="text/javascript"> <!-- function GetCountsAll( Wordcount, Sentancecount, Clausecount, Charactercount ) { var TextString = document.getElementById("Text").innerHTML; var Wordcount = 0; var Sentancecount = 0; var Clausecount = 0; var Charactercount = 0; // For loop that runs through all characters incrementing the variable(s) value each iteration for (i=0; i < TextString.length; i++); if (TextString.charAt(i) == " " = true) Wordcount++; return Wordcount; if (TextString.charAt(i) = "." = true) Sentancecount++; Clausecount++; return Sentancecount; if (TextString.charAt(i) = ";" = true) Clausecount++; return Clausecount; } --> </script> </head> <body> <div id="Text"> It is important to remember that XHTML is a markup language; it is not a programming language. The language only describes the placement and visual appearance of elements arranged on a page; it does not permit users to manipulate these elements to change their placement or appearance, or to perform any "processing" on the text or graphics to change their content in response to user needs. For many Web pages this lack of processing capability is not a great drawback; the pages are simply displays of static, unchanging, information for which no manipulation by the user is required. Still, there are cases where the ability to respond to user actions and the availability of processing methods can be a great asset. This is where JavaScript enters the picture. </div> <input type = "button" value = "Get Counts" class = "btnstyle" onclick = "GetCountsAll()"/> <br/> <span id= "Charactercount"> </span> Characters <br/> <span id= "Wordcount"> </span> Words <br/> <span id= "Sentancecount"> </span> Sentences <br/> <span id= "ClauseCount"> </span> Clauses <br/> </body> </html> I am a student and still learning JavaScript, so excuse any horrible mistakes. The script is meant to calculate the number of characters, words, sentences, and clauses in the passage. It's, plainly put, just not working. I have tried a multitude of things to get it to work for me and have gotten a plethora of different errors but no matter what I can NOT get this to work. Please help! (btw i know i misspelled sentence)

    Read the article

  • Hashing words to numbers with respect to definition

    - by thornate
    As part of a larger project, I need to read in text and represent each word as a number. For example, if the program reads in "Every good boy deserves fruit", then I would get a table that converts 'every' to '1742', 'good' to '977513', etc. Now, obviously I can just use a hashing algorithm to get these numbers. However, it would be more useful if words with similar meanings had numerical values close to each other, so that 'good' becomes '6827' and 'great' becomes '6835', etc. As another option, instead of a simple integer representing each number, it would be even better to have a vector made up of multiple numbers, eg (lexical_category, tense, classification, specific_word) where lexical_category is noun/verb/adjective/etc, tense is future/past/present, classification defines a wide set of general topics and specific_word is much the same as described in the previous paragraph. Does any such an algorithm exist? If not, can you give me any tips on how to get started on developing one myself? I code in C++.

    Read the article

  • Google App Engine (python): TemplateSyntaxError: 'for' statements with five words should end in 'rev

    - by Phil
    This is using the web app framework, not Django. The following template code is giving me an TemplateSyntaxError: 'for' statements with five words should end in 'reversed' error when I try to render a dictionary. I don't understand what's causing this error. Could somebody shed some light on it for me? {% for code, name in charts.items %} <option value="{{code}}">{{name}}</option> {% endfor %} I'm rendering it using the following: class GenerateChart(basewebview): def get(self): values = {"datepicker":True} values["charts"] = {"p3": "3D Pie Chart", "p": "Segmented Pied Chart"} self.render_page("generatechart.html", values) class basewebview(webapp.RequestHandler): ''' Base class for all webapp.RequestHandler type classes ''' def render_page(self, filename, template_values=dict()): filename = "%s/%s" % (_template_dir, filename) path = os.path.join(os.path.dirname(__file__), filename) self.response.out.write(template.render(path, template_values))

    Read the article

  • How to add words to an already loaded grammar using System.Speech and SAPI 5.3

    - by Kim Major
    Given the following code, Choices choices = new Choices(); choices.Add(new GrammarBuilder(new SemanticResultValue("product", "<product/>"))); GrammarBuilder builder = new GrammarBuilder(); builder.Append(new SemanticResultKey("options", choices.ToGrammarBuilder())); Grammar grammar = new Grammar(builder) { Name = Constants.GrammarNameLanguage}; grammar.Priority = priority; _recognition.LoadGrammar(grammar); How can I add additional words to the loaded grammar? I know this can be achieved both in native code and using the SpeechLib interop, but I prefer to use the managed library. Update: What I want to achieve, is not having to load an entire grammar repeatedly because of individual changes. For small grammars I got good results by calling _recognition.RequestRecognizerUpdate() and then doing the unload of the old grammar and loading of a rebuilt grammar in the event: void Recognition_RecognizerUpdateReached(object sender, RecognizerUpdateReachedEventArgs e) For large grammars this becomes too expensive.

    Read the article

  • Building dictionary of words from large text

    - by LiorH
    I have a text file containing posts in English/Italian. I would like to read the posts into a data matrix so that each row represents a post and each column a word. The cells in the matrix are the counts of how many times each word appears in the post. The dictionary should consist of all the words in the whole file or a non exhaustive English/Italian dictionary. I know this is a common essential preprocessing step for NLP. Does anyone know of a tool\project that can perform this task? Someone mentioned apache lucene, do you know if lucene index can be serialized to a data-structure similar to my needs?

    Read the article

  • Python KMeans clustering words

    - by sadawd
    Dear Everyone I am interested to perform kmeans clustering on a list of words with the distance measure being Leveshtein. 1) I know there are a lot of frameworks out there, including scipy and orange that has a kmeans implementation. However they all require some sort of vector as the data which doesn't really fit me. 2) I need a good clustering implementation. I looked at python-clustering and realize that it doesn't a) return the sum of all the distance to each centroid, and b) it doesn't have any sort of iteration limit or cut off which ensures the quality of the clustering. python-clustering and the clustering algorithm on daniweb doesn't really work for me. Can someone find me a good lib? Google hasn't been my friend

    Read the article

  • Mapping words to numbers with respect to definition

    - by thornate
    As part of a larger project, I need to read in text and represent each word as a number. For example, if the program reads in "Every good boy deserves fruit", then I would get a table that converts 'every' to '1742', 'good' to '977513', etc. Now, obviously I can just use a hashing algorithm to get these numbers. However, it would be more useful if words with similar meanings had numerical values close to each other, so that 'good' becomes '6827' and 'great' becomes '6835', etc. As another option, instead of a simple integer representing each number, it would be even better to have a vector made up of multiple numbers, eg (lexical_category, tense, classification, specific_word) where lexical_category is noun/verb/adjective/etc, tense is future/past/present, classification defines a wide set of general topics and specific_word is much the same as described in the previous paragraph. Does any such an algorithm exist? If not, can you give me any tips on how to get started on developing one myself? I code in C++.

    Read the article

  • Wrap words in tags, keep markup

    - by spacevillain
    For example I have a string with markup (from html node): hello, this is dog "h<em>e<strong>llo, thi</strong>s i</em><strong>s d</strong>og" What is the most correct way to find some words in it (let's say "hello" and "dog"), wrap them in a span (make a highlight) and save all the markup? Desired output is something like this (notice properly closed tags) <span class="highlight">h<em>e<strong>llo</strong></em></span><strong>,</strong> <em><strong>thi</strong>s<em> i</em><strong>s <span class="highlight"><strong>d</strong>og</span> Looks the same as it should: hello, this is dog

    Read the article

  • Highlite words from searchstring

    - by Bundy
    Hi, I wrote a little search script for a client, it works and words get highlited, BUT... Imagine this situation: search term: test found result: Hello this <a href="/news/this-is-a-test">is a test</a> In this example both 'test' in the href part and between the <a> tags get highlited, breaking the link. How could I prevent this? Edit: So this is what I need: A regex replace function that replaces all matched search strings EXCEPT the ones that are located inside a href attribute Greets, nick

    Read the article

  • Fastest PHP Routine To Match Words

    - by Volomike
    What is the fastest way in PHP to take a keyword list and match it to a search result (like an array of titles) for all words? For instance, if my keyword phrase is "great leather shoes", then the following titles would be a match... Get Some Really Great Leather Shoes Leather Shoes Are Great Great Day! Those Are Some Cool Leather Shoes! Shoes, Made of Leather, Can Be Great ...while these would not be a match: Leather Shoes on Sale Today! You'll Love These Leather Shoes Greatly Great Shoes Don't Come Cheap I imagine there's some trick with array functions or a RegEx (Regular Expression) to achieve this rapidly.

    Read the article

  • Show surrounding words when searching for a specific word in a text file (Ruby)

    - by Ezra
    Hi, I'm very new to ruby. I'm trying to search for any instance of a word in a text file (not the problem). Then when the word is discovered, it would show the surrounding text (maybe 3-4 words before and after the target word, instead of the whole line), output to a list of instances and continue searching. Example "The quick brown fox jumped over the lazy dog." Search word = "jumped" Output = "...brown fox jumped over the..." Any help is appreciated. Thanks! Ezra def word_exists_in_file f = File.open("test.txt") f.each do line print line if line.match /someword/ return true end end false end

    Read the article

  • Extract words from sentence(s) using TSQL

    - by Newbie
    I have the following input. INPUT: TableA ID Sentences --- ---------- 1 I am a student 2 Have a nice time guys! What I need to do is to extract the words from the sentence(s) and insert each individual word in another table OUTPUT: SentenceID WordOccurance Word ---------- ------------ ----- 1 1 I 1 2 am 1 3 a 1 4 student 2 1 Have 2 2 a 2 3 nice 2 4 time 2 5 guys! I am using SQL Server 2005. My fruitless approach so far is ;With numCTE As ( Select rn = 1 Union all Select rn+1 from numCTE where rn<1000) , getWords As ( Select rn, ID, indiChars From numCTE Cross Apply(Select ID, indiChars = Substring(Sentences,1,rn) From inputTbl)x where indiChars <> '' ) Select Id, Word = stuff(select ',' + cast(indiChars) from getWords g1 where g1.Id = g2.Id for xml path(''),'',1,1)x from getWords g2 Group by g2.Id I am looking for a set based solution. Thanks

    Read the article

  • Putting curly braces in a sentences for specific words according to their start and end indexes

    - by Suneeta Singh
    I need to put curly braces in a sentence according to the indexes. Suppose my input sentence is: "I am a girl and I live in Nepal." and I need to put curly braces according to [12, 15], [2, 4], [23, 25] These indexes are corresponding to the words "am", "and" and "in" respectively. The required output should be: "I {am} a girl {and} I live {in} Nepal." I have tried using substring but after it replaces first word, it then shifts the characters by two indexes and that is the problem I am having. Can anyone provide me solution to get the required output?

    Read the article

  • In few words, what can be said about Func<>

    - by Richard77
    Hello, I've been seing Func< for sometime now, and I've manage to avoid it (for now). But, now it looks like I can't dodge it forever. For instance, I tried Dynamic Linq, but almost everything was in terms of Func<. I've tried one of my book (C# 2008/Deitel&Deitel) and also MSDN but I'm not getting it yet. They all jump straight in the subject. What can be said (in few words) about Func< Can I get some links on the web that can get me started on that matter? Thanks for helping

    Read the article

  • Need help in sorting the programming buzz-words

    - by cwap
    How do you sort out the good buzz from the bad buzz? - I really need your help here :) I see a lot of buzz-words nowadays, both here on SO and in school. For example, we had a teacher who everyone respected, who said "be careful about gold-plating and death-by-interfacing". Now, everyone and their mama cries whenever I'm creating an interface.. Another example would be here on SO where lately "premature optimization is the root of all evil", so everytime someone asks a perfomance question, he'll get that sentence thrown in his face. A few months ago I remember it was all about NHibernate in here, etc., etc... These things comes and goes, but only the good buzz stays. Now, how do you seperate the good from the bad? By reading blogs from respected persons? By trying to come to a conclusion on your own, and then try to convince others that you're right? By simply ignoring it?

    Read the article

  • haskell. words into binary numbers

    - by Katja
    I need to convert words into binary numbers. With a bit help of yours I got this blCo::String -> Integer blCo x = num2bin(lett2num x) blCo (x:xs) | x:xs = num2bin(lett2num x):blCo xs num2lett :: Int -> Char num2lett n | (n <= ord 'A') && (n <= ord 'Z') = chr(ord 'A'+ n - 1) | (n <= ord 'a') && (n <= ord 'Z') = chr(ord 'A'+ n - 1) num2bin :: Integer -> String num2bin n | n >= 0 = concatMap show (reverse ( n2b n)) | otherwise = error "num2bin: negative number" where n2b 0 = [] n2b n = n `mod` 2 : n2b (n `div` 2) he tells me a mistake.I dont undertsand it mistake: Couldn't match expected type `Char' against inferred type `String' In the first argument of `lett2num', namely `x' In the first argument of `num2bin', namely `(lett2num x)' In the expression: num2bin (lett2num x)

    Read the article

  • mod_rewrite rule for all urls except ones with some words

    - by zlog
    How do I write a mod_rewrite regulare expression rule that is the opposite of this: ^(.+)/path/(page1|page2)+$ ie, I want all pages except blah/path/page1 and blah/path/page2 to redirect to another path, where the x in blah/path/x is used in the new path. For example, I'd like write a rewrite rule like: RewriteRule some_regex /index.php?path/show/$1 [L] where some_regex would pull out the last component of a url in the format: /something/path/some_param to redirect to /index.php/path/show/some_param I'm trying to use ! and [^] syntax, but I don't quite understand how these work, especially when they involve words not single characters.

    Read the article

  • Reading in multiple words for prolog

    - by prolog123456789
    Im running prolog via poplog on unix and was wondering if there was a way to read in multiple words (such as encase it into a string). For instance, read(X) will only allow X to be 1 term. However, if I encase the user input with "", it will return a list of character codes, is this the correct method as I can not find a way to convert it back to a readable string. I would also like to be able to see if the multiworded string contains a set value (for instance, if it contains "i have been") and am unsure of how i will be able to do this as well.

    Read the article

  • XSLT: Divide "long" words with spaces.

    - by kalininew
    There is a code: <p> Lorem ipsum dolor sit ametconsecteturadipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute iruredolorinreprehenderit in voluptate velit esse cillum doloreeufugiatnullapariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> It is necessary to receive: <p> Lorem ipsum dolor sit <span class="spaced">a m e t c o n s e c t e t u r a d i p i s i c i n g</span> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute <span class="spaced">i r u r e d o l o r i n r e p r e h e n d e r i t</span> in voluptate velit esse cillum <span class="spaced">d o l o r e e u f u g i a t n u l l a p a r i a t u r</span>. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> The sense consists in dividing "long" words with spaces. To put space after each letter in such word. Then it is necessary to conclude this word in a tag with a class "spaced". The word is considered "long" if the quantity of letters in this word is more 10 (for example. It is possible to set any value). How to solve this problem means xslt?

    Read the article

  • Counting the number of words in a text area

    - by user1320483
    Hello everyone my first question on stack overflow import javax.swing.*; import java.util.*; import java.awt.event.*; public class TI extends JFrame implements ActionListener { static int count=0; String ct; JTextField word; JTextArea tohide; public static void main(String arg[]) { TI ti=new TI(); } public TI() { JPanel j=new JPanel(); JLabel def=new JLabel("Enter the text to be encrypted"); word=new JTextField("",20); tohide=new JTextArea("",5,20); JButton jb=new JButton("COUNT"); tohide.setBorder(BorderFactory.createLoweredBevelBorder()); j.add(def); j.add(tohide); j.add(word); j.add(jb); add(j); setSize(500,500); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); jb.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String txt=tohide.getText(); StringTokenizer stk=new StringTokenizer(txt," "); while(stk.hasMoreTokens()) { String token=stk.nextToken(); count++; } ct=Integer.toString(count);; word.setText(ct); } } I want to count the number of words that are being typed in the textarea.There is a logical error.As I keep clicking the count button the word count increases.

    Read the article

  • Merging two Regular Expressions to Truncate Words in Strings

    - by Alix Axel
    I'm trying to come up with the following function that truncates string to whole words (if possible, otherwise it should truncate to chars): function Text_Truncate($string, $limit, $more = '...') { $string = trim(html_entity_decode($string, ENT_QUOTES, 'UTF-8')); if (strlen(utf8_decode($string)) > $limit) { $string = preg_replace('~^(.{1,' . intval($limit) . '})(?:\s.*|$)~su', '$1', $string); if (strlen(utf8_decode($string)) > $limit) { $string = preg_replace('~^(.{' . intval($limit) . '}).*~su', '$1', $string); } $string .= $more; } return trim(htmlentities($string, ENT_QUOTES, 'UTF-8', true)); } Here are some tests: // Iñtërnâtiônàlizætiøn and then the quick brown fox... (49 + 3 chars) echo dyd_Text_Truncate('Iñtërnâtiônàlizætiøn and then the quick brown fox jumped overly the lazy dog and one day the lazy dog humped the poor fox down until she died.', 50, '...'); // Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_... (50 + 3 chars) echo dyd_Text_Truncate('Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_jumped_overly_the_lazy_dog and one day the lazy dog humped the poor fox down until she died.', 50, '...'); They both work as it is, however if I drop the second preg_replace() I get the following: Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_jumped_overly_the_lazy_dog and one day the lazy dog humped the poor fox down until she died.... I can't use substr() because it only works on byte level and I don't have access to mb_substr() ATM, I've made several attempts to join the second regex with the first one but without success. Please help S.M.S., I've been struggling with this for almost an hour. EDIT: I'm sorry, I've been awake for 40 hours and I shamelessly missed this: $string = preg_replace('~^(.{1,' . intval($limit) . '})(?:\s.*|$)?~su', '$1', $string); Still, if someone has a more optimized regex (or one that ignores the trailing space) please share: "Iñtërnâtiônàlizætiøn and then " "Iñtërnâtiônàlizætiøn_and_then_" EDIT 2: I still can't get rid of the trailing whitespace, can someone help me out?

    Read the article

  • Algorithm to detect how many words typed, also multi sentence support (Java)

    - by Alex Cheng
    Hello all. Problem: I have to design an algorithm, which does the following for me: Say that I have a line (e.g.) alert tcp 192.168.1.1 (caret is currently here) The algorithm should process this line, and return a value of 4. I coded something for it, I know it's sloppy, but it works, partly. private int counter = 0; public void determineRuleActionRegion(String str, int index) { if (str.length() == 0 || str.indexOf(" ") == -1) { triggerSuggestionList(1); return; } //remove duplicate space, spaces in front and back before searching int num = str.trim().replaceAll(" +", " ").indexOf(" ", index); //Check for occurances of spaces, recursively if (num == -1) { //if there is no space //no need to check if it's 0 times it will assign to 1 triggerSuggestionList(counter + 1); counter = 0; return; //set to rule action } else { //there is a space counter++; determineRuleActionRegion(str, num + 1); } } //end of determineactionRegion() So basically I find for the space and determine the region (number of words typed). However, I want it to change upon the user pressing space bar <space character>. How may I go around with the current code? Or better yet, how would one suggest me to do it the correct way? I'm figuring out on BreakIterator for this case... To add to that, I believe my algorithm won't work for multi sentences. How should I address this problem as well. -- The source of String str is acquired from textPane.getText(0, pos + 1);, the JTextPane. Thanks in advance. Do let me know if my question is still not specific enough.

    Read the article

  • java Getting a list of words from a Trie

    - by adam08
    I'm looking to use the following code to not check whether there is a word matching in the Trie but to return a list all words beginning with the prefix inputted by the user. Can someone point me in the right direction? I can't get it working at all..... public boolean search(String s) { Node current = root; System.out.println("\nSearching for string: "+s); while(current != null) { for(int i=0;i<s.length();i++) { if(current.child[(int)(s.charAt(i)-'a')] == null) { System.out.println("Cannot find string: "+s); return false; } else { current = current.child[(int)(s.charAt(i)-'a')]; System.out.println("Found character: "+ current.content); } } // If we are here, the string exists. // But to ensure unwanted substrings are not found: if (current.marker == true) { System.out.println("Found string: "+s); return true; } else { System.out.println("Cannot find string: "+s +"(only present as a substring)"); return false; } } return false; } }

    Read the article

  • Need a tool to search large structure text documents for words, phrases and related phrases

    - by pitosalas
    I have to keep up with structured documents containing things such as requests for proposals, government program reports, threat models and all kinds of things like that. They are in techno-legalese as I would call them: highly structured, with section numbering and 3, 4 and 5 levels of nesting. All in English I need a more efficient way to locate those paragraphs of nuggets that matter to me. So what I’d like is kind of a local document index/repository, that would allow me to have some standing queries and easily locate sections in documents that talk about my queries. Here’s an example: I’d like to load in 10 large PDF files, each of say 100 pages. Each PDF contains English text, formatted very nicely into paragraphs and sections. I’d like to specify that I am interested in “blogging platforms”, “weaknesses in Ruby”, “localization and internationalization” Ideally then look at a list that showed the section of text, the name of the document, and other information that seemed to be related to and/or include the words and phrases I specified. I am sure something like this exists. I would call it something like document indexing, document comprehension or structured searching.

    Read the article

  • key-words highlight in <textarea> (again)

    - by Halst
    Wait, I know! I know that this "syntax highlight in textarea"-question was raised like a million times on stackoverflow! But, please, listen. offtopic: I'm not a web-developer, and technically I'm not a programmer at all. I study mechatronics and deal mostly with control-engineering and digital-hardware. And I'm so pissed off that whenever I want to share some application (that would be helpful in my field) and embed it into the web, I need to know such a crazy amount of technologies, like html, css, javascript, flash, etc.. that takes time, which I could have been spending for the benefit of my own field. Right now I'm playing with hardware-description-languages and I'm writing some Python-libraries to convert one HDL into another. And I wanted to embed such feature on the web: http://xhdl2vhdl.appspot.com/ I wanted to implement some basic syntax highlighting (only keywords highlighting will be enough) so that the code could be readable. But the whole idea highlighting something in textarea is not trivial at all. The other difficulty is that the languages I work with are rare, and there are no out-of-box solutions for them. I tried to dig into these solutions, but they are very complicated for me: http://www.nicolarizzo.com/gamesroom/experimental/CodeEditor.html http://marijn.haverbeke.nl/codemirror/jstest.html and there is no clear descriptions how to use them (for my level of knowledge of web-development). So, is there a simple solution, just to highlight a bunch of key-words in textarea or perform something equivalent? Thank you.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >