Exemplo n.º 1
0
    void operator()(const hypergraph_type& graph_in, IteratorTree tree_iter, IteratorRule rule_iter)
    {
      if (! graph_in.is_valid()) return;
      
      phrase_map.clear();
      phrase_map.reserve(graph_in.nodes.size());
      phrase_map.resize(graph_in.nodes.size());
      
      // bottom-up topological order
      for (size_t id = 0; id != graph_in.nodes.size(); ++ id) {
	match_tree(id, graph_in, tree_iter);
	
	if (! grammar.empty())
	  match_phrase(id, graph_in, rule_iter);
      }
    }
Exemplo n.º 2
0
static CoglBool
check_swrast_architecture (const CoglGpuInfoStrings *strings)
{
  return match_phrase (strings->renderer_string, "software rasterizer") ||
    match_phrase (strings->renderer_string, "Software Rasterizer");
}
Exemplo n.º 3
0
static CoglBool
check_softpipe_architecture (const CoglGpuInfoStrings *strings)
{
  return match_phrase (strings->renderer_string, "softpipe");
}
Exemplo n.º 4
0
static CoglBool
check_sandybridge_architecture (const CoglGpuInfoStrings *strings)
{
  return match_phrase (strings->renderer_string, "Sandybridge");
}
Exemplo n.º 5
0
static CoglBool
check_intel_vendor (const CoglGpuInfoStrings *strings)
{
  return match_phrase (strings->renderer_string, "Intel(R)");
}
Exemplo n.º 6
0
static bool
check_swrast_architecture(const cg_gpu_info_strings_t *strings)
{
    return match_phrase(strings->renderer_string, "software rasterizer") ||
           match_phrase(strings->renderer_string, "Software Rasterizer");
}
Exemplo n.º 7
0
static bool
check_softpipe_architecture(const cg_gpu_info_strings_t *strings)
{
    return match_phrase(strings->renderer_string, "softpipe");
}
Exemplo n.º 8
0
static bool
check_sandybridge_architecture(const cg_gpu_info_strings_t *strings)
{
    return match_phrase(strings->renderer_string, "Sandybridge");
}
Exemplo n.º 9
0
static bool
check_intel_vendor(const cg_gpu_info_strings_t *strings)
{
    return match_phrase(strings->renderer_string, "Intel(R)");
}
Exemplo n.º 10
0
int main(int argc, char * argv[]) {

    if (argc == 1)
        return EXIT_SUCCESS;

    printf("Number of words: %d\n", argc - 1);

    // Clean the input a bit. and count sentences.
    
    int nb_of_sentences = 0;
    int nb_of_sir_occurances = 0;
    for (int i = 1; i < argc; i++) {
        int length = strlen(argv[i]);
        if(argv[i][length - 1] == '"' && ispunct(argv[i][length - 2])) {
            argv[i][length - 1] = argv[i][length - 2];
            argv[i][length - 2] = '"';
        }
        // Count sentences
        char last = argv[i][length - 1];
        if (last == '.' || last == '!' || last == '?')
            nb_of_sentences++; 
        // Count Sir occurances (double counts).
        if(strcmp(argv[i], "Sir") == 0 || strcmp(argv[i], "\"Sir") == 0)
            nb_of_sir_occurances++;
        if(strcmp(argv[i], "Sirs") == 0 || strcmp(argv[i], "\"Sirs") == 0)
            nb_of_sir_occurances += count_sirs(i + 1, argv);
    }
    printf("Number of Sentences: %d\n", nb_of_sentences);
    printf("Number of occurences of Sirs: %d\n", nb_of_sir_occurances);
    
    // Sentences
    
    int end_of_sentences[nb_of_sentences];
    int current_sentence = 0;
    for (int i = 1; i < argc; i++) {
        int length = strlen(argv[i]);
        char last = argv[i][length - 1];
        if (last == '.' || last == '!' || last == '?')
            end_of_sentences[current_sentence++] = i; 
    }
    
    // Sirs
    
    int sir_occurances[nb_of_sir_occurances];
    int current_sir = 0;
    for (int i = 1; i < argc; i++) {
        if(strcmp(argv[i], "Sir") == 0 || strcmp(argv[i], "\"Sir") == 0)
            sir_occurances[current_sir++] = i + 1;
        if(strcmp(argv[i], "Sirs") == 0 || strcmp(argv[i], "\"Sirs") == 0)
            while(current_sir <= nb_of_sir_occurances) {
                i++;
                if(strcmp(argv[i], "and") != 0 && strcmp(argv[i], "or") != 0)
                    sir_occurances[current_sir++] = i;
                else {
                    if (strcmp(argv[i + 1], "I") != 0) 
                        sir_occurances[current_sir++] = i + 1;
                    break;
                }
            }
    }
    // Trim off punctuation from end of Sir names:
    for (int i = 0; i < nb_of_sir_occurances; i++) {
        int word = sir_occurances[i];
        int length = strlen(argv[word]);
        if(ispunct(argv[word][length - 1]))
            argv[word][length - 1] = '\0';
    }
    // Count distinct Sirs:
    char * sirs[nb_of_sir_occurances]; 
    // ...and if we know this we can ignore the excess spaces.
    int nb_of_sirs = 0; 
    for(int i = 0; i < nb_of_sir_occurances; i++) {
        int current_sir = sir_occurances[i];
        bool duplicate = false;
        // Check if the current Sir has occured previously...
        for(int j = 0; j < i; j++) {
            int previous_sir = sir_occurances[j];
            if(strcmp(argv[current_sir], argv[previous_sir]) == 0) {
                duplicate = true;
                break;
            }
        }
        if(!duplicate)
            sirs[nb_of_sirs++] = argv[current_sir];
    }
    // Sort the Sirs
    qsort(sirs, nb_of_sirs, sizeof(char *), cmpstr);

    // Find Sir Statments
    
    Sentence sentences[nb_of_sentences];   // Sentences data.
    int current_begin = 1;  // coz argv inclues the program name at 0
    for (int s = 0; s < nb_of_sentences; s++) {
        Sentence current_s = {current_begin, end_of_sentences[s], -1, -1, -1, -1, -1, false, 0};
        for (int w = current_begin; w <= end_of_sentences[s]; w++) {
            // Look for quotes...
            if(argv[w][0] == '"') {
                current_s.open = w++;
                do {
                    int length = strlen(argv[w]);
                    for (int c = 0; c < length; c++)
                        if(argv[w][c] == '"') {
                            current_s.close = w;
                            break;
                        }
                    if(current_s.close != -1) {
                        // Remove punctuation and move on...
                        if(ispunct(argv[w][length - 1]))
                            argv[w][length - 1] = '\0';
                        break;
                    }
                } while (++w <= end_of_sentences[s]); 
            }
        }
        current_begin = end_of_sentences[s] + 1;
        sentences[s] = current_s;
    }
    // Look for Sir who is speaking.
    for (int i = 0; i < nb_of_sentences; i++) {
        Sentence * s = &sentences[i];
        if (s->open != -1) {
            int speaker_i = find_speaker(argv, *s);
            if(speaker_i != -1)
                s->speaker = find_index(argv[speaker_i], sirs, nb_of_sirs);
            // match phrase to one of the 8 templates.
            match_phrase(s, argv);
            find_sirs(argv, s, sirs, nb_of_sirs);
        }
    }
    
    
    
    
    // Output testing.

    for (int i = 1; i < argc; i++){
        printf("%s ", argv[i]);
        if(in_array(i, end_of_sentences, nb_of_sentences))
            printf("\n");
    }
    printf("The Sirs are:");
    print_array(sirs, nb_of_sirs);
    printf("\n");
}