如何将文本文件转换为swi-prolog事实?

时间:2017-05-10 20:19:17

标签: parsing prolog swi-prolog file-conversion

我希望prolog能够阅读用户上传的文本文件,将其转换为prolog事实并将其存储在知识库中。此文本文件应该是以下格式的学生成绩单。我对prolog很新,所以,我不知道它是否可能,因为文本文件有一些垃圾和重复数据,我只想采取它的某些部分。

示例:这是文本文件

Main Menu </cgi/regweb/stu_login.main_menu>

_

    *Academic Transcript*_

    *Year/Semester:*

        2013 / 1    *Number :*  20131234
    *Name               :*  Mary Georgia    *Advisor :*     Mr.Paul Watson
    *Degree             :*  B.Sc. in Information Systems    *Status    :*   

    ------------------------------------------------------------------------
    *Course*    *Course Name*   *Credit*    *Grade*     *Status*    *Repeated*
    ENGL    154     LANGUAGE DEVELOPMENT I  3   A   -   0
    ITCS    103     COMPUTER PROGRAMMING 1  4   A   -   0
    ITIS    101     PERSONAL PRODUCTIVITY WITH IS TECHNOLOGY    3   A-  -   0
    MATHS   101     CALCULUS I  3   B+  -   0

    ------------------------------------------------------------------------
    *Semester Credits Attended   :*     13  *Passed:*   13  *GPA:*  3.92
    *Cumulative Credits Attended:*  13  *Passed:*   13  *GPA:*  3.92

    ------------------------------------------------------------------------
    */STUDENT COPY - äÓÎÉ ÇáØÇáÈ /*

    *åÐå ÇáäÓÎÉ ÛíÑ ÑÓãíÉ æáÇ ÊÚÑÖ ÍÇáÉ ÇáØÇáÈ ÇáÃßÇÏíãíÉ
    Úáì ÇáØÇáÈ ÇÓÊÎÑÇÌ äÓÎÉ ßÔÝ ÇáÏÑÌÇÊ ÇáÑÓãíÉ ãä ãßÊÈ ÇáÊÓÌíá*
    *This is not an Official Transcript and Does Not State The Academic Status
    Students must obtain detailed Official Transcript of their Academic
    Status from the Registration Offices *

    ------------------------------------------------------------------------
    *****************  End  Of   Transcript  For   2013 / 1  *******************

    ------------------------------------------------------------------------

    *Year/Semester:*

        2013 / 2    *Number :*  20131234
    *Name               :*  Mary Georgia    *Advisor :*     Mr.Paul Watson
    *Degree             :*  B.Sc. in Information Systems    *Status    :*   


    ------------------------------------------------------------------------
    *Course*    *Course Name*   *Credit*    *Grade*     *Status*    *Repeated*
    ACC     112     FINANCIAL ACCOUNTING I  3   B-  -   0
    ECON    140     MICROECONOMICS  3   A-  -   0
    ENGL    155     LANGUAGE DEVELOPMENT II     3   A   -   0
    ITCS    104     COMPUTER PROGRAMMING 2  4   A   -   0
    MGT     131     INTRO. TO BUSINESS ADMINISTRATION   3   A   -   0

    ------------------------------------------------------------------------
    *Semester Credits Attended   :*     16  *Passed:*   16  *GPA:*  3.82
    *Cumulative Credits Attended:*  29  *Passed:*   29  *GPA:*  3.87

    ------------------------------------------------------------------------
    */STUDENT COPY - äÓÎÉ ÇáØÇáÈ /*

    *åÐå ÇáäÓÎÉ ÛíÑ ÑÓãíÉ æáÇ ÊÚÑÖ ÍÇáÉ ÇáØÇáÈ ÇáÃßÇÏíãíÉ
    Úáì ÇáØÇáÈ ÇÓÊÎÑÇÌ äÓÎÉ ßÔÝ ÇáÏÑÌÇÊ ÇáÑÓãíÉ ãä ãßÊÈ ÇáÊÓÌíá*
    *This is not an Official Transcript and Does Not State The Academic Status
    Students must obtain detailed Official Transcript of their Academic
    Status from the Registration Offices *

    ------------------------------------------------------------------------
    *****************  End  Of   Transcript  For   2013 / 2  *******************

    ------------------------------------------------------------------------

Prolog知识库:

  

学生(编号,姓名,Total_Credits_Passed,累积GPA,顾问)

student(20131234,'Mary Georgia',29,3.87,'Mr.Paul Watson').
  

coursestaken(号码,年份,学期courseslist(course1,course2,course3,course4,course5,course6,course7),等级(gradeofcourse1,gradeofcourse2,gradeofcourse3,gradeofcourse4,gradeofcourse5,gradeofcourse6,gradeofcourse7)

coursestaken(20131234,2013,1,courseslist(ENGL154,ITCS103,ITIS101,MATHS101,_,_,_),grades(A,A,A-,B+,_,_,_)).
如果有的话,

在其他学期做同样的事。

任何帮助都将受到高度赞赏。

0 个答案:

没有答案