0

问题

我正在尝试 It's sunny on Monday and rainy on Tuesday使用 RGL 在 GF 上生成句子。我在 RGL 页面上寻找了一种生成这句话的方法,但我找不到任何可能对此有所帮助的方法。在GitHubExtend.gf上查看了有关 GF 的更多信息,我发现了这三行:

    MkVPS      : Temp -> Pol -> VP -> VPS ;  -- hasn't slept
    ConjVPS    : Conj -> [VPS] -> VPS ;      -- has walked and won't sleep
    PredVPS    : NP   -> VPS -> S ;          -- she [has walked and won't sleep]

乍一看,它们似乎很有希望,但是当我尝试在真实代码上实现它们时,似乎我误用了[VPS]. 我的代码:

mkPhr(PredVPS
        (it_NP)
        (ConjVPS
            (and_Conj)
            (MkVPS
                (mkTemp (futureTense) (simultaneousAnt))
                (positivePol)
                (mkVP
                    (mkVP (mkA "sunny"))
                    (SyntaxEng.mkAdv (on_Prep) (mkNP (mkN ("Monday"))))))
            (MkVPS
                (mkTemp (futureTense) (simultaneousAnt))
                (positivePol)
                (mkVP
                    (mkVP (mkA "rainy"))
                    (SyntaxEng.mkAdv (on_Prep) (mkNP (mkN ("Tuesday"))))))));

但是我遇到了这个错误,这显然是定义变量和预期变量的问题。

missing record fields: s1, s2 type of MkVPS (mkTemp futureTense simultaneousAnt) positivePol (AdvVP ((\a -> UseComp (CompAP (PositA a))) (regA "rainy")) (PrepNP on_Prep ((\n -> MassNP (UseN n)) (regN "Monday"))))
      expected: {s1 : ResEng.Agr => Str; s2 : ResEng.Agr => Str}
      inferred: {s : ResEng.Agr => Str; lock_VPS : {}}

问题

正确的使用方法是[VPS]什么?

4

1 回答 1

1

澄清清单

就像其他列表 category 一样C,您需要使用一个构造函数,该构造函数需要两个(或更多)Cs 并创建一个[C].

对于 RGL API 中的类别,有 type 的便捷操作符mkC : Conj -> C -> C -> C,但在底层,这些操作符还需要为[C]. (构造函数称为BaseCand ,您可以在此处ConsC阅读有关列表的更多信息。)

如何使用与 VPS 的连词

所以VPS不在 API 中,所以没有使用 type signature 的便利操作Conj -> VPS -> VPS -> VPS。相反,您需要BaseVPS显式调用。这是工作代码,我将您的长表达式切成小块。

resource VPS = open SyntaxEng, ParadigmsEng, ExtendEng in {
  oper
    -- Lexicon
    sunny_A : A = mkA "sunny" ;
    rainy_A : A = mkA "rainy" ;
    monday_N : N  = mkN "Monday" ;
    tuesday_N : N  = mkN "Tuesday" ;

    -- Helper functions
    adj_on_day : A -> N -> VP = \a,n ->
      mkVP (mkVP a) (SyntaxEng.mkAdv on_Prep (mkNP n)) ;
    sunny_on_Monday_VP  : VP = adj_on_day sunny_A monday_N ;
    rainy_on_Tuesday_VP : VP = adj_on_day rainy_A tuesday_N ;

    tenseVPS : Tense -> VP -> VPS = \tns,vp -> 
      MkVPS (mkTemp tns simultaneousAnt) positivePol vp ;
    futureVPS = tenseVPS futureTense ;
    pastVPS = tenseVPS pastTense ;

    -- Constructing the phrase
    -- lin: "it will be sunny on Monday and will be rainy on Tuesday"
    futFutPhrase : Phr =
      mkPhr (
        PredVPS it_NP
                (ConjVPS -- : Conj -> [VPS] -> VPS
                   and_Conj -- : Conj
                   (BaseVPS -- : VPS -> VPS -> [VPS]
                     (futureVPS sunny_on_Monday_VP)  -- : VPS
                     (futureVPS rainy_on_Tuesday_VP) -- : VPS
                   )
                )
      ) ;

    -- lin: "it was sunny on Monday and will be rainy on Tuesday"
    pastFutPhrase : Phr =
      mkPhr (
        PredVPS it_NP
                (ConjVPS -- : Conj -> [VPS] -> VPS
                   and_Conj -- : Conj
                   (BaseVPS -- : VPS -> VPS -> [VPS]
                     (pastVPS sunny_on_Monday_VP)    -- : VPS
                     (futureVPS rainy_on_Tuesday_VP) -- : VPS
                   )
                )
      ) ;
}

它的工作原理是这样的:

$ gf
Languages:
> i -retain VPS.gf
> cc -one futFutPhrase
it will be sunny on Monday and will be rainy on Tuesday
> cc -one pastFutPhrase
it was sunny on Monday and will be rainy on Tuesday

所以时态在两种情况下都是重复的,因为连词是在 VPS 级别上,而不是在 AP 级别上。

如何创建您想要的短语

如果你想有省略号,“周一晴,周二下雨”,你需要使用AdvAP将 Adv“on Monday”附加到 AP“sunny” ,然后做一个 AP 连词,把那个 AP 变成VP,然后像往常一样在 Cl 中使用该 VP。这是代码,与之前的文件不同:

resource APConj = open SyntaxEng, ParadigmsEng, (A=AdjectiveEng) in {
  oper
    -- Lexicon
    sunny_A : A = mkA "sunny" ;
    rainy_A : A = mkA "rainy" ;
    monday_N : N  = mkN "Monday" ;
    tuesday_N : N  = mkN "Tuesday" ;

    -- Helper functions
    adj_on_day : A -> N -> AP = \a,n ->
      A.AdvAP (mkAP a) (SyntaxEng.mkAdv on_Prep (mkNP n)) ;
    sunny_on_Monday_AP  : AP = adj_on_day sunny_A monday_N ;
    rainy_on_Tuesday_AP : AP = adj_on_day rainy_A tuesday_N ;

    -- Constructing the phrase

    sunnyRainyEllipsisPhrase : Phr =
      mkPhr (
        mkCl (
          mkVP (mkAP and_Conj sunny_on_Monday_AP rainy_on_Tuesday_AP)
          )
      ) ;
}

像这样工作:

$ gf
Languages:
> i -retain APConj.gf 
> cc -one sunnyRainyEllipsisPhrase
it is sunny on Monday and rainy on Tuesday
于 2022-02-11T02:41:46.997 回答