Пример #1
0
        public ActionResult Login(LoginModel model, string ReturnUrl)
        {
            if (ModelState.IsValid)
            {
                using (var db = new DAO.Entities())
                {
                    var passHas     = CoreFunction.GetMd5Hash(model.pass);
                    var accountData = db.asp_User.FirstOrDefault(x => x.account == model.acc && x.password == passHas);
                    if (accountData != null)
                    {
                        FormsAuthentication.SetAuthCookie(model.acc, false);

                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        return(RedirectToAction("index", "Home"));
                    }
                    else
                    {
                        TempData["mess"] = "Sai tài khoản hoặc mật khẩu";
                    }
                }
            }
            return(View(model));
        }
Пример #2
0
 static public void GenerateIndependentResult()
 {
     foreach (Sentence sentence in Variable.Sentences)
     {
         sentence.IndependentResult = new Result();
     }
     foreach (Label label in Variable.LabelArray)
     {
         //Variable.OutputFile.WriteLine("Start: " + Variable.LabelToString[label]);
         IList <double> Pdatas = new List <double>();
         Initialize(label);
         for (int time = 1; time <= Variable.ConvergeTimeThreshold; ++time)
         {
             //计算Pk
             NoGroupIDSVariable.Pj = CoreFunction.CalculatePj(NoGroupIDSVariable.Sij, time);
             //计算π
             NoGroupIDSVariable.PAkjl = CoreFunction.CalculatePAkjl(new Label[] { label }, NoGroupIDSVariable.Sij, time, -1);
             //计算Sij
             //if (CoreFunction.CalculatePdataAndSij(new Label[] { label }, ref NoGroupIDSVariable.Sij, NoGroupIDSVariable.Pj, NoGroupIDSVariable.Pajl, NoGroupIDSVariable.Mcj, ref NoGroupIDSVariable.Pdata, -1, Pdatas,
             //    new Dictionary<Tuple<Labelset, Labelset>, double>(), new Dictionary<Tuple<Character, Character>, IDictionary<Tuple<Labelset, Labelset>, double>>()))
             //{
             //    ObtainLabelResult(label);
             //    break;
             //}
         }
     }
     OutputResult();
 }
Пример #3
0
 public static PType[] GetCoreFunctionArgTypes(CoreFunction functionId)
 {
     if (returnTypes == null)
     {
         CoreFunctionUtil.Init();
     }
     return(argTypes[functionId].ToArray());
 }
Пример #4
0
        public static bool[] GetCoreFunctionIsArgTypeRepeated(CoreFunction functionId)
        {
            if (returnTypes == null)
            {
                CoreFunctionUtil.Init();
            }

            return(argTypesRepeated[functionId]);
        }
Пример #5
0
        public static PType GetCoreFunctionReturnType(CoreFunction functionId)
        {
            if (returnTypes == null)
            {
                CoreFunctionUtil.Init();
            }

            return(returnTypes[functionId]);
        }
Пример #6
0
        public CoreFunctionReference(Token firstToken, CoreFunction coreFunctionId, Expression context, ICompilationEntity owner) : base(firstToken, owner)
        {
            this.CoreFunctionId = coreFunctionId;
            this.Context        = context;

            this.ReturnType         = CoreFunctionUtil.GetCoreFunctionReturnType(this.CoreFunctionId);
            this.ArgTypes           = CoreFunctionUtil.GetCoreFunctionArgTypes(this.CoreFunctionId);
            this.ArgTypesIsRepeated = CoreFunctionUtil.GetCoreFunctionIsArgTypeRepeated(this.CoreFunctionId);
        }
