Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                if (Request.QueryString["q"] != null)
                {
                    List<string> inputKeyWords = parseString(Request.QueryString["q"].ToString());
                    List<string> inputKeyWordsURI = new List<string>();
                    List<string> microHtmlPic = new List<string>();
                    List<string> microHtmlLabel = new List<string>();
                    string HTML;
                    keywordSearchServiceInterfaceClient keyWordsClient = new keywordSearchServiceInterfaceClient();

                    foreach (string keyword in inputKeyWords)
                    {
                        inputKeyWordsURI.Add(keyWordsClient.geturi_bestMatch(keyword));
                    }

                    ProfileConstructorInterfaceClient profileClient = new ProfileConstructorInterfaceClient();
                    List<MicroProfile> profiles = new List<MicroProfile>();
                    foreach (string keyword in inputKeyWordsURI)
                    {
                        profiles.Add((MicroProfile)profileClient.ConstructProfile(keyword, MergedServicechoiceProfile.micro, 1));
                    }

                    List<string> htmlTable = new List<string>();//<tr><td><div class="imgcontainer"><img src="testimg/220px-WikiBex.jpg" /></div></td></tr><tr><td class="title">hany</td></tr>
                    HTML = "<table class=\"relateTable\"><tr>";
                    foreach (MicroProfile microProfile in profiles)
                    {
                        HTML += "<td><div class=\"imgcontainer\"><a href=\"answer.aspx?uri=" + microProfile.URI + "\"><img src=\"" + microProfile.Picture + "\" /></a></div></td>";
                    }
                    HTML += "</tr><tr>";
                    foreach (MicroProfile microProfile in profiles)
                    {
                        HTML += "<td class=\"title\"><a href=\"answer.aspx?uri=" + microProfile.URI + "\">" + microProfile.Label + "</a></td>";
                    }
                    HTML += "</tr></table>";
                    HTML += "<script>var mainNodes = \"" + string.Join(",", inputKeyWordsURI.ToArray()) + "\"; </script>";
                    headerTable.InnerHtml = HTML;
                }
                //if nothing is sent in q parameter
                else
                {
                    //headerTable.InnerHtml = "<h2>There were no parameters to relate between</h2>";
                    answerbox.InnerHtml = "<h2>There were no parameters to relate between.....</h2>";

                }
            }
            catch (Exception c)
            {
                Util.log("RELATION ERROR" + c.Message);
                Response.Redirect("error.aspx");

            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                String question = Request.QueryString["q"];
                String uri = Request.QueryString["uri"];
                String HTML = "";

                if (question != null && uri == null)
                {
                    List<KeyValuePair<questionAnswer, List<Profile>>> QNDiffProfiles = QuestionAnswerer.getAnswersInProfiles(question);
                    if (QNDiffProfiles.Count == 0)
                        HTML += "<div> No results found </div>";
                    if (QNDiffProfiles.Count > 1)
                    {
                        HTML += "<ul id=\"menu\" class=\"menu\">";
                        for (int x = 0; x < QNDiffProfiles.Count; x++)
                        {
                            questionAnswer answer = QNDiffProfiles[x].Key;
                            if (x == 0)
                                HTML += "<li class=\"active\"><a href=\"#tab" + x + "\">" + answer.predicateLabelList.Keys.ToList()[0] + " of " + answer.subjectLabelList.Keys.ToList()[0] + "</a></li>";
                            else
                                HTML += "<li><a href=\"#tab" + x + "\">" + answer.predicateLabelList.Keys.ToList()[0] + " of " + answer.subjectLabelList.Keys.ToList()[0] + "</a></li>";
                        }
                        HTML += "</ul>";
                    }

                    foreach (KeyValuePair<questionAnswer, List<Profile>> QNProfiles in QNDiffProfiles)
                    {
                        questionAnswer answer = QNDiffProfiles[0].Key;
                        List<Profile> profiles = QNProfiles.Value;
                        bool isCountAnswer = false;
                        if (QNProfiles.Key.questiontype == utilquestionTypes.countAnswer)
                            isCountAnswer = true;
                        if (QNDiffProfiles.Count > 1)
                            HTML += "<div id=\"tab" + QNDiffProfiles.IndexOf(QNProfiles) + "\">";
                        else
                            HTML += "<div>";
                        if(QNProfiles.Key.predicateLabelList.Keys.ToList().Count>0 && QNProfiles.Key.subjectLabelList.Keys.ToList().Count>0)
                            HTML += "<div>" + QNProfiles.Key.predicateLabelList.Keys.ToList()[0] + " of " + "<a href=\"answer.aspx?uri=" + QNProfiles.Key.subjectUriList.Keys.ToList()[0] + "\">" + QNProfiles.Key.subjectLabelList.Keys.ToList()[0] + "</a>" + "</div>";

                        foreach (Profile profile in profiles)
                        {
                            if (profile is FullProfile)
                            {
                                FullProfile fullProfile = (FullProfile)profile;
                                HTML += showFullProfile(fullProfile, isCountAnswer, profiles.Count, answer.predicateLabelList.Keys + " of " + answer.subjectLabelList.Keys);
                            }

                            else if (profile is MiniProfile)
                            {
                                MiniProfile miniProfile = (MiniProfile)profile;
                                HTML += showMiniProfie(miniProfile, isCountAnswer, profiles.Count, answer.predicateLabelList.Keys + " of " + answer.subjectLabelList.Keys);

                            }
                            else if (profile is MicroProfile)
                            {
                                MicroProfile microProfile = (MicroProfile)profile;
                                HTML += showMicroProfile(microProfile, isCountAnswer, profiles.Count, answer.predicateLabelList.Keys + " of " + answer.subjectLabelList.Keys);
                            }
                            else if (profile is LiteralProfile)
                            {
                                LiteralProfile LP = (LiteralProfile)profile;
                                HTML += showLiteralProfile(LP);
                            }
                        }
                        HTML += "</div>";
                    }
                }
                else if (uri != null && question == null)
                {
                    ProfileConstructorInterfaceClient PCIClient = new ProfileConstructorInterfaceClient();
                    FullProfile fullProfile = (FullProfile)PCIClient.ConstructProfile(uri, MergedServicechoiceProfile.full, 50);
                    HTML = showFullProfile(fullProfile, false, 0, "");
                }

                else if (uri == null && question == null)
                { }
                else
                    Response.Redirect("error.aspx");
                answerbox.InnerHtml = HTML;
            }
            catch (Exception exep)
            {
                Util.log(exep.Message);
                Response.Redirect("error.aspx");
            }
        }
