示例#1
0
文件: str.c 项目: andrei6200/IQL
char* cat4(char* s1, char* s2, char* s3, char* s4)
{
    char* part1 = cat2(s1, s2);
    char* part2 = cat2(s3, s4);
    sprintf(output, "%s%s%s", part1, SEPARATOR, part2);
    free(part1);
    free(part2);

    return strdup(output);
}
示例#2
0
Re_node parse_re(char **s, short end)
{
    Stack stk = NULL, temp;
    Tok_node next_token;
    Re_node re = NULL;

    if (s == NULL || *s == NULL) return NULL;
    while (TRUE) {
        next_token = get_token(s);
        if (next_token == NULL) return NULL;
        switch (tok_type(next_token)) {
        case RPAREN:
            retract_token(s);
        case EOS:
            if (end == tok_type(next_token)) return Top(cat2(&stk));
            else return NULL;
        case LPAREN:
            re = parse_re(s, RPAREN);
            if (Push(&stk, re) == NULL) return NULL;
            if (tok_type(get_token(s)) != RPAREN || re == NULL) return NULL;
            if (Size(stk) > 2) {
                temp = stk->next;
                stk->next = cat2(&temp);	/* condense CAT nodes */
                if (stk->next == NULL) return NULL;
                else stk->size = stk->next->size + 1;
            }
            break;
        case OPSTAR:
            if (wrap(&stk, OPSTAR) == NULL) return NULL;
            break;
        case OPOPT:
            if (wrap(&stk, OPOPT) == NULL) return NULL;
            break;
        case OPALT:
            if (cat2(&stk) == NULL) return NULL;
            re = parse_re(s, end);
            if (re == NULL) return NULL;
            if (mk_alt(&stk, re) == NULL) return NULL;
            break;
        case LITERAL:
            if (Push(&stk, tok_val(next_token)) == NULL) return NULL;
            if (Size(stk) > 2) {
                temp = stk->next;
                stk->next = cat2(&temp);    /* condense CAT nodes */
                if (stk->next == NULL) return NULL;
                else stk->size = stk->next->size + 1;
            }
            break;
        default:
            printf("parse_re: unknown token type %d\n", tok_type(next_token));
            break;
        }
    }
}
示例#3
0
    void equality_data() {
        QTest::addColumn<QLandmarkCategory>("lop");
        QTest::addColumn<QLandmarkCategory>("rop");
        QTest::addColumn<bool>("isEqual");

        QLandmarkCategory cat0;
        cat0.setName("equalName");
        cat0.setIconUrl(QUrl("equalIcon"));

        QLandmarkCategory cat1;
        cat1.setName("unequalName");
        cat1.setIconUrl(QUrl("unequalIcon"));
        QTest::newRow("allUnequal") << cat0 << cat1 << false;

        QLandmarkCategory cat2(cat0);
        cat2.setName("unequalName");
        QTest::newRow("nameUnequal") << cat0 << cat2 << false;

        QLandmarkCategory cat3(cat0);
        cat3.setIconUrl(QUrl("unequalIcon"));
        QTest::newRow("iconUnequal") << cat0 << cat3 << false;

        QLandmarkCategory cat5(cat0);
        QTest::newRow("allEqual") << cat0 << cat5 << true;
    }
示例#4
0
void StarCatalog::splitInTwo(
    const std::string f1, const std::string f2,
    const int seed) const
{
    srand(seed);

    std::vector<long> id1;
    std::vector<long> id2;

    double split_point = 0.5;


    for (int i=0; i<this->size(); i++) {

        // number between [0,1)
        double r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );
        if (r > split_point) {
            id1.push_back(i);
        } else {
            id2.push_back(i);
        }

    }

    StarCatalog cat1(*this, id1);
    StarCatalog cat2(*this, id2);

    cat1.writeFits(f1);
    cat2.writeFits(f2);
}
示例#5
0
文件: str.c 项目: andrei6200/IQL
char* cat3(char* s1, char* s2, char* s3)
{
    char* part1 = cat2(s1, s2);
    if (s3 == NULL)
        s3 = blank;
    sprintf(output, "%s%s%s", part1, SEPARATOR, s3);
    free(part1);
    
    return strdup(output);
}
示例#6
0
Re_node parse(char *s)
{
    Re_node tree, temp;
    Stack stk = NULL;

    tree = parse_re(&s, NUL);
    if (tree == NULL || Push(&stk, tree) == NULL) return NULL;
    temp = mk_leaf(EOS, C_LIT, NUL, NULL);
    if (temp == NULL || Push(&stk, temp) == NULL) return NULL;
    final_pos = --pos_cnt;
    return Top(cat2(&stk));
}
示例#7
0
    void copyConstructor() {
        QFETCH(QString, name);
        QFETCH(QUrl, iconUrl);

        QLandmarkCategory cat1;

        cat1.setName(name);
        cat1.setIconUrl(iconUrl);

        QLandmarkCategory cat2(cat1);

        QCOMPARE(cat2.name(), name);
        QCOMPARE(cat2.iconUrl(), iconUrl);
    }
