mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
PGF2: fixes for named entity callback function
This commit is contained in:
@@ -44,6 +44,7 @@ import Data.IORef
|
|||||||
import Data.Char(isUpper,isSpace)
|
import Data.Char(isUpper,isSpace)
|
||||||
import Data.List(isSuffixOf,maximumBy)
|
import Data.List(isSuffixOf,maximumBy)
|
||||||
import Data.Function(on)
|
import Data.Function(on)
|
||||||
|
--import Debug.Trace
|
||||||
|
|
||||||
type CId = String
|
type CId = String
|
||||||
|
|
||||||
@@ -146,10 +147,12 @@ unloadConcr c = pgf_concrete_unload (concr c)
|
|||||||
|
|
||||||
data Type =
|
data Type =
|
||||||
DTyp [Hypo] CId [Expr]
|
DTyp [Hypo] CId [Expr]
|
||||||
|
deriving Show
|
||||||
|
|
||||||
data BindType =
|
data BindType =
|
||||||
Explicit
|
Explicit
|
||||||
| Implicit
|
| Implicit
|
||||||
|
deriving Show
|
||||||
|
|
||||||
-- | 'Hypo' represents a hypothesis in a type i.e. in the type A -> B, A is the hypothesis
|
-- | 'Hypo' represents a hypothesis in a type i.e. in the type A -> B, A is the hypothesis
|
||||||
type Hypo = (BindType,CId,Type)
|
type Hypo = (BindType,CId,Type)
|
||||||
@@ -510,13 +513,16 @@ nerc pgf (lang,concr) lin_idx sentence offset =
|
|||||||
"Language" -> Nothing
|
"Language" -> Nothing
|
||||||
_ -> pn
|
_ -> pn
|
||||||
where
|
where
|
||||||
retLit e = Just (expr,0,end_offset)
|
retLit e = --traceShow (name,e,drop end_offset sentence) $
|
||||||
pn = retLit expr
|
Just (e,0,end_offset)
|
||||||
expr = mkApp "SymbPN" [mkApp "MkSymb" [mkStr name]]
|
where end_offset = length sentence-length rest
|
||||||
end_offset = length sentence-length rest
|
pn = retLit (mkApp "SymbPN" [mkApp "MkSymb" [mkStr name]])
|
||||||
|
((lemma,cat),_) = maximumBy (compare `on` snd) (reverse ls)
|
||||||
|
ls = [((fun,cat),p)
|
||||||
|
|(fun,_,p)<-lookupMorpho concr name,
|
||||||
|
let cat=functionCat fun,
|
||||||
|
cat/="Nationality"]
|
||||||
name = trimRight (concat capwords)
|
name = trimRight (concat capwords)
|
||||||
ls = [((l,functionCat l),p)|(l,_,p)<-lookupMorpho concr name]
|
|
||||||
((lemma,cat),_) = maximumBy (compare `on` snd) ls
|
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
where
|
where
|
||||||
-- | Variant of unfoldr
|
-- | Variant of unfoldr
|
||||||
|
|||||||
Reference in New Issue
Block a user