Upload
bertram-west
View
226
Download
1
Embed Size (px)
Citation preview
Softvérové knižnice a systémySoftvérové knižnice a systémy
Vyhľadávanie informáciíVyhľadávanie informácií
Michal Laclavík
Vyhľadávanie informácií Bratislava, 3. november 2014 2
Tools - NástrojeTools - Nástroje
IR tools• Nutch + HadoopIR API• Lucenezískavanie informácií• Sťahovač: Nutch• textové operácie: lucene, GATE• Indexovanie: lucene• spracovanie odkazov: Nutch• Báza dokumentov: Konvertery, kompresia, kódovanie
– JavaMail– Tika: PDFBox, POI, TextMining– zip
Vyhľadávanie• formulácia dopytu a operácie na dopyte: Solr• spracovanie dopytu: Solr• vrátenie výsledku na používateľské rozhranie: Solr• spätná väzba od používateľa: ?Extrakcia • GATE• Ontea• Regexy
Spracovanie odkazov
Indexovač
Usporiadanie
Vyhľadávač
Bázadokumentov
Odkazy
Index dokumentov
Sťahovač
Textové operácie
Otázka
Užívateľ
Zoznam dokumentov
Internet
Vyhľadávanie informácií Bratislava, 3. november 2014 3
ToolsTools
• IR libraries & engines– Lucene
– Egothor
• Lucene– Nutch
– Sorl
– Porty
Vyhľadávanie informácií Bratislava, 3. november 2014 4
Lucene IndexingLucene Indexing
• IndexWriter• Directory
– FSDirectory, RAMDirectory, MMapDirectory
• Analyzer• Document
– Collection of fields
• Field– Keyword, UnIndexed, UnStored, Text
doc = new Document();doc.add(new StringField("ctg", value, Field.Store.YES));doc.add(new TextField(fieldName, value2, Field.Store.NO));doc.add(new VecTextField("title", data, Field.Store.YES));writer.addDocument(doc);
Directory dir = FSDirectory.open(new File(indexPath));Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_43, analyzer);iwc.setOpenMode(OpenMode.CREATE);IndexWriter writer = new IndexWriter(dir, iwc);
Vyhľadávanie informácií Bratislava, 3. november 2014 5
Lucene Indexing 2Lucene Indexing 2
• Indexing Dates• Boosting
– Field.setBoost
• Indexing Numbers– Adding zeros, Analyzers
• Sorting– Not tokenized, Field Keyword
• Directory– FSDirectory, RAMDirectory
• Term vector– Field.Unstored(“subject”,subject,true);
Vyhľadávanie informácií Bratislava, 3. november 2014 6
Lucene SearchingLucene Searching
• IndexSearcher• Term• Query
– Boolean, Phrase, Prefix, Range, Fuzzy (levenstein)
• TermQuery• Hits queryL = new BooleanQuery();
Query name = new TermQuery(new Term("name_exact", query));Query alias = new TermQuery(new Term("alias_exact", query));Query wiki = new TermQuery(new Term("wikipedia_exact", query));
name.setBoost(0.40f);alias.setBoost(0.30f);wiki.setBoost(0.30f);
((BooleanQuery) queryL).add(name, Occur.SHOULD);((BooleanQuery) queryL).add(alias, Occur.SHOULD);((BooleanQuery) queryL).add(wiki, Occur.SHOULD);
directory = FSDirectory.open(new File(index));reader = DirectoryReader.open(directory);searcher = new IndexSearcher(reader);
Vyhľadávanie informácií Bratislava, 3. november 2014 7
Lucene Searching 2Lucene Searching 2
• Query q = QueryParser.parse(“search”, “field”, new SimpleAnalyzer());– +pubdate:[20040101 TO 20041231] Java AND (Jakarta OR Apache)– Query.toString()
• Scoring – Similarity, DefaultSimilarity
• Sorting – By field, by multiple
• MultiFieldQueryParser
• Filtering
fields = new String[] {"name", "alias", "text", "wikipedia"};boosts.put("name", 0.40f);boosts.put("alias", 0.30f);boosts.put("text", 0.20f);boosts.put("wikipedia", 0.10f);
MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_43, fields, analyzer, boosts);queryL = parser.parse(query);TopDocs results = s.search(queryL, topK);ScoreDoc[] hits = results.scoreDocs;
Vyhľadávanie informácií Bratislava, 3. november 2014 8
Lucene Searching 3Lucene Searching 3
• Custom Sort Method– Distance search
Vyhľadávanie informácií Bratislava, 3. november 2014 9
Lucene AnalysisLucene Analysis
• XY&Z Corporation – [email protected]• WitespaceAnalyzer
– [XY&Z] [Corporation] [–] [[email protected]]
• SimpleAnalyzer – kills numbers– [XY] [Z] [corporation] [xyz] [example] [com]
• StopAnalyzer– [XY] [Z] [corporation] [xyz] [example] [com]
• StandardAnalyzer– [XY&Z] [corporation] [[email protected]]
Vyhľadávanie informácií Bratislava, 3. november 2014 10
Lucene Analysis 2Lucene Analysis 2
• Indexing• Querying
– Query parse, QueryTerm not Analyzed
• Results– Tokens, position type
– Terms, position
• TokenStream, Tokenizer, TokenFilter
Vyhľadávanie informácií Bratislava, 3. november 2014 11
Lucene Analysis 3Lucene Analysis 3
• Synonyms, aliases– Same position (phrase query)
• UTF-8– Kodovania, znaky HTML
– Content-type
• Nutch analysis
Vyhľadávanie informácií Bratislava, 3. november 2014 12
SandBoxSandBox
• Development tools– Lucli CLI
– Luke – toolbox
• SnowBall analyzer
• T9 indexing example
Vyhľadávanie informácií Bratislava, 3. november 2014 13
Lucene Doc formatLucene Doc format
• Apache Tika
• XML– SAX parser Xserces– Digester Apache Jakarta
• PDF– PDFBox.org– Buildin support
• HTML– JTidy.sf.net– NekoHTML
• Word– POI – jakarta project– TextMining.org
• RTF– Javax.swing.text.rtf
Vyhľadávanie informácií Bratislava, 3. november 2014 14
Lucene PortsLucene Ports
• CLucene• dotLucene• Plucene Perl• Lupy Python• PyLucene GCJ + SWIG
Vyhľadávanie informácií Bratislava, 3. november 2014 15
NutchNutch
• Build on lucene• Fetcher• Scalable to several billions• Ranking
• Hadoop– Implementacia MapReduce
• Search and Indexing now integrated over Solr
Vyhľadávanie informácií Bratislava, 3. november 2014 16
Other Use casesOther Use cases
• JGuru• SearchBlox• Alias-i
Vyhľadávanie informácií Bratislava, 3. november 2014 17
Linux toolsLinux tools
• Catdoc – Xsl, doc
– openoffice
• Pdftotext (XPDF)
• Encoding– enca
Vyhľadávanie informácií Bratislava, 3. november 2014 18
Ine knizniceIne kniznice
• QTag– POS tagging
• Stemming– Snowball
– Porter
– Tvaroslovnik, JULS
• SimMetrics– Podobnosti, levenstein, cosmiera
• GATE
Vyhľadávanie informácií Bratislava, 3. november 2014 19
TutorialTutorial
• GATE• http://gate.ac.uk/sale/talks/gate-course-july09/slides-pdf/slides.html
• Lucene– Lucene in Action, kódy, kniha
Other ToolsOther Tools
• Apache UIMA– text processing (information extraction
• OpenNLP– machine learning for text analysis i.e. information extraction
• MOSES– Machine learning language translation
Vyhľadávanie informácií Bratislava, 3. november 2014 20
Dostupné dátové zdroje v Slovenskom jazykuDostupné dátové zdroje v Slovenskom jazyku
• Korpus– http://korpus.juls.savba.sk/
• Organizácie s dátovými zdrojmi v rôznych jazykoch použiteľné na automatický preklad– http://www.tasr.sk/
– http://www.sita.sk
– http://www.skrivanek.com/
• Voľne dostupné zdroje:– http://sk.wikipedia.org
– http://sk.wiktionary.org
• Slovníky– http://slovnik.azet.sk/
– http://slovniky.lingea.sk/
– http://www.sk-spell.sk.cx/mass-msas
• Dáta– http://sk-spell.sk.cx/
– http://www.sk-spell.sk.cx/thesaurus/
– http://www.sk-spell.sk.cx/biblia-sk/
– http://www.sk-spell.sk.cx/OCR
Vyhľadávanie informácií Bratislava, 3. november 2014 21