Пример #7
0
        private static void Init()
        {
            Dictionary <string, CoreFunction> lookup = new Dictionary <string, CoreFunction>();

            foreach (CoreFunction func in typeof(CoreFunction).GetEnumValues().Cast <CoreFunction>())
            {
                lookup[func.ToString()] = func;
            }

            returnTypes      = new Dictionary <CoreFunction, PType>();
            argTypes         = new Dictionary <CoreFunction, PType[]>();
            argTypesRepeated = new Dictionary <CoreFunction, bool[]>();

            string[] rows = GetCoreFunctionSignatureManifest().Split('\n');
            foreach (string row in rows)
            {
                string definition = row.Trim();
                if (definition.Length > 0)
                {
                    TokenStream tokens     = new TokenStream(Tokenizer.Tokenize("core function manifest", row));
                    PType       returnType = PType.Parse(tokens);
                    string      name       = tokens.Pop().Value;
                    tokens.PopExpected("(");
                    List <PType> argList     = new List <PType>();
                    List <bool>  argRepeated = new List <bool>();
                    while (!tokens.PopIfPresent(")"))
                    {
                        if (argList.Count > 0)
                        {
                            tokens.PopExpected(",");
                        }
                        argList.Add(PType.Parse(tokens));
                        if (tokens.PopIfPresent("."))
                        {
                            argRepeated.Add(true);
                            tokens.PopExpected(".");
                            tokens.PopExpected(".");
                        }
                        else
                        {
                            argRepeated.Add(false);
                        }
                    }

                    if (tokens.HasMore)
                    {
                        throw new Exception("Invalid entry in the manifest. Stuff at the end: " + row);
                    }

                    CoreFunction func = lookup[name];
                    returnTypes[func]      = returnType;
                    argTypes[func]         = argList.ToArray();
                    argTypesRepeated[func] = argRepeated.ToArray();
                }
            }
        }
Пример #8
0
 static public void RunNDDS(double threshold, IndependenceEstimation independentEstimation)
 {
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         Sij sij = Initialize(groupIndex, threshold, independentEstimation);
         CoreFunction.Intgerate(Variable.LabelArray, groupIndex, ref sij);
         DDSFunction.ObtainBinaryResult(sij, "NDDS", groupIndex);
         Function.WriteBinaryResultFile("NDDS", groupIndex);
     }
 }
Пример #9
0
 static public void RunIDDS()
 {
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         Sij sij = Initialize(groupIndex);
         CoreFunction.Intgerate(Variable.LabelArray, groupIndex, ref sij);
         DDSFunction.ObtainBinaryResult(sij, "IDDS", groupIndex);
         Function.WriteBinaryResultFile("IDDS", groupIndex);
     }
 }
Пример #10
0
 static public void RunJDDS()
 {
     //遍历在某个group size分组下的第几组
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         Sij sij = CoreFunction.InitializeSij(Variable.LabelArray, groupIndex);
         CoreFunction.Intgerate(Variable.LabelArray, groupIndex, ref sij);//迭代在此
         DDSFunction.ObtainBinaryResult(sij, "JDDS", groupIndex);
         Function.WriteBinaryResultFile("JDDS", groupIndex);
     }
 }
Пример #11
0
 static public void GenerateOneTreeForAllResult()
 {
     Initialize();
     for (int time = 1; time <= Variable.ConvergeTimeThreshold; ++time)
     {
         //计算Pk
         TDDSVariable.Pj = CoreFunction.CalculatePj(TDDSVariable.Sij, time);
         //计算π
         NoGroupDDSFunction.CalculatePAkjl(TDDSVariable.Sij, ref TDDSVariable.PAkjl);
         //计算Sij
         if (NoGroupDDSFunction.CalculatePdataAndSij(ref TDDSVariable.Sij, TDDSVariable.Pj, TDDSVariable.PAkjl, ref TDDSVariable.Pdata))
         {
             break;
         }
     }
     NoGroupDDSFunction.ObtainResult(TDDSVariable.Sij, "TreeForAll");
 }
Пример #12
0
 static public void GenerateOneTreeForSenResult()
 {
     Initialize();
     for (int time = 1; time <= Variable.ConvergeTimeThreshold; ++time)//其中几个函数可以和Dependent公用
     {
         //计算Pk
         DTDDSVariable.Pj = CoreFunction.CalculatePj(DTDDSVariable.Sij, time);
         //计算π
         NoGroupDDSFunction.CalculatePAkjl(DTDDSVariable.Sij, ref DTDDSVariable.PAkjl);
         //计算Sij
         if (NoGroupDDSFunction.CalculatePdataAndSij(ref DTDDSVariable.Sij, DTDDSVariable.Pj, DTDDSVariable.PAkjl, ref DTDDSVariable.Pdata))
         {
             break;
         }
     }
     NoGroupDDSFunction.ObtainResult(DTDDSVariable.Sij, "TreeForSen");
 }
