Document Term matrix
Hi All, I have a Lucene index built with Lucene 4.9 for 584 text documents, I need to extract a Document-term matrix, and Document Document similarity matrix in-order to use it to cluster the documents. My questions:1- How can I extract the matrix and compute the similarity between documents in Lucene.2- Is there any java based code that can cluster the documents from Lucene index. RegardsShaimaa
comparing documents in 2 indexes
Hi all I have a problem that might be very trivial but I don't know how can I solve it using Lucene I created an index with Lucene for a huge data set around 3 million documents in various domains and another index for a corpus of 30 documents in a specific domain.for every document in the small corpus I want to find a similar document from the huge one. does anyone knows if the Lucene searcher can do that. secondly: how can I view the terms of a document and their frequencies form the generated index. thanksshaimaa
RE: Document Similarity
thank you so much for the prompt reply I need to extract a document from the index that is similar to an Html document, and I need to use cosine similarity or latent semantic analysis which means that I need to generate term vector for the html document, the link you sent me doesn't contain any code any help will be greatly apreciated regardsshaimaa > Date: Mon, 30 Jul 2012 07:32:49 -0700 > From: in.ab...@gmail.com > To: java-user@lucene.apache.org > Subject: Re: Document Similarity > > Hi ELshaimaa, > I couldnt able understood what is your need . Can you please explain your > use case. > > If this is case "I need to use Lucene to find the most similar documents > from the generated index" > then go for morelikethis[1] components . > > Based on your use case people can suggest some good ways. > > > > [1] http://wiki.apache.org/solr/MoreLikeThis > > > > > Thanks and Regards, > S SYED ABDUL KATHER > > > > On Mon, Jul 30, 2012 at 7:30 PM, Elshaimaa Ali [via Lucene] < > ml-node+s472066n3998082...@n3.nabble.com> wrote: > > > > > Hi All > > I created a Lucene index for over 3 million document, and I used term > > vectors to create the index.now for an external document I need to use > > Lucene to find the most similar documents from the generated index.how can > > I process the document to generate a term vector to this document and what > > search technique I can use to map the document to one of the documents in > > the index > > regardsshaimaa > > > > -- > > If you reply to this email, your message will be added to the discussion > > below: > > http://lucene.472066.n3.nabble.com/Document-Similarity-tp3998082.html > > To unsubscribe from Lucene, click > > here<http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=472066&code=aW4uYWJkdWxAZ21haWwuY29tfDQ3MjA2NnwxMDczOTUyNDEw> > > . > > NAML<http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > > > > > > > - > THANKS AND REGARDS, > SYED ABDUL KATHER > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Document-Similarity-tp3998082p3998095.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com.
RE: Wikipedia Index
I only have the source text on a mysql database Do you know where I can download it in xml and is it possible to split the documents into content and title thanksshaimaa > From: luc...@mikemccandless.com > Date: Tue, 19 Jun 2012 19:48:24 -0400 > Subject: Re: Wikipedia Index > To: java-user@lucene.apache.org > > I have the index locally ... but it's really impractical to send it > especially if you already have the source text locally. > > Maybe index directly from the source text instead of via a database? > Lucene's benchmark contrib/module has code to decode the XML into > documents... > > Mike McCandless > > http://blog.mikemccandless.com > > On Tue, Jun 19, 2012 at 6:27 PM, Elshaimaa Ali > wrote: > > > > Thanks Mike for the prompt replyDo you have a fully indexed version of the > > wikipedia, I mainly need two fields for each document the indexed content > > of the wikipedia articles and the title.if there is any place where I can > > get the index, that will save me great time > > regardsshaimaa > > > >> From: luc...@mikemccandless.com > >> Date: Tue, 19 Jun 2012 16:29:39 -0400 > >> Subject: Re: Wikipedia Index > >> To: java-user@lucene.apache.org > >> > >> Likely the bottleneck is pulling content from the database? Maybe > >> test just that and see how long it takes? > >> > >> 24 hours is way too long to index all of Wikipedia. For example, we > >> index Wikipedia every night for our trunk/4.0 performance tests, here: > >> > >> http://people.apache.org/~mikemccand/lucenebench/indexing.html > >> > >> The export is a bit old now (01/15/2011) but it takes just under 6 > >> minutes to fully index it. This is on a fairly beefy machine (24 > >> cores)... and trunk/4.0 has substantial concurrency improvements over > >> 3.x. > >> > >> You can also try the ideas here: > >> > >> http://wiki.apache.org/lucene-java/ImproveIndexingSpeed > >> > >> Mike McCandless > >> > >> http://blog.mikemccandless.com > >> > >> On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali > >> wrote: > >> > > >> > Hi everybody > >> > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million > >> > article, the data is on a mysql database and it is taking more than 24 > >> > hours so far.Do you know any tips that can speed up the indexing process > >> > here is mycode: > >> > public static void main(String[] args) { á á á á á á String indexPath = > >> > INDEXPATH; á á á á á IndexWriter writer = null; á á á > >> > DatabaseConfiguration dbConfig = new DatabaseConfiguration(); á á á á á > >> > dbConfig.setHost(host); á á á á dbConfig.setDatabase(data); á á á á á á > >> > dbConfig.setUser(user); á á á á dbConfig.setPassword(password); á á á á > >> > dbConfig.setLanguage(Language.english); > >> > á á á á á á á á átry { á á á á á Directory dir = FSDirectory.open(new > >> > File(indexPath)); á á á á á á á á áAnalyzer analyzer = new > >> > StandardAnalyzer(Version.LUCENE_31); á á á áIndexWriterConfig iwc = new > >> > IndexWriterConfig(Version.LUCENE_31, analyzer); á á á á á á > >> > iwc.setOpenMode(OpenMode.CREATE); á á á writer = new IndexWriter(dir, > >> > iwc); á á á á á á á á á á á á } á á á á á á á catch (IOException e) { á > >> > á á á á á á á á á System.out.println(" caught a " + e.getClass() + á á á > >> > á á á á á "\n with message: " + e.getMessage()); á á á á á á á } á á á á > >> > á á á á á á á á á á try { á á á á á á á á á á á á Wikipedia wiki = new > >> > Wikipedia(dbConfig); á á á á á á á á á á á á á á á Iterable > >> > wikipages = wiki.getPages(); //get wikipedia articles from the database > >> > á á á á á á á á á á á á áIterator iter = wikipages.iterator(); á á á á á > >> > á á á á á á á á while(iter.hasNext()){ á á á á á á á á á á á á áPage p = > >> > (Page)iter.next(); á á á á á á á á á á á á á á > >> > System.out.println(p.getTitle().getPlainTitle()); á á á á á á á á á á á > >> > á á á á á á Document doc = new Document(); á á á á á á á á á á á á á á á > >> > á áField contentField = new Field("contents", p.getPlainText(), > >> > Field.Store.NO, Field.Index.ANALYZED); á á á á á á á á á á á á á á Field > >> > titleField = new Field("title", > >> > p.getTitle().getPlainTitle(),Field.Store.YES,
RE: Wikipedia Index
Thanks Mike for the prompt replyDo you have a fully indexed version of the wikipedia, I mainly need two fields for each document the indexed content of the wikipedia articles and the title.if there is any place where I can get the index, that will save me great time regardsshaimaa > From: luc...@mikemccandless.com > Date: Tue, 19 Jun 2012 16:29:39 -0400 > Subject: Re: Wikipedia Index > To: java-user@lucene.apache.org > > Likely the bottleneck is pulling content from the database? Maybe > test just that and see how long it takes? > > 24 hours is way too long to index all of Wikipedia. For example, we > index Wikipedia every night for our trunk/4.0 performance tests, here: > > http://people.apache.org/~mikemccand/lucenebench/indexing.html > > The export is a bit old now (01/15/2011) but it takes just under 6 > minutes to fully index it. This is on a fairly beefy machine (24 > cores)... and trunk/4.0 has substantial concurrency improvements over > 3.x. > > You can also try the ideas here: > > http://wiki.apache.org/lucene-java/ImproveIndexingSpeed > > Mike McCandless > > http://blog.mikemccandless.com > > On Tue, Jun 19, 2012 at 12:27 PM, Elshaimaa Ali > wrote: > > > > Hi everybody > > I'm using Lucene3.6 to index Wikipedia documents which is over 3 million > > article, the data is on a mysql database and it is taking more than 24 > > hours so far.Do you know any tips that can speed up the indexing process > > here is mycode: > > public static void main(String[] args) { á á á á á á String indexPath = > > INDEXPATH; á á á á á IndexWriter writer = null; á á á DatabaseConfiguration > > dbConfig = new DatabaseConfiguration(); á á á á á dbConfig.setHost(host); á > > á á á dbConfig.setDatabase(data); á á á á á á dbConfig.setUser(user); á á á > > á dbConfig.setPassword(password); á á á á > > dbConfig.setLanguage(Language.english); > > á á á á á á á á átry { á á á á á Directory dir = FSDirectory.open(new > > File(indexPath)); á á á á á á á á áAnalyzer analyzer = new > > StandardAnalyzer(Version.LUCENE_31); á á á áIndexWriterConfig iwc = new > > IndexWriterConfig(Version.LUCENE_31, analyzer); á á á á á á > > iwc.setOpenMode(OpenMode.CREATE); á á á writer = new IndexWriter(dir, iwc); > > á á á á á á á á á á á á } á á á á á á á catch (IOException e) { á á á á á á > > á á á á System.out.println(" caught a " + e.getClass() + á á á á á á á á > > "\n with message: " + e.getMessage()); á á á á á á á } á á á á á á á á á á > > á á á á try { á á á á á á á á á á á á Wikipedia wiki = new > > Wikipedia(dbConfig); á á á á á á á á á á á á á á á Iterable wikipages > > = wiki.getPages(); //get wikipedia articles from the database á á á á á á á > > á á á á á áIterator iter = wikipages.iterator(); á á á á á á á á á á á á á > > while(iter.hasNext()){ á á á á á á á á á á á á áPage p = (Page)iter.next(); > > á á á á á á á á á á á á á á > > System.out.println(p.getTitle().getPlainTitle()); á á á á á á á á á á á á á > > á á á á Document doc = new Document(); á á á á á á á á á á á á á á á á > > áField contentField = new Field("contents", p.getPlainText(), > > Field.Store.NO, Field.Index.ANALYZED); á á á á á á á á á á á á á á Field > > titleField = new Field("title", > > p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); á > > á á á á á á á á á á á á á á á doc.add(contentField); // wiki page text á á > > á á á á á á á á á á á á á ádoc.add(titleField); // wiki page title á á á á > > á á á á á á á á á á á á writer.addDocument(doc); á á á á á á á á á á á á á > > á} á á á á á á á á á á á } catch (Exception e) { á á á á á á á á á á á á > > e.printStackTrace(); á á á á á á á á á á} á á á á á á á á á á á á á á á á } > > > > - > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org >
Wikipedia Index
Hi everybody I'm using Lucene3.6 to index Wikipedia documents which is over 3 million article, the data is on a mysql database and it is taking more than 24 hours so far.Do you know any tips that can speed up the indexing process here is mycode: public static void main(String[] args) { String indexPath = INDEXPATH; IndexWriter writer = null; DatabaseConfiguration dbConfig = new DatabaseConfiguration(); dbConfig.setHost(host); dbConfig.setDatabase(data); dbConfig.setUser(user); dbConfig.setPassword(password); dbConfig.setLanguage(Language.english); try { Directory dir = FSDirectory.open(new File(indexPath)); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31);IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_31, analyzer); iwc.setOpenMode(OpenMode.CREATE); writer = new IndexWriter(dir, iwc); } catch (IOException e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } try { Wikipedia wiki = new Wikipedia(dbConfig); Iterable wikipages = wiki.getPages(); //get wikipedia articles from the database Iterator iter = wikipages.iterator(); while(iter.hasNext()){ Page p = (Page)iter.next(); System.out.println(p.getTitle().getPlainTitle()); Document doc = new Document(); Field contentField = new Field("contents", p.getPlainText(), Field.Store.NO, Field.Index.ANALYZED); Field titleField = new Field("title", p.getTitle().getPlainTitle(),Field.Store.YES, Field.Index.NOT_ANALYZED ); doc.add(contentField); // wiki page text doc.add(titleField); // wiki page title writer.addDocument(doc);} } catch (Exception e) { e.printStackTrace(); } }