Ejemplo n.º 3
0
        public static List<KeyValuePair<questionAnswer, List<Profile>>> getAnswersInProfiles(String question)
        {
            try
            {
                QAServiceInterfaceClient QAClient = new QAServiceInterfaceClient();
                ProfileConstructorInterfaceClient profileClient = new ProfileConstructorInterfaceClient();
                List<questionAnswer> answersForDiffQuestions = QAClient.GetAnswerWithQuestionStructure(question).ToList();
                List<List<Profile>> allAnswers = new List<List<Profile>>();
                List<KeyValuePair<questionAnswer, List<Profile>>> output = new List<KeyValuePair<questionAnswer, List<Profile>>>();
                bool isKeywordSearch = true;
                foreach (questionAnswer qAnswer in answersForDiffQuestions)
                    if (qAnswer.predicateUriList.Count != 0 || qAnswer.subjectUriList.Count != 0)
                    {
                        isKeywordSearch = false;
                        break;
                    }
                if (isKeywordSearch == false)
                {
                    foreach (questionAnswer qAnswer in answersForDiffQuestions)
                    {
                        if (qAnswer.questiontype == utilquestionTypes.URIAsnwer)
                        {
                            List<String> answers = qAnswer.objectUriList.ToList();
                            if (answers.Count == 1)
                            {
                                List<Profile> fullProfile = new List<Profile>();
                                fullProfile.Add(profileClient.ConstructProfile(answers[0], MergedServicechoiceProfile.full, 200));
                                KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(qAnswer, fullProfile);
                                output.Add(questionNAnswer);
                            }
                            else if (answers.Count < 4 && answers.Count > 1)
                            {
                                List<Profile> miniProfiles = new List<Profile>();
                                foreach (String answer in answers)
                                    miniProfiles.Add(profileClient.ConstructProfile(answer, MergedServicechoiceProfile.mini, 7));
                                KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(qAnswer, miniProfiles);
                                output.Add(questionNAnswer);
                            }
                            else
                            {
                                List<Profile> microProfiles = new List<Profile>();
                                foreach (String answer in answers)
                                    microProfiles.Add(profileClient.ConstructProfile(answer, MergedServicechoiceProfile.micro, 7));
                                KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(qAnswer, microProfiles);
                                output.Add(questionNAnswer);
                            }
                        }
                        else if (qAnswer.questiontype == utilquestionTypes.literalAnswer)
                        {
                            List<Profile> LPLIST = new List<Profile>();
                            // string h= qAnswer.subjectUriList.Keys.ToList()[0];
                            LPLIST.Add(profileClient.ConstructLiteralProfile(qAnswer.subjectUriList.Keys.ToList()[0], qAnswer.predicateLabelList.Keys.ToList()[0], qAnswer.subjectLabelList.Keys.ToList()[0], "jkfjk", qAnswer.objectUriList[0], qAnswer.predicateUriList.Keys.ToList()[0]));

                            KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(qAnswer, LPLIST);
                            output.Add(questionNAnswer);

                        }

                    }
                }
                else
                {
                    List<String> answers = new List<String>();
                    foreach (questionAnswer answer in answersForDiffQuestions)
                        if (answer.objectUriList.Length > 0)
                            answers.Add(answer.objectUriList[0]);
                    if (answers.Count == 1)
                    {
                        List<Profile> fullProfile = new List<Profile>();
                        fullProfile.Add(profileClient.ConstructProfile(answers[0], MergedServicechoiceProfile.full, 200));
                        KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(answersForDiffQuestions[0], fullProfile);
                        output.Add(questionNAnswer);
                    }
                    else if (answers.Count < 4 && answers.Count > 1)
                    {
                        List<Profile> miniProfiles = new List<Profile>();
                        foreach (String answer in answers)
                            miniProfiles.Add(profileClient.ConstructProfile(answer, MergedServicechoiceProfile.mini, 7));
                        if (answersForDiffQuestions.Count > 0)
                        {
                            KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(answersForDiffQuestions[0], miniProfiles);
                            output.Add(questionNAnswer);
                        }
                    }
                    else
                    {
                        List<Profile> microProfiles = new List<Profile>();
                        foreach (String answer in answers)
                            microProfiles.Add(profileClient.ConstructProfile(answer, MergedServicechoiceProfile.micro, 7));
                        if (answersForDiffQuestions.Count > 0)
                        {
                            KeyValuePair<questionAnswer, List<Profile>> questionNAnswer = new KeyValuePair<questionAnswer, List<Profile>>(answersForDiffQuestions[0], microProfiles);
                            output.Add(questionNAnswer);
                        }
                    }
                }
                return output;
            }
            catch (Exception exep)
            {
                Util.log(exep.Message);
                System.Web.HttpContext.Current.Response.Redirect("error.aspx", false);
                return null;
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if there's no query, return the original page (this case should never happen)
            try
            {
                if (Request.QueryString["q"] == null)
                {
                    answerbox.InnerHtml = "<h3> No parameters to compare between... </h3>";
                    return;
                }
                else
                {

                    //parsing the parameters
                    List<string> parsedStringsList = parseString(Request.QueryString["q"].ToString());

                    //the outputURIs
                    List<string> outputURIs = new List<string>();

                    //using the keyword search to get the URIs
                    keywordSearchServiceInterfaceClient kwClient = new keywordSearchServiceInterfaceClient();
                    foreach (string item in parsedStringsList)
                    {
                        outputURIs.Add(kwClient.geturi_bestMatch(item));

                    }

                    //comparing between the translated uris
                    List<ResourceInformation> comparisonOutput = new List<ResourceInformation>();
                    ComparisonServiceInterfaceClient comparisonClient = new ComparisonServiceInterfaceClient();
                    comparisonOutput = comparisonClient.Compare(outputURIs.ToArray()).ToList();

                    // comparisonOutput = preprocessingComparisonObjects(comparisonOutput);

                    //getting the micro profiles
                    ProfileConstructorInterfaceClient constructProfile = new ProfileConstructorInterfaceClient();
                    List<MicroProfile> MicroProfilesList = new List<MicroProfile>();

                    foreach (string item in outputURIs)
                    {
                        MicroProfilesList.Add((MicroProfile)constructProfile.ConstructProfile(item, MergedServicechoiceProfile.micro, 10));

                    }

                    //output to the divs
                    //First the microProfile
                    answerbox.InnerHtml = "";
                    answerbox.InnerHtml +=
                        "<div class=\"comparisonbox tableheader\">" +
                        "<div class=\"predicate\">" +
                            "<p></p>" +
                        "</div>" +
                        "<div class=\"window\">" +
                            "<div class=\"datarow\">";

                    //this was added to handle the maps if available

                    foreach (MicroProfile item in MicroProfilesList)
                    {
                        answerbox.InnerHtml += "<div class=\"datacell\">" +
                                    "<a href=\"answer.aspx?uri=" + item.URI + " \"><img src=\"" + item.Picture + "\" />  </a>" +
                                    "<div class=\"title\"> <a href=\"answer.aspx?uri=" + item.URI + "\">" + item.Label + "</a></div>" +
                            //"<div class=\"Abstract\">" + item.Abstract + "</div>" +
                                "</div>";

                    }

                    answerbox.InnerHtml += "</div>" +
                        "</div>" +
                        "<div class=\"clearfix\">" +
                        "</div>" +
                    "</div>";

                    //right till now
                    //will crash if no comparison........

                    //now for the data for each entity
                    int numberOfPredicates = comparisonOutput[0].FinalComparisonObject.ToList().Count;
                    int numberOfObjects = comparisonOutput.Count;
                    //Second the table values

                    ////////////////THE MAPS PART///////////
                    if (canViewMap(comparisonOutput))
                    {
                        answerbox.InnerHtml += "<div class=\"comparisonbox expandableContent\">" +
                        "<div class=\"predicate\">" +
                            //this returns the predicate of all the tables
                        "Map" +
                        "</div>";

                        answerbox.InnerHtml += "<div class=\"window\">" +
                            "<div class=\"datarow\">";
                        List<string> mapstrings = viewMap(comparisonOutput);
                        foreach (string item in mapstrings)
                        {
                            answerbox.InnerHtml += "<div class=\"datacell\">";
                            answerbox.InnerHtml += item;
                            answerbox.InnerHtml += "</div>";

                        }
                        answerbox.InnerHtml += "</div>" +
                            "</div>" +
                            "</div>";
                    }
                    ////////////////////////////////////////////////////////

                    //comparisonOutput = removeUnwantedPredicates(comparisonOutput.ToList()).ToList();

                    for (int i = 0; i < numberOfPredicates; i++)
                    {
                        //check if the predicate is of the ones that should be excluded
                        if (isExcludedURI(comparisonOutput[0].FinalComparisonObject[i].Key.Key))
                            continue;

                        answerbox.InnerHtml += "<div class=\"comparisonbox expandableContent\">" +
                        "<div class=\"predicate\">" +
                            //this returns the predicate of all the tables
                        comparisonOutput[0].FinalComparisonObject[i].Key.Value +
                        "</div>";

                        answerbox.InnerHtml += "<div class=\"window\">" +
                            "<div class=\"datarow\">";

                        for (int j = 0; j < numberOfObjects; j++)
                        {
                            answerbox.InnerHtml += "<div class=\"datacell\">";
                            //should be in a href key and value
                            for (int k = 0; k < comparisonOutput[j].FinalComparisonObject[i].Value.ToList().Count; k++)
                            {
                                //we check if it's a uri or not
                                string uri = comparisonOutput[j].FinalComparisonObject[i].Value[k].Key;
                                string value = HttpUtility.HtmlDecode(comparisonOutput[j].FinalComparisonObject[i].Value[k].Value);
                                if (Uri.IsWellFormedUriString(uri, UriKind.Absolute))
                                {
                                    if (Uri.IsWellFormedUriString(value, UriKind.Absolute))
                                    {
                                        answerbox.InnerHtml += "<span><a href=\"" + uri + "\">" + value + "</a><br/></span>";
                                    }
                                    else
                                    {
                                        answerbox.InnerHtml += "<span><a href=\"answer.aspx?uri=" + uri + "\">" + value + "</a><br/></span>";
                                    }

                                }

                                else
                                {
                                    answerbox.InnerHtml += "<span>" + value + "<br/></span>";
                                }

                            }
                            answerbox.InnerHtml += "</div>";
                        }
                        answerbox.InnerHtml += "</div>" +
                            "</div>" +
                            "</div>";

                    }

                    answerbox.InnerHtml += "</div>";

                }
            }
            catch (Exception c)
            {

                //logging should go here
                Util.log("Comparison>> Message: " + c.Message + " Data: " + c.Data);
                Response.Redirect("error.aspx", false);

            }
        }