Project

General

Profile

root / branches / compiler / cSharp / ooasCompiler / src / libs / c5 / UserGuideExamples / Kwic.cs @ 3

1
// C5 example sketch -- not so interesting after all
2
// 2004-08
3

    
4
// KWIC = keyword-in-context.
5

    
6
// Read a file of words and create an ordered list of keywords, giving
7
// for each keyword a list of the contexts in which it appears.  For
8
// instance, for this text
9

    
10
This book presents C# version 2.0 as used in Microsoft Visual Studio
11
2005, including generics, iterators, anonymous methods and partial
12
type declarations, but excluding most of Microsoft's .Net Framework
13
class libraries except threads, input-output, and generic collection
14
classes.  The book does not cover unsafe code, destructors,
15
finalization, reflection, pre-processing directives (#define,
16
#if) or details of \textsc{ieee754} floating-point
17
numbers.
18

    
19
// the resulting list may look like this:
20
// book 
21
//   this book presents
22
//   the book does
23
// Microsoft
24
//   in Microsoft Visual
25
//   of Microsoft's .Net
26
  
27
// How to proceed: (1) read a stream of words from file; (2) turn this
28
// into a stream of (2n+1)-tuples of words, namely a keyword
29
// surrounded by n words on either side; (3) create a dictionary
30
// mapping each keyword to a set of its contexts; (4) output the
31
// entries of the dictionary sorted by keyword, for each keyword
32
// building an HTML <item> list or similar.
33

    
34
// Step (2) can be improved by not generating (2n+1)-tuples for
35
// keywords that are stop words (in, of, the, a, ...).  Also, each
36
// such triple may have an associated line number or page number on
37
// which it appears, in which case the dictionary should map to a
38
// dictionary that maps each context to a list of line numbers or page
39
// numbers.
40

    
41
using System;
42
using C5;
43
using SCG = System.Collections.Generic;
44

    
45
class MyTest {
46
  public static void Main(String[] args) {
47

    
48
  }
49
}