Пример #13
0
 static public void GeneratePreciseResult()
 {
     Initialize();
     for (int time = 1; time <= Variable.ConvergeTimeThreshold; ++time)
     {
         //计算Pk
         NoGroupJDDSVariable.Pj = CoreFunction.CalculatePj(NoGroupJDDSVariable.Sij, time);
         //计算π
         NoGroupDDSFunction.CalculatePAkjl(NoGroupJDDSVariable.Sij, ref NoGroupJDDSVariable.PAkjl);
         //计算Sij
         if (NoGroupDDSFunction.CalculatePdataAndSij(ref NoGroupJDDSVariable.Sij, NoGroupJDDSVariable.Pj, NoGroupJDDSVariable.PAkjl, ref NoGroupJDDSVariable.Pdata))
         {
             break;
         }
     }
     NoGroupDDSFunction.ObtainResult(NoGroupJDDSVariable.Sij, "Precise");
 }
Пример #14
0
 static public void RunIDS()
 {
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         foreach (Sentence sentence in Variable.Sentences)
         {
             sentence.AnnotaitonGroups[groupIndex].IDSNumResult = new NumericResult();
             sentence.AnnotaitonGroups[groupIndex].IDSResult    = new Result();
         }
         foreach (Label label in Variable.LabelArray)
         {
             Sij sij = CoreFunction.InitializeSij(new Label[] { label }, groupIndex);
             CoreFunction.Intgerate(new Label[] { label }, groupIndex, ref sij);
             ObtainLabelResult(sij, groupIndex);
         }
         Function.WriteBinaryResultFile("IDS", groupIndex);
     }
 }
Пример #15
0
 static public void RunPDS()
 {
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         foreach (Sentence sentence in Variable.Sentences)
         {
             sentence.AnnotaitonGroups[groupIndex].PDSNumResult = new NumericResult();
             sentence.AnnotaitonGroups[groupIndex].PDSResult    = new Result();
         }
         LabelPair[] bilabels = GenerateBilabels(groupIndex);
         foreach (LabelPair bilabel in bilabels)
         {
             Sij sij = CoreFunction.InitializeSij(bilabel.ToArray(), groupIndex);
             CoreFunction.Intgerate(bilabel.ToArray(), groupIndex, ref sij);
             ObtainLabelResult(bilabel, groupIndex, sij);
         }
         Function.WriteBinaryResultFile("PDS", groupIndex);
     }
 }
Пример #16
0
 static public void RunPeTM(PorSForJointje PorS, Smoothing SmoothingBE, BnOrNot bnOrNot)
 {
     double[] accuracyOfPersonalityForEachGroup = new double[GroupVariable.AnnotatorGroups.Length];
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         IDictionary <Annotator, IDictionary <Character, IDictionary <Will, double> > > okcx = PersonalityFunction.CalculateOkcx(groupIndex);//模拟人对角色个性的标注,计算一次就不变了
         Mce  mce  = InitializeMce(groupIndex);
         Sije sije = null;
         if (bnOrNot == BnOrNot.Yes)
         {
             sije = InitializeSijeWithBN(mce, groupIndex);
         }
         else
         {
             sije = InitializeSije(mce, groupIndex); //old new
         }
         Pje            pje    = null;               //p(t|e)
         Pdata          pdata  = null;
         IList <double> Pdatas = new List <double>();
         for (int convergeTime = 1; convergeTime <= Variable.ConvergeTimeThreshold; ++convergeTime)
         {
             mce = CalculateMce(sije, groupIndex);
             PAkjl pakjl = CoreFunction.CalculatePAkjl(Variable.LabelArray, sije.ToSij, convergeTime, groupIndex);
             BEkef bekef = PersonalityFunction.CalculateBExy(mce, okcx, SmoothingBE, convergeTime, groupIndex);
             if (PorS == PorSForJointje.P)
             {
                 pje = CalculatePje(sije, convergeTime);
             }
             if (CalculatePdataAndSije(ref sije, pakjl, bekef, pje, mce, okcx, ref pdata, Pdatas, groupIndex))//old/new
             {
                 break;
             }
         }
         IDictionary <Sentence, IDictionary <Will, double> > sic = ObtainBinaryResult(sije, mce, groupIndex);
         WriteBinaryResultFile(sic, mce, groupIndex);
         PersonalityFunction.WriteMVResultFile(mce, groupIndex);
         accuracyOfPersonalityForEachGroup[groupIndex] = PersonalityPaperFunction.AccuracyOfPersonalityForEachGroup(PersonalityVariable.TruePersonality, mce.EstimatedPersonality);
     }
     Function.ConsoleWriteLine("Accuracy Of PeTM: " + PersonalityPaperFunction.AccuracyOfPersonality(accuracyOfPersonalityForEachGroup));
 }
