word-frequency

Word frequency in Solr

不羁岁月 提交于 2019-11-30 17:25:15
问题 I am trying to get frequency of words using solr. When I give this query : localSolr/solr/select?q=someQuery&rows=0&facet=true&facet.field=content&wt=xml solr gives me the frequencies like; <lst name="facet_counts"> <lst name="facet_queries"/> <lst name="facet_fields"> <lst name="content"> <int name="word1">24</int> <int name="word2">12</int> <int name="word3">8</int> But when I count the words; I find that word2's actual count number is 13. Solr counts same words in the field as one. For

Most used words in text with php

霸气de小男生 提交于 2019-11-30 16:04:39
I found the code below on stackoverflow and it works well in finding the most common words in a string. But can I exclude the counting on common words like "a, if, you, have, etc"? Or would I have to remove the elements after counting? How would I do this? Thanks in advance. <?php $text = "A very nice to tot to text. Something nice to think about if you're into text."; $words = str_word_count($text, 1); $frequency = array_count_values($words); arsort($frequency); echo '<pre>'; print_r($frequency); echo '</pre>'; ?> This is a function that extract common words from a string. it takes three

Convert sparse matrix (csc_matrix) to pandas dataframe

戏子无情 提交于 2019-11-30 12:03:36
I want to convert this matrix into a pandas dataframe. csc_matrix The first number in the bracket should be the index , the second number being columns and the number in the end being the data . I want to do this to do feature selection in text analysis, the first number represents the document, the second being the feature of word and the last number being the TFIDF score. Getting a dataframe helps me to transform the text analysis problem into data analysis. from scipy.sparse import csc_matrix csc = csc_matrix(np.array( [[0, 0, 4, 0, 0, 0], [1, 0, 0, 0, 2, 0], [2, 0, 0, 1, 0, 0], [0, 0, 0, 0

counting the word frequency in lucene index

浪尽此生 提交于 2019-11-30 07:43:26
Can someone help me finding the word frequency in all lucene index for example if doc A has 3 number of word (B) and doc C has 2 of them, I'd like a method to return 5 showing the frequency of word (B) in all lucene index Xodarap This has been asked multiple times: Get term frequencies in Lucene How to count term frequency for set of documents? Get highest frequency terms from Lucene index How do I get solr term frequency? Assuming you work with Lucene 3.x: IndexReader ir = IndexReader.open(dir); TermDocs termDocs = ir.termDocs(new Term("your_field", "your_word")); int count = 0; while

Word frequencies from strings in Postgres?

强颜欢笑 提交于 2019-11-30 04:18:05
Is it possible to identify distinct words and a count for each, from fields containing text strings in Postgres? Something like this? SELECT some_pk, regexp_split_to_table(some_column, '\s') as word FROM some_table Getting the distinct words is easy then: SELECT DISTINCT word FROM ( SELECT regexp_split_to_table(some_column, '\s') as word FROM some_table ) t or getting the count for each word: SELECT word, count(*) FROM ( SELECT regexp_split_to_table(some_column, '\s') as word FROM some_table ) t GROUP BY word You could also use the PostgreSQL text-searching functionality for this, for example:

WordCount: how inefficient is McIlroy's solution?

喜欢而已 提交于 2019-11-30 03:43:33
Long story short: in 1986 an interviewer asked Donald Knuth to write a program that takes a text and a number N in input, and lists the N most used words sorted by their frequencies. Knuth produced a 10-pages Pascal program, to which Douglas McIlroy replied with the following 6-lines shell script: tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn | sed ${1}q Read the full story at http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/ . Of course they had very different goals: Knuth was showing his concepts of literate programming and built everything from scratch, while

Most used words in text with php

◇◆丶佛笑我妖孽 提交于 2019-11-29 23:04:45
问题 I found the code below on stackoverflow and it works well in finding the most common words in a string. But can I exclude the counting on common words like "a, if, you, have, etc"? Or would I have to remove the elements after counting? How would I do this? Thanks in advance. <?php $text = "A very nice to tot to text. Something nice to think about if you're into text."; $words = str_word_count($text, 1); $frequency = array_count_values($words); arsort($frequency); echo '<pre>'; print_r(

counting the word frequency in lucene index

点点圈 提交于 2019-11-29 10:25:00
问题 Can someone help me finding the word frequency in all lucene index for example if doc A has 3 number of word (B) and doc C has 2 of them, I'd like a method to return 5 showing the frequency of word (B) in all lucene index 回答1: This has been asked multiple times: Get term frequencies in Lucene How to count term frequency for set of documents? Get highest frequency terms from Lucene index How do I get solr term frequency? 回答2: Assuming you work with Lucene 3.x: IndexReader ir = IndexReader.open

Count word frequency in a text? [duplicate]

大兔子大兔子 提交于 2019-11-29 02:28:35
Possible Duplicate: php: sort and count instances of words in a given string I am looking to write a php function which takes a string as input, splits it into words and then returns an array of words sorted by the frequency of occurence of each word. What's the most algorithmically efficient way of accomplishing this ? Gordon Your best bet are these: str_word_count — Return information about words used in a string array_count_values — Counts all the values of an array Example $words = 'A string with certain words occuring more often than other words.'; print_r( array_count_values(str_word

WordCount: how inefficient is McIlroy's solution?

我只是一个虾纸丫 提交于 2019-11-29 00:40:44
问题 Long story short: in 1986 an interviewer asked Donald Knuth to write a program that takes a text and a number N in input, and lists the N most used words sorted by their frequencies. Knuth produced a 10-pages Pascal program, to which Douglas McIlroy replied with the following 6-lines shell script: tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq -c | sort -rn | sed ${1}q Read the full story at http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/ . Of course they had very different goals