示例#8
0
int main(int argc, char *argv[])
{
  region_t r;
  cap_t fs_server;

  if(argc != 2 && argc != 4) {
    printf(_("Usage: %s /x=shell_options [OPTION_NAME on/off]\n"), argv[0]);
    return 1;
  }

  if(get_process_caps("fs_op", &fs_server, NULL) < 0)
    return 1;

  {
    cap_t opts;
    struct cap_args result;

    r = region_make();
    cap_call(fs_server, r,
	     cap_args_make(cat2(r, mk_int(r, METHOD_FSOP_GET_OBJ),
				mk_string(r, argv[1])),
			   caps_empty, fds_empty),
	     &result);
    filesys_obj_free(fs_server);
    if(expect_cap1(result, &opts) < 0) {
      fprintf(stderr, _("%s: couldn't get options object\n"), argv[0]);
      return 1;
    }

    if(argc == 2) {
      print_option(r, opts, "log_summary");
      print_option(r, opts, "log_into_xterm");
      print_option(r, opts, "print_fs_tree");
      print_option(r, opts, "enable_x11");
    }
    else if(argc == 4) {
      int x;
      if(!strcmp(argv[3], "on")) x = 1;
      else if(!strcmp(argv[3], "off")) x = 0;
      else {
	fprintf(stderr, _("value `%s' not recognised\n"), argv[3]);
	return 1;
      }
      set_option(r, opts, argv[2], x);
    }
    else assert(0);
  }
  return 0;
}
示例#9
0
文件: genarr.c 项目: spchamp/ilu
PUBLIC char * ar_typeDeclarator(Type t) {
    char* 		buf;
    TypeDescription	d;
    Type		eType;
    list		dimList;
    int			nDims;
    int			i;
    t = ar_assert(t);
    d = t->description;
    eType = d->structuredDes.array.type;
    dimList = d->structuredDes.array.dimensions;
    nDims = list_size(dimList);
    buf = typeDeclarator(eType);
    for (i = 0; i < nDims; i++) {
        buf = cat2(buf, "[]");
    }
    return buf;
}
示例#10
0
文件: genarr.c 项目: spchamp/ilu
PUBLIC char * ar_ioInPiece(Type t) {
    char * piece;
    TypeDescription d;
    Type elementType;
    list dimList;
    t = myUrType(t);
    d = type_description(t);
    elementType = d->structuredDes.array.type;
    dimList = d->structuredDes.array.dimensions;
    if (list_size(dimList) == 1) {
        piece = arraySpecialElemTypeName(elementType);
        if (piece != NULL) {
            return (ioSpecialElemInPiece(piece,
                (unsigned long) list_ref(dimList, 0)));
        }
    }
    return (cat2(arrJName(t), ".inFunc(_call)" ));
}
示例#11
0
Box MakeBoxOfCats()
{
	Box catbox;

	Cat cat1(L"Furry");
	catbox.MoveCatToBox(std::move(cat1));
	// WARNING! At this point, cat1 has been moved to catbox, so it is no longer valid!

	Cat cat2(L"Purry");
	catbox.AddCatToBox(cat2);

	Cat cat3(L"Curry");
	catbox.AddCatToBox(cat3);

	Cat cat4(L"Allergy");
	catbox.AddCatToBox(cat4);

	return catbox;
}
示例#12
0
static int CALLBACK compareTokenHelp(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	TOKENREGISTEREX *tr1 = (TOKENREGISTEREX *)lParam1;
	TOKENREGISTEREX *tr2 = (TOKENREGISTEREX *)lParam2;
	if (tr1 == NULL || tr2 == NULL)
		return 0;

	ptrT cat1(getTokenCategory(tr1));
	ptrT cat2(getTokenCategory(tr2));
	if (cat1 == NULL || cat2 == NULL)
		return 0;

	int res = _tcscmp(cat1, cat2);
	if (res != 0)
		return res;

	if (tr1->tszTokenString == NULL || tr2->tszTokenString == NULL)
		return 0;

	return _tcscmp(tr1->tszTokenString, tr2->tszTokenString);
}
void Ut_Category::testChildren()
{
    MemoryCategory cat1 ("test1");
    MemoryCategory cat2 ("test2");

    // the children has to be sorted by order
    cat1.addChild (fileCat);
    cat1.addChild (invalidMemCat);
    cat1.addChild (memCat);
    QCOMPARE (cat1.children().count(), 3);
    QCOMPARE (cat1.children().at(0), invalidMemCat); // has 0 order
    QCOMPARE (cat1.children().at(1), memCat); // has 1 order
    QCOMPARE (cat1.children().at(2), fileCat); // has 9999999

    // try it with another sequence
    cat2.addChild (invalidMemCat);
    cat2.addChild (memCat);
    cat2.addChild (fileCat);
    QCOMPARE (cat2.children().count(), 3);
    QCOMPARE (cat2.children().at(0), invalidMemCat); // has 0 order
    QCOMPARE (cat2.children().at(1), memCat); // has 1 order
    QCOMPARE (cat2.children().at(2), fileCat); // has 9999999
}
示例#14
0
  void operator()(std::ostream& out, const Edge& e) const
  {
    const Common::PropertyCode::PropertyManager& microManager = m_propertyCodeManager->getPropertyManager("MICRO");


    bool hasNonValidTrigram=false;
    bool hasNonValidBigram=false;

    std::vector<std::vector<uint64_t> > gramNotFound;
    std::vector<uint64_t> gram;

    uint64_t cat1(0),cat2(0),cat3(0);
    LinguisticAnalysisStructure::MorphoSyntacticData* d3=get(vertex_data,*m_graph,target(e,*m_graph));
    if (d3!=0 && !d3->empty()) {
      cat3=microManager.getPropertyAccessor().readValue(d3->begin()->properties);
    }
    LinguisticAnalysisStructure::MorphoSyntacticData* d2=get(vertex_data,*m_graph,source(e,*m_graph));
    if (d2!=0 && !d2->empty()) {
      cat2=microManager.getPropertyAccessor().readValue(d2->begin()->properties);
    }
    gram.push_back(cat2);
    gram.push_back(cat3);

    LinguisticGraphInEdgeIt inItr,inItrEnd;
    for(boost::tie(inItr,inItrEnd)=in_edges(source(e,*m_graph),*m_graph);
        inItr!=inItrEnd;
        inItr++)
        {
      LinguisticAnalysisStructure::MorphoSyntacticData* d1=get(vertex_data,*m_graph,source(*inItr,*m_graph));
      if (d1!=0 && !d1->empty()) {
        cat1=microManager.getPropertyAccessor().readValue(d1->begin()->properties);
      }
      if (!m_trigramMatrix->exists(cat1,cat2,cat3))
      {
          hasNonValidTrigram=true;
          gramNotFound.push_back(gram);
          gramNotFound.back().insert(gramNotFound.back().begin(),cat1);
      }

        }
    if (hasNonValidTrigram) {
        // check if bigram is valid
        if (!m_bigramMatrix->exists(cat2,cat3))
        {
      gramNotFound.push_back(gram);
      hasNonValidBigram=true;
        }
    }

    out << "[label=\"";
    for (std::vector<std::vector<uint64_t> >::iterator it=gramNotFound.begin();
        it!=gramNotFound.end();
        it++)
    {
      copy(it->begin(),it->end(),std::ostream_iterator<uint64_t>(out,","));
      out << "\\l";
    }
    out << "\",style=";
    if (hasNonValidBigram)
    {
      out << "dotted";
    } else if (hasNonValidTrigram)
    {
      out << "dashed";
    }
    else
    {
      out << "solid";
    }
    out << ",fontname=\"Monospace\",fontsize=\"9\"]";
  }