Пример #17
0
 static public void RunTDDS()
 {
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         Initialize(groupIndex);
         IList <double> Pdatas = new List <double>();
         for (int time = 1; time <= Variable.ConvergeTimeThreshold; ++time)
         {
             //计算Pk
             //计算Pk,mcj(consistent:角色c有j标签的概率)
             ChoiceFunction.PriorPj(ref TDDSVariable.Pj, ref TDDSVariable.Mcj, TDDSVariable.Sij, time);
             //计算π
             TDDSVariable.PAkjl = CoreFunction.CalculatePAkjl(Variable.LabelArray, TDDSVariable.Sij, time, groupIndex);
             //计算Sij
             //if (CoreFunction.CalculatePdataAndSij(Variable.LabelArray, ref TDDSVariable.Sij, TDDSVariable.Pj, TDDSVariable.Pajl, TDDSVariable.Mcj, ref TDDSVariable.Pdata, groupIndex, Pdatas,
             //    TDDSVariable.ConditionalPj, TDDSVariable.ConditionalMcj))
             //break;
         }
         DDSFunction.ObtainBinaryResult(TDDSVariable.Sij, "TDDS", groupIndex);
         DDSFunction.ObtainNumericResult(TDDSVariable.Sij, "TDDS", groupIndex);
         Function.WriteBinaryResultFile("TDDS", groupIndex);
     }
 }
 public ActionResult Account(CreateAccountModel model)
 {
     if (ModelState.IsValid)
     {
         using (var db = new Entities())
         {
             var data = db.asp_User.FirstOrDefault(x => x.account == model.account);
             if (data == null)
             {
                 //check mat khau
                 if (string.IsNullOrEmpty(model.password))
                 {
                     TempData["mess"] = "Bạn chưa nhập mật khẩu";
                     return(RedirectToAction("ListAccount", new { id = model.account }));
                 }
                 data = new asp_User
                 {
                     account  = model.account,
                     userName = model.name,
                     password = CoreFunction.GetMd5Hash(model.password),
                     email    = model.email
                 };
                 foreach (var item in model.groups)
                 {
                     if (item.check && !data.asp_Group.Any(x => x.id == item.id))
                     {
                         var groupItem = db.asp_Group.FirstOrDefault(x => x.id == item.id);
                         if (groupItem != null)
                         {
                             data.asp_Group.Add(groupItem);
                         }
                     }
                     else if (!item.check && data.asp_Group.Any(x => x.id == item.id))
                     {
                         var groupItem = db.asp_Group.FirstOrDefault(x => x.id == item.id);
                         if (groupItem != null)
                         {
                             data.asp_Group.Remove(groupItem);
                         }
                     }
                 }
                 db.asp_User.Add(data);
                 db.SaveChanges();
                 TempData["mess"] = "Đã thêm dữ liệu thành công";
             }
             else if (model.edit)
             {
                 data.userName = model.name;
                 if (!string.IsNullOrEmpty(model.password))
                 {
                     data.password = CoreFunction.GetMd5Hash(model.password);
                 }
                 data.email = model.email;
                 foreach (var item in model.groups)
                 {
                     if (item.check && !data.asp_Group.Any(x => x.id == item.id))
                     {
                         var groupItem = db.asp_Group.FirstOrDefault(x => x.id == item.id);
                         if (groupItem != null)
                         {
                             data.asp_Group.Add(groupItem);
                         }
                     }
                     else if (!item.check && data.asp_Group.Any(x => x.id == item.id))
                     {
                         var groupItem = db.asp_Group.FirstOrDefault(x => x.id == item.id);
                         if (groupItem != null)
                         {
                             data.asp_Group.Remove(groupItem);
                         }
                     }
                 }
                 db.SaveChanges();
                 TempData["mess"] = "Đã cập nhật dữ liệu thành công";
             }
             else
             {
                 TempData["mess"] = "Tài khoản đã tồn tại";
             }
         }
     }
     return(RedirectToAction("ListAccount", new { id = model.account }));
 }
Пример #19
0
 public CoreFunctionInvocation(Token firstToken, CoreFunction function, Expression context, IList <Expression> args, ICompilationEntity owner)
     : this(firstToken, function, PushInFront(context, args), owner)
 {
 }
Пример #20
0
 public CoreFunctionReference(Token firstToken, CoreFunction coreFunctionId, ICompilationEntity owner) : this(firstToken, coreFunctionId, null, owner)
 {
 }
Пример #21
0
 public CoreFunctionInvocation(Token firstToken, CoreFunction function, IList <Expression> args, ICompilationEntity owner) : base(firstToken, owner)
 {
     this.Function = function;
     this.Args     = args.ToArray();
 }
Пример #22
0
        public override Expression ResolveNamesAndCullUnusedCode(PastelCompiler compiler)
        {
            this.Root = this.Root.ResolveNamesAndCullUnusedCode(compiler);

            if (this.Root is EnumReference)
            {
                InlineConstant enumValue = ((EnumReference)this.Root).EnumDef.GetValue(this.FieldName);
                return(enumValue.CloneWithNewToken(this.FirstToken));
            }

            if (this.Root is DependencyNamespaceReference)
            {
                PastelCompiler     dependencyScope = ((DependencyNamespaceReference)this.Root).Scope;
                string             field           = this.FieldName.Value;
                FunctionDefinition funcDef         = dependencyScope.GetFunctionDefinition(field);
                if (funcDef != null)
                {
                    return(new FunctionReference(this.FirstToken, funcDef, this.Owner));
                }

                EnumDefinition enumDef = dependencyScope.GetEnumDefinition(field);
                if (enumDef != null)
                {
                    return(new EnumReference(this.FirstToken, enumDef, this.Owner));
                }

                InlineConstant constValue = dependencyScope.GetConstantDefinition(field);
                if (constValue != null)
                {
                    return(constValue.CloneWithNewTokenAndOwner(this.FirstToken, this.Owner));
                }

                throw new ParserException(this.FieldName, "The namespace '" + ((DependencyNamespaceReference)this.Root).FirstToken.Value + "' does not have a member called '" + field + "'");
            }

            if (this.Root is CoreNamespaceReference)
            {
                CoreFunction coreFunction = this.GetCoreFunction(this.FieldName.Value);
                switch (coreFunction)
                {
                case CoreFunction.FLOAT_BUFFER_16:
                case CoreFunction.INT_BUFFER_16:
                case CoreFunction.STRING_BUFFER_16:
                    return(new CoreFunctionInvocation(this.FirstToken, coreFunction, new Expression[0], this.Owner));

                default:
                    return(new CoreFunctionReference(this.FirstToken, coreFunction, this.Owner));
                }
            }

            if (this.Root is ExtensibleNamespaceReference)
            {
                string name = this.FieldName.Value;
                return(new ExtensibleFunctionReference(this.FirstToken, name, this.Owner));
            }

            if (this.Root is EnumReference)
            {
                EnumDefinition enumDef   = ((EnumReference)this.Root).EnumDef;
                InlineConstant enumValue = enumDef.GetValue(this.FieldName);
                return(enumValue);
            }

            return(this);
        }