示例#15
0
void GreedyPosTagger::processVertex(LinguisticGraphVertex vx,AnalysisGraph* anagraph) const
{
  LinguisticGraph* graph=anagraph->getGraph();
  LinguisticGraphVertex startVx=anagraph->firstVertex();
  LinguisticGraphVertex endVx=anagraph->lastVertex();

  PTLOGINIT;
  if (vx==startVx || vx==endVx)
  {
    return;
  }
  MorphoSyntacticData* data=get(vertex_data,*graph,vx);
  Token* token=get(vertex_token,*graph,vx);
  if (data==0)
  {
    LERROR << "MorphoSyntacticData of vertex " << vx << " is NULL !";
    return;
  }
  LDEBUG << "process vertex : " << vx << " : " 
    << Common::Misc::limastring2utf8stdstring(token->stringForm());

  MorphoSyntacticData* posdata=new MorphoSyntacticData(*data);
  put(vertex_data,*graph,vx,posdata);
  
  set<LinguisticCode> micros=posdata->allValues(*m_microAccessor);
  LinguisticCode selectedMicro;


  if (micros.size()==0)
  {
    LWARN << "Token " 
      << Common::Misc::limastring2utf8stdstring(token->stringForm()) 
      << " has no possible dicowords ! build a DicoWord with category 0";
    selectedMicro=0;
  }
  else if (micros.size()==1)
  {
    // no choice, put this category
    selectedMicro=*(micros.begin());
    LDEBUG << "GreedyPosTagging : only one choice : " << selectedMicro;
  }
  else
  {
    // choose the most probable dicoWord
    set<LinguisticCode>::iterator dwItr,dwMaxTri,dwMaxBi;
    float maxTri=0;
    float maxBi=0;
    LinguisticCode cat1(0),cat2(0);

    LinguisticGraphInEdgeIt inItr,inItrEnd;
    boost::tie(inItr,inItrEnd)=in_edges(vx,*graph);
    for (;inItr!=inItrEnd;inItr++)
    {
      LinguisticGraphVertex predVx=source(*inItr,*graph);
      MorphoSyntacticData* m2=get(vertex_data,*graph,predVx);
      if (predVx==startVx && m2!=0 && !m2->empty())
      {
        cat2=m_microCatPonctuForte;
      }
      else
      {
        
        cat2=m_microAccessor->readValue(m2->begin()->properties);

        LinguisticGraphInEdgeIt inItr2,inItr2End;
        boost::tie(inItr2,inItr2End)=in_edges(vx,*graph);
        for (;inItr2!=inItr2End;inItr2++)
        {
          LinguisticGraphVertex predpredVx=source(*inItr2,*graph);
          MorphoSyntacticData* m1=get(vertex_data,*graph,predpredVx);
          if (predpredVx==startVx && m1!=0 && !m1->empty())
          {
            cat1=m_microCatPonctuForte;
          }
          else
          {
            cat1=m_microAccessor->readValue(m1->begin()->properties);
          }
          // search better trigram
          for (dwItr=micros.begin();dwItr!=micros.end();dwItr++)
          {
            float p=m_trigramMatrix->freq(cat1,cat2,*dwItr);
            if (p>maxTri)
            {
              maxTri=p;
              dwMaxTri=dwItr;
            }
          }
        }
      }
      if (maxTri==0)
      {
        // no trigram has been found, search bigram
        for (dwItr=micros.begin();dwItr!=micros.end();dwItr++)
        {
          float p=m_bigramMatrix->freq(cat1,*dwItr);
          if (p>maxBi)
          {
            maxBi=p;
            dwMaxBi=dwItr;
          }
        }

      }


    }

    if (maxTri!=0)
    {
      // choose best trigram
      LDEBUG << "found trigram : choose " << *dwMaxTri << " (p=" << maxTri << ")";
      selectedMicro=*dwMaxTri;
    }
    else if (maxBi!=0)
    {
      // choose best bigram
      LDEBUG << "found bigram : choose " << *dwMaxBi << " (p=" << maxBi << ")";
      selectedMicro=*dwMaxBi;
    }
    else
    {
      // no trigram nor bigram has been found
      // choose better probability as source in bigram then as target in bigram
      LWARN << "Found no trigram nor bigram (" << cat1 << "," << cat2 << ") ! try heuristics to find a microcategory";
      for (dwItr=micros.begin();dwItr!=micros.end();dwItr++)
      {
        float p=m_bigramMatrix->freq(m_microCatPonctuForte,*dwItr);
        if (p>maxBi)
        {
          maxBi=p;
          dwMaxBi=dwItr;
        }
      }
      if (maxBi!=0)
      {
        LDEBUG << "found bigram with ponctu forte : choose " << *dwMaxBi <<  " (p=" << maxBi << ")";
        selectedMicro=*dwMaxBi;
      }
      else
      {
        selectedMicro=*(micros.begin());
        LDEBUG << "choose first : " << selectedMicro;
      }
    }
  }
  
  // filter linguisticelement
  CheckDifferentPropertyPredicate cdpp(m_microAccessor,selectedMicro);
  posdata->erase(remove_if(posdata->begin(),posdata->end(),cdpp),posdata->end());
  
}
示例#16
0
文件: genenum.c 项目: spchamp/ilu
PUBLIC char * enm_ioInPiece(Type t) {
    t = enm_assert(t);
    return cat2(enmJName(t), ".from_int(_call.inEnum())");
}
示例#17
0
文件: utility.hpp 项目: YANG-H/Wheels
template <class T, class... Ts> constexpr auto cat(T &&v, Ts &&... vs) {
  return cat2(std::forward<T>(v), cat(std::forward<Ts>(vs)...));
}